Ilija Misov
Ilija Misov

Reputation: 41

AWS CloudFormation template "Launch configuration name not found"

I came across this issue with AWS CloudFormation template I'm creating. I am creating an AutoScaling group and assign LaunchConfiguration to it, but when I run the template I get the error "Launch configuration name not found - A launch configuration with the name: WebServerASLaunchConfig does not exists". Here is the exact code snippet

 "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"
                    }
                ]
            }
        }

Thanks for the help

Upvotes: 3

Views: 2011

Answers (1)

Daniel Conde Marin
Daniel Conde Marin

Reputation: 7742

To reference any parameters or resources make use of Ref.

Replace "LaunchConfigurationName": "WebServerASLaunchConfig", with:

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

Upvotes: 4

Related Questions