rp123409
rp123409

Reputation: 165

Stack creation failure - Failed to receive 1 resource signal(s) within the specified duration

I am trying to create a simple web deployment template which referencing resources from another template. Instance is created successfully but terminates with signal failure error. I am new to CloudFormation and seems kind of hit a roadblock here-

I am able to launch Linux EC2 instance, install httpd and create an index.html but code fails to execute the helper scripts it seems

AWSTemplateFormatVersion: 2010-09-09
Description: This template will create a web instance by refering an existing VPC created by another template.

Parameters:
  NetworkStackName:
    Description: >-
      Name of an active CloudFormation stack that contains the networking
      resources, such as the subnet and security group, that will be used in
      this stack.
    Type: String
    MinLength: 1
    MaxLength: 255
    AllowedPattern: '^[a-zA-Z][-a-zA-Z0-9]*$'
    Default: AR3Resource
  InstanceType:
    Description: EC2 Instance Type
    Type: String
    Default: t2.micro
    AllowedValues:
      - t1.micro
      - t2.nano
      - t2.micro
      - t2.small
      - t2.medium
      - t2.large
      - m1.small
      - m1.medium
      - m1.large
      - m1.xlarge
      - m2.xlarge
      - m2.2xlarge
      - m2.4xlarge
      - m3.medium
      - m3.large
      - m3.xlarge
      - m3.2xlarge
      - m4.large
      - m4.xlarge
      - m4.2xlarge
      - m4.4xlarge
      - m4.10xlarge
      - c1.medium
      - c1.xlarge
      - c3.large
      - c3.xlarge
      - c3.2xlarge
      - c3.4xlarge
      - c3.8xlarge
      - c4.large
      - c4.xlarge
      - c4.2xlarge
      - c4.4xlarge
      - c4.8xlarge
      - g2.2xlarge
      - g2.8xlarge
      - r3.large
      - r3.xlarge
      - r3.2xlarge
      - r3.4xlarge
      - r3.8xlarge
      - i2.xlarge
      - i2.2xlarge
      - i2.4xlarge
      - i2.8xlarge
      - d2.xlarge
      - d2.2xlarge
      - d2.4xlarge
      - d2.8xlarge
      - hi1.4xlarge
      - hs1.8xlarge
      - cr1.8xlarge
      - cc2.8xlarge
      - cg1.4xlarge
    ConstraintDescription: Must be a valid Instance type.
  KeyName:
    Description: Existing KeyPair name
    Type: AWS::EC2::KeyPair::KeyName
    ConstraintDescription: Must be an existing KeyPair from the region where instance is being created.
 # IPCidrRange:
 #   Description: ' The IP address range that can be used to SSH to the EC2 instances'
 #   Type: String
 #   MinLength: '9'
 #   MaxLength: '18'
 #   Default: 0.0.0.0/0
 #   AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})'
 #   ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.   
Mappings:    
  AWSInstanceType2Arch:
    t1.micro:
      Arch: HVM64
    t2.nano:
      Arch: HVM64
    t2.micro:
      Arch: HVM64
    t2.small:
      Arch: HVM64
    t2.medium:
      Arch: HVM64
    t2.large:
      Arch: HVM64
    m1.small:
      Arch: HVM64
    m1.medium:
      Arch: HVM64
    m1.large:
      Arch: HVM64
    m1.xlarge:
      Arch: HVM64
    m2.xlarge:
      Arch: HVM64
    m2.2xlarge:
      Arch: HVM64
    m2.4xlarge:
      Arch: HVM64
    m3.medium:
      Arch: HVM64
    m3.large:
      Arch: HVM64
    m3.xlarge:
      Arch: HVM64
    m3.2xlarge:
      Arch: HVM64
    m4.large:
      Arch: HVM64
    m4.xlarge:
      Arch: HVM64
    m4.2xlarge:
      Arch: HVM64
    m4.4xlarge:
      Arch: HVM64
    m4.10xlarge:
      Arch: HVM64
    c1.medium:
      Arch: HVM64
    c1.xlarge:
      Arch: HVM64
    c3.large:
      Arch: HVM64
    c3.xlarge:
      Arch: HVM64
    c3.2xlarge:
      Arch: HVM64
    c3.4xlarge:
      Arch: HVM64
    c3.8xlarge:
      Arch: HVM64
    c4.large:
      Arch: HVM64
    c4.xlarge:
      Arch: HVM64
    c4.2xlarge:
      Arch: HVM64
    c4.4xlarge:
      Arch: HVM64
    c4.8xlarge:
      Arch: HVM64
    g2.2xlarge:
      Arch: HVMG2
    g2.8xlarge:
      Arch: HVMG2
    r3.large:
      Arch: HVM64
    r3.xlarge:
      Arch: HVM64
    r3.2xlarge:
      Arch: HVM64
    r3.4xlarge:
      Arch: HVM64
    r3.8xlarge:
      Arch: HVM64
    i2.xlarge:
      Arch: HVM64
    i2.2xlarge:
      Arch: HVM64
    i2.4xlarge:
      Arch: HVM64
    i2.8xlarge:
      Arch: HVM64
    d2.xlarge:
      Arch: HVM64
    d2.2xlarge:
      Arch: HVM64
    d2.4xlarge:
      Arch: HVM64
    d2.8xlarge:
      Arch: HVM64
    hi1.4xlarge:
      Arch: HVM64
    hs1.8xlarge:
      Arch: HVM64
    cr1.8xlarge:
      Arch: HVM64
    cc2.8xlarge:
      Arch: HVM64
  AWSInstanceType2NATArch:
    t1.micro:
      Arch: NATHVM64
    t2.nano:
      Arch: NATHVM64
    t2.micro:
      Arch: NATHVM64
    t2.small:
      Arch: NATHVM64
    t2.medium:
      Arch: NATHVM64
    t2.large:
      Arch: NATHVM64
    m1.small:
      Arch: NATHVM64
    m1.medium:
      Arch: NATHVM64
    m1.large:
      Arch: NATHVM64
    m1.xlarge:
      Arch: NATHVM64
    m2.xlarge:
      Arch: NATHVM64
    m2.2xlarge:
      Arch: NATHVM64
    m2.4xlarge:
      Arch: NATHVM64
    m3.medium:
      Arch: NATHVM64
    m3.large:
      Arch: NATHVM64
    m3.xlarge:
      Arch: NATHVM64
    m3.2xlarge:
      Arch: NATHVM64
    m4.large:
      Arch: NATHVM64
    m4.xlarge:
      Arch: NATHVM64
    m4.2xlarge:
      Arch: NATHVM64
    m4.4xlarge:
      Arch: NATHVM64
    m4.10xlarge:
      Arch: NATHVM64
    c1.medium:
      Arch: NATHVM64
    c1.xlarge:
      Arch: NATHVM64
    c3.large:
      Arch: NATHVM64
    c3.xlarge:
      Arch: NATHVM64
    c3.2xlarge:
      Arch: NATHVM64
    c3.4xlarge:
      Arch: NATHVM64
    c3.8xlarge:
      Arch: NATHVM64
    c4.large:
      Arch: NATHVM64
    c4.xlarge:
      Arch: NATHVM64
    c4.2xlarge:
      Arch: NATHVM64
    c4.4xlarge:
      Arch: NATHVM64
    c4.8xlarge:
      Arch: NATHVM64
    g2.2xlarge:
      Arch: NATHVMG2
    g2.8xlarge:
      Arch: NATHVMG2
    r3.large:
      Arch: NATHVM64
    r3.xlarge:
      Arch: NATHVM64
    r3.2xlarge:
      Arch: NATHVM64
    r3.4xlarge:
      Arch: NATHVM64
    r3.8xlarge:
      Arch: NATHVM64
    i2.xlarge:
      Arch: NATHVM64
    i2.2xlarge:
      Arch: NATHVM64
    i2.4xlarge:
      Arch: NATHVM64
    i2.8xlarge:
      Arch: NATHVM64
    d2.xlarge:
      Arch: NATHVM64
    d2.2xlarge:
      Arch: NATHVM64
    d2.4xlarge:
      Arch: NATHVM64
    d2.8xlarge:
      Arch: NATHVM64
    hi1.4xlarge:
      Arch: NATHVM64
    hs1.8xlarge:
      Arch: NATHVM64
    cr1.8xlarge:
      Arch: NATHVM64
    cc2.8xlarge:
      Arch: NATHVM64
  AWSRegionArch2AMI:
    us-east-1:
      PV64: ami-8ff710e2
      HVM64: ami-f5f41398
      HVMG2: ami-4afd1d27
    us-west-2:
      PV64: ami-eff1028f
      HVM64: ami-d0f506b0
      HVMG2: ami-ee897b8e
    us-west-1:
      PV64: ami-ac85fbcc
      HVM64: ami-6e84fa0e
      HVMG2: ami-69106909
    eu-west-1:
      PV64: ami-23ab2250
      HVM64: ami-b0ac25c3
      HVMG2: ami-936de5e0
    eu-central-1:
      PV64: ami-27c12348
      HVM64: ami-d3c022bc
      HVMG2: ami-8e7092e1
    ap-northeast-1:
      PV64: ami-26160d48
      HVM64: ami-29160d47
      HVMG2: ami-91809aff
    ap-northeast-2:
      PV64: NOT_SUPPORTED
      HVM64: ami-cf32faa1
      HVMG2: NOT_SUPPORTED
    ap-southeast-1:
      PV64: ami-f3dd0a90
      HVM64: ami-1ddc0b7e
      HVMG2: ami-3c30e75f
    ap-southeast-2:
      PV64: ami-8f94b9ec
      HVM64: ami-0c95b86f
      HVMG2: ami-543d1137
    sa-east-1:
      PV64: ami-e188018d
      HVM64: ami-fb890097
      HVMG2: NOT_SUPPORTED
    cn-north-1:
      PV64: ami-77a46e1a
      HVM64: ami-05a66c68
      HVMG2: NOT_SUPPORTED
Resources:
  AR3Webserver:
    Type: AWS::EC2::Instance
    Metadata:
      'AWS::CloudFormation::Init':
        configSets:
          All: 
            - ConfigureApp
        ConfigureApp:    
          Packages:
            yum: 
              httpd: []
          files: 
            /var/www/html/index.html:
              content: !Join 
                - |+

                - - >-
                    <http>
                    <h1>This is a AR3 Test Website</h1>
                    </http>
              mode: '000644'
              owner: root
              group: root
          services:
            sysvinit:
              httpd:
                enabled: 'true'
                ensureRunning: 'true'
    Properties:
      InstanceType: !Ref InstanceType
      ImageId: !FindInMap [AWSRegionArch2AMI, !Ref 'AWS::Region', HVM64]
      KeyName: !Ref KeyName
      Tags:
        - Key: Application
          Value: !Ref 'AWS::StackId'
      NetworkInterfaces:
        - GroupSet: 
            - !ImportValue
              'Fn::Sub': '${NetworkStackName}-WebSecurityGroup'
          AssociatePublicIpAddress: 'true'
          DeviceIndex: '0'
          DeleteOnTermination: 'true'
          SubnetId: !ImportValue 
            'Fn::Sub': '${NetworkStackName}-PubSubnetID1'
      UserData: !Base64
        'Fn::Join':
          - ''
          - - |
              #!/bin/bash -xe
            - |
              yum update -y aws-cfn-bootstrap
            - |
              # Install the files and packages from the metadata
            - '/opt/aws/bin/cfn-init -v '
            - '         --stack '
            - !Ref 'AWS::StackName'
            - '         --resource AR3Webserver '
            - '         --configsets All '
            - '         --region '
            - !Ref 'AWS::Region'
            - |+

            - |
              # Signal the status from cfn-init
            - '/opt/aws/bin/cfn-signal -e $? '
            - '         --stack '
            - !Ref 'AWS::StackName'
            - '         --resource AR3Webserver '
            - '         --region '
            - !Ref 'AWS::Region'
            - |+
            
    CreationPolicy:
      ResourceSignal:
        Timeout: PT5M
Outputs:
  URL:
    Value: !Join
      - ''
      - - 'http://'
        - !GetAtt
          - AR3Webserver
          - PublicDnsName
    Description: AR3 Website URL

This is partially working now

AWSTemplateFormatVersion: 2010-09-09
Description: This template will create a web instance by refering an existing VPC created by another template.

Parameters:
  NetworkStackName:
    Description: >-
      Name of an active CloudFormation stack that contains the networking
      resources, such as the subnet and security group, that will be used in
      this stack.
    Type: String
    MinLength: 1
    MaxLength: 255
    AllowedPattern: '^[a-zA-Z][-a-zA-Z0-9]*$'
    Default: AR3Resource
  InstanceType:
    Description: EC2 Instance Type
    Type: String
    Default: t2.micro
    AllowedValues:
      - t1.micro
      - t2.nano
      - t2.micro
      - t2.small
      - t2.medium
      - t2.large
      - m1.small
      - m1.medium
      - m1.large
      - m1.xlarge
      - m2.xlarge
      - m2.2xlarge
      - m2.4xlarge
      - m3.medium
      - m3.large
      - m3.xlarge
      - m3.2xlarge
      - m4.large
      - m4.xlarge
      - m4.2xlarge
      - m4.4xlarge
      - m4.10xlarge
      - c1.medium
      - c1.xlarge
      - c3.large
      - c3.xlarge
      - c3.2xlarge
      - c3.4xlarge
      - c3.8xlarge
      - c4.large
      - c4.xlarge
      - c4.2xlarge
      - c4.4xlarge
      - c4.8xlarge
      - g2.2xlarge
      - g2.8xlarge
      - r3.large
      - r3.xlarge
      - r3.2xlarge
      - r3.4xlarge
      - r3.8xlarge
      - i2.xlarge
      - i2.2xlarge
      - i2.4xlarge
      - i2.8xlarge
      - d2.xlarge
      - d2.2xlarge
      - d2.4xlarge
      - d2.8xlarge
      - hi1.4xlarge
      - hs1.8xlarge
      - cr1.8xlarge
      - cc2.8xlarge
      - cg1.4xlarge
    ConstraintDescription: Must be a valid Instance type.
  KeyName:
    Description: Existing KeyPair name
    Type: AWS::EC2::KeyPair::KeyName
    ConstraintDescription: Must be an existing KeyPair from the region where instance is being created.
 # IPCidrRange:
 #   Description: ' The IP address range that can be used to SSH to the EC2 instances'
 #   Type: String
 #   MinLength: '9'
 #   MaxLength: '18'
 #   Default: 0.0.0.0/0
 #   AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})'
 #   ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.   
Mappings:    
  AWSInstanceType2Arch:
    t1.micro:
      Arch: HVM64
    t2.nano:
      Arch: HVM64
    t2.micro:
      Arch: HVM64
    t2.small:
      Arch: HVM64
    t2.medium:
      Arch: HVM64
    t2.large:
      Arch: HVM64
    m1.small:
      Arch: HVM64
    m1.medium:
      Arch: HVM64
    m1.large:
      Arch: HVM64
    m1.xlarge:
      Arch: HVM64
    m2.xlarge:
      Arch: HVM64
    m2.2xlarge:
      Arch: HVM64
    m2.4xlarge:
      Arch: HVM64
    m3.medium:
      Arch: HVM64
    m3.large:
      Arch: HVM64
    m3.xlarge:
      Arch: HVM64
    m3.2xlarge:
      Arch: HVM64
    m4.large:
      Arch: HVM64
    m4.xlarge:
      Arch: HVM64
    m4.2xlarge:
      Arch: HVM64
    m4.4xlarge:
      Arch: HVM64
    m4.10xlarge:
      Arch: HVM64
    c1.medium:
      Arch: HVM64
    c1.xlarge:
      Arch: HVM64
    c3.large:
      Arch: HVM64
    c3.xlarge:
      Arch: HVM64
    c3.2xlarge:
      Arch: HVM64
    c3.4xlarge:
      Arch: HVM64
    c3.8xlarge:
      Arch: HVM64
    c4.large:
      Arch: HVM64
    c4.xlarge:
      Arch: HVM64
    c4.2xlarge:
      Arch: HVM64
    c4.4xlarge:
      Arch: HVM64
    c4.8xlarge:
      Arch: HVM64
    g2.2xlarge:
      Arch: HVMG2
    g2.8xlarge:
      Arch: HVMG2
    r3.large:
      Arch: HVM64
    r3.xlarge:
      Arch: HVM64
    r3.2xlarge:
      Arch: HVM64
    r3.4xlarge:
      Arch: HVM64
    r3.8xlarge:
      Arch: HVM64
    i2.xlarge:
      Arch: HVM64
    i2.2xlarge:
      Arch: HVM64
    i2.4xlarge:
      Arch: HVM64
    i2.8xlarge:
      Arch: HVM64
    d2.xlarge:
      Arch: HVM64
    d2.2xlarge:
      Arch: HVM64
    d2.4xlarge:
      Arch: HVM64
    d2.8xlarge:
      Arch: HVM64
    hi1.4xlarge:
      Arch: HVM64
    hs1.8xlarge:
      Arch: HVM64
    cr1.8xlarge:
      Arch: HVM64
    cc2.8xlarge:
      Arch: HVM64
  AWSInstanceType2NATArch:
    t1.micro:
      Arch: NATHVM64
    t2.nano:
      Arch: NATHVM64
    t2.micro:
      Arch: NATHVM64
    t2.small:
      Arch: NATHVM64
    t2.medium:
      Arch: NATHVM64
    t2.large:
      Arch: NATHVM64
    m1.small:
      Arch: NATHVM64
    m1.medium:
      Arch: NATHVM64
    m1.large:
      Arch: NATHVM64
    m1.xlarge:
      Arch: NATHVM64
    m2.xlarge:
      Arch: NATHVM64
    m2.2xlarge:
      Arch: NATHVM64
    m2.4xlarge:
      Arch: NATHVM64
    m3.medium:
      Arch: NATHVM64
    m3.large:
      Arch: NATHVM64
    m3.xlarge:
      Arch: NATHVM64
    m3.2xlarge:
      Arch: NATHVM64
    m4.large:
      Arch: NATHVM64
    m4.xlarge:
      Arch: NATHVM64
    m4.2xlarge:
      Arch: NATHVM64
    m4.4xlarge:
      Arch: NATHVM64
    m4.10xlarge:
      Arch: NATHVM64
    c1.medium:
      Arch: NATHVM64
    c1.xlarge:
      Arch: NATHVM64
    c3.large:
      Arch: NATHVM64
    c3.xlarge:
      Arch: NATHVM64
    c3.2xlarge:
      Arch: NATHVM64
    c3.4xlarge:
      Arch: NATHVM64
    c3.8xlarge:
      Arch: NATHVM64
    c4.large:
      Arch: NATHVM64
    c4.xlarge:
      Arch: NATHVM64
    c4.2xlarge:
      Arch: NATHVM64
    c4.4xlarge:
      Arch: NATHVM64
    c4.8xlarge:
      Arch: NATHVM64
    g2.2xlarge:
      Arch: NATHVMG2
    g2.8xlarge:
      Arch: NATHVMG2
    r3.large:
      Arch: NATHVM64
    r3.xlarge:
      Arch: NATHVM64
    r3.2xlarge:
      Arch: NATHVM64
    r3.4xlarge:
      Arch: NATHVM64
    r3.8xlarge:
      Arch: NATHVM64
    i2.xlarge:
      Arch: NATHVM64
    i2.2xlarge:
      Arch: NATHVM64
    i2.4xlarge:
      Arch: NATHVM64
    i2.8xlarge:
      Arch: NATHVM64
    d2.xlarge:
      Arch: NATHVM64
    d2.2xlarge:
      Arch: NATHVM64
    d2.4xlarge:
      Arch: NATHVM64
    d2.8xlarge:
      Arch: NATHVM64
    hi1.4xlarge:
      Arch: NATHVM64
    hs1.8xlarge:
      Arch: NATHVM64
    cr1.8xlarge:
      Arch: NATHVM64
    cc2.8xlarge:
      Arch: NATHVM64
  AWSRegionArch2AMI:
    us-east-1:
      PV64: ami-8ff710e2
      HVM64: ami-f5f41398
      HVMG2: ami-4afd1d27
    us-west-2:
      PV64: ami-eff1028f
      HVM64: ami-d0f506b0
      HVMG2: ami-ee897b8e
    us-west-1:
      PV64: ami-ac85fbcc
      HVM64: ami-6e84fa0e
      HVMG2: ami-69106909
    eu-west-1:
      PV64: ami-23ab2250
      HVM64: ami-b0ac25c3
      HVMG2: ami-936de5e0
    eu-central-1:
      PV64: ami-27c12348
      HVM64: ami-d3c022bc
      HVMG2: ami-8e7092e1
    ap-northeast-1:
      PV64: ami-26160d48
      HVM64: ami-29160d47
      HVMG2: ami-91809aff
    ap-northeast-2:
      PV64: NOT_SUPPORTED
      HVM64: ami-cf32faa1
      HVMG2: NOT_SUPPORTED
    ap-southeast-1:
      PV64: ami-f3dd0a90
      HVM64: ami-1ddc0b7e
      HVMG2: ami-3c30e75f
    ap-southeast-2:
      PV64: ami-8f94b9ec
      HVM64: ami-0c95b86f
      HVMG2: ami-543d1137
    sa-east-1:
      PV64: ami-e188018d
      HVM64: ami-fb890097
      HVMG2: NOT_SUPPORTED
    cn-north-1:
      PV64: ami-77a46e1a
      HVM64: ami-05a66c68
      HVMG2: NOT_SUPPORTED
Resources:
  AR3Webserver:
    Type: AWS::EC2::Instance
    Metadata:
      'AWS::CloudFormation::Init':
        config:   
          Packages:
            yum: 
              httpd: []
          files: 
            /var/www/html/index.html:
              content: |
                <html>
                  <body>
                    <h1>AR3 Web </h1>
                    <h2>This is a test web page!!</h2>
                  </body
                </html>
              mode: '000644'
              owner: root
              group: root
            /etc/cfn/cfn-hup.conf:
              content: !Sub |
                [main]
                stack=${AWS::StackId}
                region=${AWS::Region}
                mode: '000400'
                owner: root
                group: root
            /etc/cfn/hooks.d/cfn-auto-reloader.conf:
              content: !Sub |
                [cfn-auto-reloader-hook]
                trigger=post.update
                path=Resources.AR3Webserver.Metadata.AWS::CloudFormation::Init
                action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource AR3Webserver --region ${AWS::Region}
                runas=root
                mode: '000400'
                owner: root
                group: root

          services:
            sysvinit:
              httpd:
                enabled: 'true'
                ensureRunning: 'true'
              cfn-hup:
                enabled: 'true'
                ensureRunning: 'true'
                files:
                  - /etc/cfn/cfn-hup.conf
                  - /etc/cfn/hooks.d/cfn-auto-reloader.conf
  
    Properties:
      InstanceType: !Ref InstanceType
      ImageId: !FindInMap [AWSRegionArch2AMI, !Ref 'AWS::Region', HVM64]
      KeyName: !Ref KeyName
      Tags:
        - Key: Application
          Value: !Ref 'AWS::StackId'
      NetworkInterfaces:
        - GroupSet: 
            - !ImportValue
              'Fn::Sub': '${NetworkStackName}-WebSecurityGroup'
          AssociatePublicIpAddress: 'true'
          DeviceIndex: '0'
          DeleteOnTermination: 'true'
          SubnetId: !ImportValue 
            'Fn::Sub': '${NetworkStackName}-PubSubnetID1'
      UserData: 
        'Fn::Base64': !Sub |
          #!/bin/bash -ex
          yum update -y aws-cfn-bootstrap
          /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource AR3Webserver --region ${AWS::Region}
          /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource AR3Webserver --region ${AWS::Region}
Outputs:
  URL:
    Value: !Join
      - ''
      - - 'http://'
        - !GetAtt
          - AR3Webserver
          - PublicDnsName
    Description: AR3 Website URL
Above template is getting created but httpd package is not getting deployed so service won't start

Error I am getting is

+ /opt/aws/bin/cfn-init -v --stack AR3Web --resource AR3Webserver --region us-east-1
+ Error occurred during build: Could not enable service httpd (return code 1)
+ Feb 16 12:09:53 cloud-init[2775]: util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [1]
+ Feb 16 12:09:53 cloud-init[2775]: cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
+ Feb 16 12:09:53 cloud-init[2775]: util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
+ Cloud-init v. 0.7.6 finished at Sat, 16 Feb 2019 12:09:53 +0000. Datasource DataSourceEc2.  Up 34.94 seconds

Upvotes: 4

Views: 11120

Answers (2)

Alex Harvey
Alex Harvey

Reputation: 15472

I see a few problems.

The immediate problem is the typo in the AWS::CloudFormation::Init section, where you have Packages with a capital P whereas the docs indicate it should be packages all be in lower case. This is causing the httpd package to not be installed, which in turn leads to the error message you see when the services section tries to start httpd.

This then causes the UserData script to error out, and so the cfn-signal is not sent, and error message is seen:

Failed to receive 1 resource signal(s) within the specified duration

In addition, (and I mean in the second version of your template), there are other typos, where mode, owner and group are all incorrectly indented (one level too deep). This will result in all of that config being misinterpreted as part of the file content.

If you fix all that up, it should be fine.

Upvotes: 3

John Rotenstein
John Rotenstein

Reputation: 269282

First, I should mention that the template is WAY old. It is using AMIs from 2016 and all of those mappings can be replaced with a simple parameter based on Query for the latest Amazon Linux AMI IDs using AWS Systems Manager Parameter Store | AWS Compute Blog.

Anyway, the error you are receiving says that the startup script running on the EC2 instance failed to signal success.

The /var/log/cloud-init-output.log file on the EC2 instance says:

Error occurred during build: Could not enable service httpd (return code 1)

So, it seems have a problem with these configuration lines:

      services:
        sysvinit:
          httpd:
            enabled: 'true'
            ensureRunning: 'true'

Upvotes: 2

Related Questions