title: cnf-init throws Python error on ubuntu ami
body: <p>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:</p>
  <p><code>Error occurred during build: list indices must be integers, not unicode</code></p>
  <p>This is my Cloudformation template:</p>
  <pre>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&lt;AWS::EC2::Subnet::Id&gt;'
    DomainUrl:
      Description: The url of the site excluding any sub domains eg. &quot;example.com&quot;
      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: 
                - &quot;nginx-core&quot;
            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 &quot;upgrade&quot;;
                        proxy_pass http://phoenix;
                      }
                    }
            commands:
              01-restartNginx:
                command: service nginx restart
          configSets:
            setup:
              - &quot;nginx&quot;
      Properties:
        ImageId: &quot;ami-0701e7be9b2a77600&quot;
        InstanceType: t1.micro
        KeyName: &quot;main&quot;
        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 &quot;&quot; ]
          - !Select [ 1, !GetAZs &quot;&quot; ]
        LaunchConfigurationName: !Ref AuthScalingLaunchConfig
        TargetGroupARNs:
          - !Ref TargetGroup
        HealthCheckGracePeriod: &quot;60&quot;
        HealthCheckType: EC2
        VPCZoneIdentifier: !Ref Subnets
        MaxSize: &quot;10&quot;
        DesiredCapacity: &quot;1&quot;
        MinSize: &quot;1&quot;
  </pre>
  <p>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.</p>