Summary of CloudFormation Helper Scripts Training

Example Configuration in Markdown

Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Metadata:
      AWS::CloudFormation::Init:
        configSets:
          setup:
            - install_server
        install_server:
          packages:
            yum:
              httpd: []
          files:
            "/var/www/html/index.html":
              content: |
                Hello world!
              mode: 000644
              owner: root
              group: root
          services:
            sysvinit:
              httpd:
                enabled: true
                ensureRunning: true
    Properties:
      # ... other properties ...
      UserData:
        Fn::Base64: !Sub |
          #!/bin/bash -xe
          yum update -y aws-cfn-bootstrap
          /opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource MyInstance --configsets setup --region ${AWS::Region}
          /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource MyInstance --region ${AWS::Region}