Amazon Relational Database Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 49: Line 49:
   PostgresSubnetGroup:
   PostgresSubnetGroup:
     Type: AWS::RDS::DBSubnetGroup
     Type: AWS::RDS::DBSubnetGroup
      Properties:
    Properties:
        DBSubnetGroupDescription: !Sub The subnet group used by the ${MicroworldName}/${EnvironmentName} environment PostgreSQL instance
      DBSubnetGroupDescription: !Sub The subnet group used by the ${MicroworldName}/${EnvironmentName} environment PostgreSQL instance
        DBSubnetGroupName: !Sub ${MicroworldName}-${EnvironmentName}-postgres-subnet-group
      DBSubnetGroupName: !Sub ${MicroworldName}-${EnvironmentName}-postgres-subnet-group
        SubnetIds:
      SubnetIds:
          - !Ref PostgresSubnet
        - !Ref PostgresSubnet
        Tags:
      Tags:
          - Key: Name
        - Key: Name
            Value: !Sub ${MicroworldName}-${EnvironmentName}-postgres-subnet-group
          Value: !Sub ${MicroworldName}-${EnvironmentName}-postgres-subnet-group


=Deploying a RDS Instance into a Specific VPC=
=Deploying a RDS Instance into a Specific VPC=


{{Internal|Deploying a RDS Instance into a Specific VPC|Deploying a RDS Instance into a Specific VPC}}
{{Internal|Deploying a RDS Instance into a Specific VPC|Deploying a RDS Instance into a Specific VPC}}

Revision as of 19:27, 17 April 2019

Internal

Create a Database Instance with CloudFormation

AWS::RDS::DBInstance

AWS::RDS::DBInstance
Resources:
  PostgresDBInstance: 
  Type: AWS::RDS::DBInstance
  DeletionPolicy: Delete
  Properties: 
    DBName: themyscira01
    DBInstanceIdentifier: !Sub ${EnvironmentName}-${MicroworldName}-postgres
    AllocatedStorage: 8
    DBInstanceClass: db.t2.micro
    Engine: postgres
    EngineVersion: 9.4.20
    MasterUsername: bn73hewc
    MasterUserPassword: ce75h9w0
    #
    # This is what configures the DB instance to be deployed in a specific VPC. See VPC Association.
    #
    DBSubnetGroupName: !Ref PostgresSubnetGroup
    VPCSecurityGroups:
      - !Ref PostgresSecurityGroup
    Tags: 
      - Key: Name
        Value: !Sub ${EnvironmentName}-${MicroworldName}-postgres

For details on DBSubnetGroupName and VPCSecurityGroups, see:

Deploying a RDS Instance into a Specific VPC

Return Values

Ref

Returns instance identifier (DBInstanceIdentifier).

GetAtt

  • Endpoint.Address returns the connection endpoint for the database (e.g. mystack-mydb-1apw1j4phylrk.cg034hpkmmjt.us-east-2.rds.amazonaws.com)
  • Endpoint.Port

AWS::RDS::DBSubnetGroup

AWS::RDS::DBSubnetGroup
Resources:
  PostgresSubnetGroup:
    Type: AWS::RDS::DBSubnetGroup
    Properties:
      DBSubnetGroupDescription: !Sub The subnet group used by the ${MicroworldName}/${EnvironmentName} environment PostgreSQL instance
      DBSubnetGroupName: !Sub ${MicroworldName}-${EnvironmentName}-postgres-subnet-group
      SubnetIds:
        - !Ref PostgresSubnet
      Tags:
        - Key: Name
          Value: !Sub ${MicroworldName}-${EnvironmentName}-postgres-subnet-group

Deploying a RDS Instance into a Specific VPC

Deploying a RDS Instance into a Specific VPC