遇到不受支持的属性版本

问题描述

当我尝试运行此 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": ""
                    }
                }
              }
            }
        }

解决方法

AWS::AutoScaling::AutoScalingGroup 没有 getAnimals() 属性。也许这应该是 getInstitution() 的一部分?

,

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

Visual Studio Code extension

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