I'm using the below aws cloudformation template to spin up an autoscaling group and it's throwing a python error when I try to run cfn-init. I've tried everything I can think of to resolve this but I'm now totally stumped. The error I get is:
Error occurred during build: list indices must be integers, not unicode
This is my Cloudformation template:
Description: 'Autoscaling groups' Parameters: DeploymentProfileARN: Description: The ARN of the iam group with deployment permissions. Type: String PublicSecurityGroup: Description: The security group for use with ec2. Type: String TargetGroup: Description: The load balancer target group Type: String Subnets: Description: The load balancer target group Type: 'List<AWS::EC2::Subnet::Id>' DomainUrl: Description: The url of the site excluding any sub domains eg. "example.com" Type: String EnvironmentName: Description: An environment name that will be prefixed to resource names Type: String Default: Dev AllowedValues: [Prod, Uat, Dev] MasterDataBaseAddress: Description: The address of the master database Type: String Resources: AuthScalingLaunchConfig: Type: AWS::AutoScaling::LaunchConfiguration Metadata: AWS::CloudFormation::Init: nginx: packages: apt: - "nginx-core" files: '/tmp/test': content: !Sub | test '/etc/nginx/sites-enabled/default': content: !Sub | upstream phoenix { server 127.0.0.1:4000 max_fails=5 fail_timeout=60s; } server { listen 80 default_server; server_name .${DomainUrl}; location / { allow all; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Cluster-Client-Ip $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://phoenix; } } commands: 01-restartNginx: command: service nginx restart configSets: setup: - "nginx" Properties: ImageId: "ami-0701e7be9b2a77600" InstanceType: t1.micro KeyName: "main" IamInstanceProfile: !Ref DeploymentProfileARN SecurityGroups: - !Ref PublicSecurityGroup UserData: Fn::Base64: !Sub | #!/bin/bash # install cfn apt update apt install -y python-pip mkdir -p /opt/aws/bin pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gpip cfn-init --stack ${AWS::StackName} --resource AuthScalingLaunchConfig --region ${AWS::Region} --configsets setup service cfn-hup start AutoScalingGroup: Type: AWS::AutoScaling::AutoScalingGroup Properties: AvailabilityZones: - !Select [ 0, !GetAZs "" ] - !Select [ 1, !GetAZs "" ] LaunchConfigurationName: !Ref AuthScalingLaunchConfig TargetGroupARNs: - !Ref TargetGroup HealthCheckGracePeriod: "60" HealthCheckType: EC2 VPCZoneIdentifier: !Ref Subnets MaxSize: "10" DesiredCapacity: "1" MinSize: "1"
Any help or steers in the right direction would be awesome. I've tried using different versions of the aws-cfn-bootstrap but they've all given me the same issue.