3

我在创建 AWS CloudFormation 模板时遇到了这个问题。我正在创建一个 AutoScaling 组并将 LaunchConfiguration 分配给它,但是当我运行模板时,我收到错误“找不到启动配置名称 - 名称为:WebServerASLaunchConfig 的启动配置不存在”。这是确切的代码片段

 "WebServerASLaunchConfig": {
            "Type" : "AWS::AutoScaling::LaunchConfiguration",
            "Properties": {
                "ImageId": {
                    "Ref": "BaseImageId"
                },
                "KeyName": {
                    "Ref": "KeyPairName"
                },
                "AssociatePublicIpAddress" : "True",
                "InstanceType": "t2.small",
                "SecurityGroups": [
                    {
                        "Ref": "EC2InstanceSecurityGroup"
                    }
                ]
            }
         },
        "WebServerAutoScalingGroup": {
            "Type": "AWS::AutoScaling::AutoScalingGroup",
            "Properties": {
                "LaunchConfigurationName": "WebServerASLaunchConfig",
                "AvailabilityZones": [
                    {
                        "Ref": "AvailabilityZone1"
                    },
                    {
                        "Ref": "AvailabilityZone2"
                    }
                ],
                "VPCZoneIdentifier": [
                    {
                        "Ref" : "PublicSubnet1"
                    },
                    {
                        "Ref" : "PublicSubnet2"
                    }
                ],
                "MinSize" : "2",
                "MaxSize" : "2",
                "LoadBalancerNames": [
                    {
                        "Ref" : "ApplicationLoadBalancer"
                    }
                ],
                "Tags": [
                    {
                        "Key": "Name",
                        "Value": {
                            "Fn::Join": [ 
                                "-",
                                [
                                    {
                                        "Ref": "AWS::StackName"
                                    },
                                    "VPC"
                                ]                                
                            ]
                        },
                        "PropagateAtLaunch": "True"
                    }
                ]
            }
        }

谢谢您的帮助

4

1 回答 1

4

要引用任何参数或资源,请使用Ref

替换"LaunchConfigurationName": "WebServerASLaunchConfig", 为:

"LaunchConfigurationName": { "Ref": "WebServerASLaunchConfig" }

于 2017-10-24T12:19:04.453 回答