Skip to content

Instantly share code, notes, and snippets.

@viktorfa
Created August 14, 2020 14:20
Show Gist options
  • Select an option

  • Save viktorfa/cb0e1d4ebe1a22cdb8468f682e948873 to your computer and use it in GitHub Desktop.

Select an option

Save viktorfa/cb0e1d4ebe1a22cdb8468f682e948873 to your computer and use it in GitHub Desktop.

Revisions

  1. viktorfa created this gist Aug 14, 2020.
    86 changes: 86 additions & 0 deletions aurora.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@
    # cloudformation/aurora.yml

    Resources:
    RDSCluster:
    Type: AWS::RDS::DBCluster
    Properties:
    MasterUsername: DBUsername
    MasterUserPassword: DBPassword
    DatabaseName: DBName
    Engine: aurora
    EngineMode: serverless
    ScalingConfiguration:
    AutoPause: true
    MaxCapacity: 1
    MinCapacity: 1
    SecondsUntilAutoPause: 300
    DeletionProtection: false
    DBSubnetGroupName: !Ref RDSSubnetGroup
    VpcSecurityGroupIds:
    - !GetAtt SecurityGroup.GroupId

    VPC:
    Type: AWS::EC2::VPC

    Properties:
    CidrBlock: 172.32.0.0/16
    EnableDnsSupport: true
    EnableDnsHostnames: true
    InstanceTenancy: default

    SubnetA:
    Type: AWS::EC2::Subnet

    Properties:
    CidrBlock: 172.32.0.0/20
    AvailabilityZone: !Select [0, !GetAZs '']
    MapPublicIpOnLaunch: true

    VpcId: !Ref VPC

    SubnetB:
    Type: AWS::EC2::Subnet

    Properties:
    CidrBlock: 172.32.16.0/20
    AvailabilityZone: !Select [1, !GetAZs '']
    MapPublicIpOnLaunch: true

    VpcId: !Ref VPC
    SubnetC:
    Type: AWS::EC2::Subnet

    Properties:
    CidrBlock: 172.32.32.0/20
    AvailabilityZone: !Select [2, !GetAZs '']
    MapPublicIpOnLaunch: true

    VpcId: !Ref VPC

    SecurityGroup:
    Type: AWS::EC2::SecurityGroup

    Properties:
    GroupName: ${ self:service }-security-group
    GroupDescription: "Security group for RDS"

    SecurityGroupIngress:
    - IpProtocol: tcp
    FromPort: 3306
    ToPort: 3306
    - IpProtocol: tcp
    FromPort: 3306
    ToPort: 3306
    CidrIp: 0.0.0.0/0

    VpcId: !Ref VPC

    RDSSubnetGroup:
    Type: AWS::RDS::DBSubnetGroup

    Properties:
    DBSubnetGroupDescription: "Subnet group for RDS"
    SubnetIds:
    - !Ref SubnetA
    - !Ref SubnetB
    - !Ref SubnetC