Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aurora-postgres.cfhighlander.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
CfhighlanderTemplate do

Name 'aurora-postgres'
Description "Highlander Aurora Postgres component #{component_version}"
DependsOn 'vpc@1.2.0'

Parameters do
ComponentParam 'EnvironmentName', 'dev', isGlobal: true
ComponentParam 'EnvironmentType', 'development', isGlobal: true, allowedValues: ['development', 'production']
ComponentParam 'StackOctet', isGlobal: true

MappingParam('WriterInstanceType') do
map 'EnvironmentType'
attribute 'WriterInstanceType'
Expand All @@ -19,6 +24,7 @@
maximum_availability_zones.times do |az|
ComponentParam "SubnetPersistence#{az}"
end

ComponentParam 'SnapshotID'
ComponentParam 'EnableReader', 'false'
ComponentParam 'VPCId', type: 'AWS::EC2::VPC::Id'
Expand Down
9 changes: 8 additions & 1 deletion aurora-postgres.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Description "#{component_name} - #{component_version}"

Condition("EnableReader", FnEquals(Ref("EnableReader"), 'true'))
Condition("UseUsernameAndPassword", FnEquals(Ref(:SnapshotID), ''))
Condition("UseSnapshotID", FnNot(FnEquals(Ref(:SnapshotID), '')))

az_conditions_resources('SubnetPersistence', maximum_availability_zones)

tags = []
Expand All @@ -26,7 +29,7 @@

RDS_DBClusterParameterGroup(:DBClusterParameterGroup) {
Description FnJoin(' ', [ Ref(:EnvironmentName), component_name, 'cluster parameter group' ])
Family 'aurora-postgresql'
Family 'aurora-postgresql9.6'
Parameters cluster_parameters if defined? cluster_parameters
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), component_name, 'cluster-parameter-group' ])}]
}
Expand All @@ -35,8 +38,12 @@
Engine 'aurora-postgresql'
DBClusterParameterGroupName Ref(:DBClusterParameterGroup)
SnapshotIdentifier Ref(:SnapshotID)
SnapshotIdentifier FnIf('UseSnapshotID',Ref(:SnapshotID), Ref('AWS::NoValue'))
MasterUsername FnIf('UseUsernameAndPassword', FnJoin('', [ '{{resolve:ssm:', FnSub(master_login['username_ssm_param']), ':1}}' ]), Ref('AWS::NoValue'))
MasterUserPassword FnIf('UseUsernameAndPassword', FnJoin('', [ '{{resolve:ssm-secure:', FnSub(master_login['password_ssm_param']), ':1}}' ]), Ref('AWS::NoValue'))
DBSubnetGroupName Ref(:DBClusterSubnetGroup)
VpcSecurityGroupIds [ Ref(:SecurityGroup) ]
Port cluster_port
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), component_name, 'cluster' ])}]
}

Expand Down
6 changes: 6 additions & 0 deletions aurora-postgres.config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
maximum_availability_zones: 5
hostname: aurora2pg

cluster_port: 5432

master_login:
username_ssm_param: /rds/AURORA_POSTGRES_MASTER_USERNAME
password_ssm_param: /rds/AURORA_POSTGRES_MASTER_PASSWORD

# cluster_parameters:

# instance_parameters:
Expand Down