This file is indexed.

/etc/heat/templates/AWS_RDS_DBInstance.yaml is in heat-common 1:6.0.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
HeatTemplateFormatVersion: '2012-12-12'
Description: 'Builtin AWS::RDS::DBInstance'
Parameters:
  AllocatedStorage:
    Type: String
  DBInstanceClass:
    Type: String
  DBName:
    Type: String
  DBSecurityGroups:
    Type: CommaDelimitedList
    Default: ''
  Engine:
    Type: String
    AllowedValues: ['MySQL']
  MasterUsername:
    Type: String
  MasterUserPassword:
    Type: String
  Port:
    Type: String
    Default: '3306'
  KeyName:
    Type: String
    Default: ''

Mappings:
  DBInstanceToInstance:
    db.m1.small: {Instance: m1.small}
    db.m1.large: {Instance: m1.large}
    db.m1.xlarge: {Instance: m1.xlarge}
    db.m2.xlarge: {Instance: m2.xlarge}
    db.m2.2xlarge: {Instance: m2.2xlarge}
    db.m2.4xlarge: {Instance: m2.4xlarge}

Resources:
  ServerSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: 'Enable SSH access'
      SecurityGroupIngress:
      - IpProtocol: icmp
        FromPort: '-1'
        ToPort: '-1'
        CidrIp: '0.0.0.0/0'
      - IpProtocol: tcp
        FromPort: '22'
        ToPort : '22'
        CidrIp : '0.0.0.0/0'
      - IpProtocol: tcp
        FromPort: {Ref: Port}
        ToPort : {Ref: Port}
        CidrIp : '0.0.0.0/0'
  DatabaseInstance:
    Type: AWS::EC2::Instance
    Metadata:
      AWS::CloudFormation::Init:
        config:
          files:
            /tmp/db_setup.sql:
              content:
                'Fn::Replace':
                - DBName: {Ref: DBName}
                  MasterUserPassword: {Ref: MasterUserPassword}
                  MasterUsername: {Ref: MasterUsername}
                - |
                  CREATE DATABASE DBName;
                  GRANT ALL PRIVILEGES ON DBName.* TO "MasterUsername"@"%"
                  IDENTIFIED BY "MasterUserPassword";
                  FLUSH PRIVILEGES;
                  EXIT
              mode: '000644'
              owner: root
              group: root
          packages:
            yum:
              mariadb: []
              mariadb-server: []
          services:
            systemd:
              mysqld:
                enabled: true
                ensureRunning: true
    Properties:
      ImageId: F19-x86_64-cfntools
      InstanceType: {'Fn::FindInMap': [DBInstanceToInstance,
                                       {Ref: DBInstanceClass}, Instance]}
      KeyName: {Ref: KeyName}
      SecurityGroups: [{"Ref" : "ServerSecurityGroup"}]
      UserData:
        Fn::Base64:
          Fn::Replace:
          - 'AWS::StackName': {Ref: 'AWS::StackName'}
            'AWS::Region': {Ref: 'AWS::Region'}
            MasterUserPassword: {Ref: MasterUserPassword}
            WaitHandle: {Ref: WaitHandle}
          - |
            #!/bin/bash -v
            #
            iptables -F

            # Helper function
            function error_exit
            {
              /opt/aws/bin/cfn-signal -e 1 -r \"$1\" 'WaitHandle'
              exit 1
            }
            /opt/aws/bin/cfn-init -s AWS::StackName -r DatabaseInstance --region AWS::Region || error_exit 'Failed to run cfn-init'
            # Setup MySQL root password and create a user
            mysqladmin -u root password 'MasterUserPassword'
            mysql -u root --password='MasterUserPassword' < /tmp/db_setup.sql || error_exit 'Failed to setup mysql'

            # Database setup completed, signal success
            /opt/aws/bin/cfn-signal -e 0 -r "MySQL server setup complete" 'WaitHandle'

  WaitHandle:
    Type: AWS::CloudFormation::WaitConditionHandle
  WaitCondition:
    Type: AWS::CloudFormation::WaitCondition
    DependsOn: DatabaseInstance
    Properties:
      Handle: {Ref: WaitHandle}
      Timeout: "600"

Outputs:
  Endpoint.Address: {'Fn::GetAtt': [DatabaseInstance, PublicIp]}
  Endpoint.Port: {Ref: Port}