Last active
November 29, 2020 17:21
-
-
Save paprika101/9ab2c759ca823748e6be56eab17b7293 to your computer and use it in GitHub Desktop.
The cloudformation YAML template for creating a Postgres Aurora DB cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
AWSTemplateFormatVersion: "2010-09-09" | |
Description: A basic CFN template to create an Aurora DB cluster | |
Parameters: | |
SecurityGroupID: | |
Description: Security Group Name used by Aurora DB | |
Type: String | |
DBName: | |
Description: The database name for Aurora PostgreSQL DB instance | |
Type: String | |
DBMasterUsername: | |
Description: The database master/super username. | |
Type: String | |
DBMasterUserPassword: | |
Description: The password for database master/super user. | |
Type: String | |
NoEcho: "true" | |
DBInstanceClass: | |
Description: Database instance class | |
Type: String | |
DBAllocatedStorage: | |
Description: The memory to be allocated for your database | |
Type: Number | |
SubnetId1: | |
Description: Subnet ID in 1st AZ of your region | |
Type: String | |
SubnetId2: | |
Description: Subnet ID in 2nd AZ of your region | |
Type: String | |
EnablePerformanceInsights: | |
Description: A value that indicates whether to enable Performance Insights for the DB instance. | |
Type: String | |
Default: false | |
MultiAZ: | |
Description: true, in case you wish to have a multi-AZ deployment | |
Type: String | |
Default: false | |
Resources: | |
DBCluster: | |
DependsOn: | |
- DBSubnetGroup | |
- DBClusterPG | |
Type: AWS::RDS::DBCluster | |
Properties: | |
BackupRetentionPeriod: 7 | |
DBClusterIdentifier: auroradbcluster | |
DBClusterParameterGroupName: !Ref DBClusterPG | |
DBSubnetGroupName: !Ref DBSubnetGroup | |
DatabaseName: !Ref DBName | |
DeletionProtection: false | |
Engine: aurora-postgresql | |
EngineMode: provisioned | |
EngineVersion: 10.11 | |
MasterUserPassword: !Ref DBMasterUserPassword | |
MasterUsername: !Ref DBMasterUsername | |
Port: 5432 | |
SourceRegion: !Ref 'AWS::Region' | |
StorageEncrypted: true | |
VpcSecurityGroupIds: | |
- Ref: SecurityGroupID | |
DBClusterPG: | |
Type: AWS::RDS::DBClusterParameterGroup | |
Properties: | |
Description: DB Cluster Parameter Group for your Aurora DB cluster | |
Family: aurora-postgresql10 | |
Parameters: | |
rds.logical_replication: 1 | |
DBParameterGroup: | |
Type: AWS::RDS::DBParameterGroup | |
Properties: | |
Tags: | |
- Key: "Name" | |
Value: myrdsdbparametergroup | |
Description: Database Parameter Group for your Aurora DB Instnace | |
Family: postgres10 | |
Parameters: | |
shared_preload_libraries: "pg_stat_statements, pg_hint_plan" | |
DBSubnetGroup: | |
Type: AWS::RDS::DBSubnetGroup | |
Properties: | |
Tags: | |
- Key: "Name" | |
Value: myrdsdbsubnetgroup | |
DBSubnetGroupDescription: An appropriate description for your DB subnet group. | |
DBSubnetGroupName: myrdsdbsubnetgroup | |
SubnetIds: | |
- Ref: SubnetId1 | |
- Ref: SubnetId2 | |
DBInstance: | |
DependsOn: | |
- DBSubnetGroup | |
- DBParameterGroup | |
Type: AWS::RDS::DBInstance | |
Properties: | |
Tags: | |
- Key: "Name" | |
Value: mypostgresdb | |
DBInstanceIdentifier: mypostgresdb | |
DBName: | |
Ref: DBName | |
AllocatedStorage: | |
Ref: DBAllocatedStorage | |
DBInstanceClass: | |
Ref: DBInstanceClass | |
Engine: aurora-postgresql | |
EngineVersion: 10.11 | |
MasterUsername: | |
Ref: DBMasterUsername | |
MasterUserPassword: | |
Ref: DBMasterUserPassword | |
DBSubnetGroupName: | |
Ref: DBSubnetGroup | |
DBParameterGroupName: | |
Ref: DBParameterGroup | |
VPCSecurityGroups: | |
- Ref: SecurityGroupID | |
StorageType: gp2 | |
StorageEncrypted: "true" | |
EnablePerformanceInsights: | |
Ref: EnablePerformanceInsights | |
MultiAZ: !Ref MultiAZ | |
AutoMinorVersionUpgrade: true | |
CopyTagsToSnapshot: true | |
BackupRetentionPeriod: 7 | |
PubliclyAccessible: false | |
Outputs: | |
RDSEndpoint: | |
Description: RDS Database Endpoint | |
Value: | |
Fn::GetAtt: | |
- DBInstance | |
- Endpoint.Address | |
Export: | |
Name: | |
Fn::Sub: "RDSEndpoint" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment