Resources:
  MyDatabaseRdsInstance:
    DeletionPolicy: Delete
    Properties:
      AllocatedStorage: 50
      AllowMajorVersionUpgrade: true
      AutoMinorVersionUpgrade: false
      AvailabilityZone:
        Fn::Select:
        - 0
        - Fn::GetAZs: ''
      BackupRetentionPeriod: 1
      DBInstanceClass: db.t3.medium
      DBParameterGroupName:
        Ref: MyDatabasePostgres11ParameterGroup
      DBSubnetGroupName:
        Ref: MyDatabaseDbSubnetGroup
      EnableCloudwatchLogsExports:
      - postgresql
      - upgrade
      Engine: postgres
      EngineVersion: '11.6'
      MasterUserPassword: ypWTXyFkmVFQGfqsRLzFjhEmsijXh32b
      MasterUsername: root
      MultiAZ: false
      StorageType: gp2
      VPCSecurityGroups:
      - Ref: MyDatabaseFirewallSecurityGroup
    Type: AWS::RDS::DBInstance
  MyDatabasePostgres11ParameterGroup:
    Properties:
      Description: DBParameterGroup for Postgres11
      Family: postgres11
    Type: AWS::RDS::DBParameterGroup
  MyDatabaseDbSubnetGroup:
    Properties:
      DBSubnetGroupDescription: DBSubnetGroup
      SubnetIds:
      - Ref: MyDatabaseSubnetGroupSubnet
      - Ref: MyDatabaseSubnetGroupSubnet2
      - Ref: MyDatabaseSubnetGroupSubnet3
    Type: AWS::RDS::DBSubnetGroup
  MyDatabaseSubnetGroupSubnet:
    Properties:
      AvailabilityZone:
        Fn::Select:
        - 0
        - Fn::GetAZs: ''
      CidrBlock: 10.0.8.0/26
      Tags:
      - Key: Name
        Value: MyDatabaseSubnetGroupSubnet
      VpcId:
        Ref: SkeletonVpc
    Type: AWS::EC2::Subnet
  MyDatabaseSubnetGroupSubnet2:
    Properties:
      AvailabilityZone:
        Fn::Select:
        - 1
        - Fn::GetAZs: ''
      CidrBlock: 10.0.8.64/26
      Tags:
      - Key: Name
        Value: MyDatabaseSubnetGroupSubnet2
      VpcId:
        Ref: SkeletonVpc
    Type: AWS::EC2::Subnet
  MyDatabaseSubnetGroupSubnet3:
    Properties:
      AvailabilityZone:
        Fn::Select:
        - 2
        - Fn::GetAZs: ''
      CidrBlock: 10.0.8.128/26
      Tags:
      - Key: Name
        Value: MyDatabaseSubnetGroupSubnet3
      VpcId:
        Ref: SkeletonVpc
    Type: AWS::EC2::Subnet
  MyDatabaseSubnetGroupSubnetRouteTableAssociation:
    Properties:
      RouteTableId:
        Ref: MyDatabaseSkeletonRouteTable
      SubnetId:
        Ref: MyDatabaseSubnetGroupSubnet
    Type: AWS::EC2::SubnetRouteTableAssociation
  MyDatabaseSubnetGroupSubnetRouteTableAssociation2:
    Properties:
      RouteTableId:
        Ref: MyDatabaseSkeletonRouteTable
      SubnetId:
        Ref: MyDatabaseSubnetGroupSubnet2
    Type: AWS::EC2::SubnetRouteTableAssociation
  MyDatabaseSubnetGroupSubnetRouteTableAssociation3:
    Properties:
      RouteTableId:
        Ref: MyDatabaseSkeletonRouteTable
      SubnetId:
        Ref: MyDatabaseSubnetGroupSubnet3
    Type: AWS::EC2::SubnetRouteTableAssociation
  SkeletonVpc:
    Properties:
      CidrBlock: 10.0.0.0/16
    Type: AWS::EC2::VPC
  MyDatabaseSkeletonRoute:
    Properties:
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId:
        Ref: SkeletonInternetGateway
      RouteTableId:
        Ref: MyDatabaseSkeletonRouteTable
    Type: AWS::EC2::Route
  MyDatabaseSkeletonRouteTable:
    Properties:
      VpcId:
        Ref: SkeletonVpc
    Type: AWS::EC2::RouteTable
  SkeletonInternetGateway:
    Type: AWS::EC2::InternetGateway
  MyDatabaseFirewallSecurityGroup:
    Properties:
      GroupDescription: SecurityGroup
      SecurityGroupIngress:
      - CidrIp: 10.0.0.0/16
        FromPort: 5432
        IpProtocol: 6
        ToPort: 5432
      Tags:
      - Key: Name
        Value: MyDatabaseFirewallSecurityGroup
      VpcId:
        Ref: SkeletonVpc
    Type: AWS::EC2::SecurityGroup
  SkeletonVpcGatewayAttachment:
    Properties:
      InternetGatewayId:
        Ref: SkeletonInternetGateway
      VpcId:
        Ref: SkeletonVpc
    Type: AWS::EC2::VPCGatewayAttachment
