首页 > 解决方案 > 遇到不支持的属性版本

问题描述

当我尝试运行此 CloudFormation 模板时,在 GitlabRunnerASG 上收到错误“遇到不支持的属性版本”:

        "Resources": {
        "GitlabRunnerASG": {
            "Type": "AWS::AutoScaling::AutoScalingGroup",
            "Properties": {
                "AvailabilityZones": {
                    "Ref": "SubnetASGAZ"
                },
                "LaunchTemplate": {             
                  "LaunchTemplateId": {
                    "Ref":"MyLaunchTemplate"
                   }
                },
                "Version": {
                  "Fn::GetAtt":[
                    "MyLaunchTemplate",
                    "LatestVersionNumber"
                    ]
                },
                "VPCZoneIdentifier": {
                    "Ref": "SubnetIds"
                },
                "MaxSize": {
                    "Ref": "NumberOfInstances"
                },
                "MinSize": {
                    "Ref": "NumberOfInstances"
                },
        "MyLaunchTemplate": {
            "Type": "AWS::EC2::LaunchTemplate",
            "Properties": {
              "LaunchTemplateName":{"Fn::Sub":"${AWS::StackName}-launch-template"},
              "LaunchTemplateData": {             
                "SecurityGroups": {
                    "Ref": "SecurityGroupName"
                },
                "InstanceType": {
                    "Ref": "EC2Type"
                },
                "ImageId": {
                    "Ref": "RunnerAMIId"
                },
                "IamInstanceProfile": {
                    "Arn":{"Fn::GetAtt": ["MyIamInstanceProfile", "Arn"]}
                },
                "BlockDeviceMappings": [
                    {
                        "DeviceName": "/dev/xvda",
                        "Ebs": {
                            "DeleteOnTermination": true,
                            "VolumeSize": {
                                "Ref": "EC2HardDriveSize"
                            },
                            "VolumeType": "gp2"
                        }
                    }
                ],
                "UserData": {
                    "Fn::Base64": {
                        "Fn::Sub": ""
                    }
                }
              }
            }
        }

标签: amazon-web-servicesamazon-cloudformation

解决方案


建议在VSCode中尝试CloudFormation Linter以在编写模板以及自动完成和文档链接时内联查看其中一些错误:

Visual Studio 代码扩展

[cfn-lint] E3003: Property Version missing at Resources/GitlabRunnerASG/Properties/LaunchTemplate
[cfn-lint] E3002: Invalid Property Resources/GitlabRunnerASG/Properties/Version

推荐阅读