Skip to content

Commit 0e99922

Browse files
committed
convert user/pass parameters to secure ssm
1 parent f2a88bd commit 0e99922

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

aurora-postgres.cfhighlander.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
CfhighlanderTemplate do
2+
3+
Name 'aurora-postgres'
4+
Description "Highlander Aurora Postgres component #{component_version}"
25
DependsOn '[email protected]'
6+
37
Parameters do
48
ComponentParam 'EnvironmentName', 'dev', isGlobal: true
59
ComponentParam 'EnvironmentType', 'development', isGlobal: true, allowedValues: ['development', 'production']
610
ComponentParam 'StackOctet', isGlobal: true
11+
712
MappingParam('WriterInstanceType') do
813
map 'EnvironmentType'
914
attribute 'WriterInstanceType'
@@ -19,10 +24,8 @@
1924
maximum_availability_zones.times do |az|
2025
ComponentParam "SubnetPersistence#{az}"
2126
end
27+
2228
ComponentParam 'SnapshotID'
23-
ComponentParam 'MasterUsername', 'master'
24-
ComponentParam 'MasterUserPassword', 'pa33w0rd'
25-
2629
ComponentParam 'EnableReader', 'false'
2730
ComponentParam 'VPCId', type: 'AWS::EC2::VPC::Id'
2831
end

aurora-postgres.cfndsl.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
DBClusterParameterGroupName Ref(:DBClusterParameterGroup)
4040
SnapshotIdentifier Ref(:SnapshotID)
4141
SnapshotIdentifier FnIf('UseSnapshotID',Ref(:SnapshotID), Ref('AWS::NoValue'))
42-
MasterUsername FnIf('UseUsernameAndPassword',Ref(:MasterUsername), Ref('AWS::NoValue'))
43-
MasterUserPassword FnIf('UseUsernameAndPassword',Ref(:MasterUserPassword), Ref('AWS::NoValue'))
42+
MasterUsername FnIf('UseUsernameAndPassword', FnJoin('', [ '{{resolve:ssm:', FnSub(master_login['username_ssm_param']), ':1}}' ]), Ref('AWS::NoValue'))
43+
MasterUserPassword FnIf('UseUsernameAndPassword', FnJoin('', [ '{{resolve:ssm-secure:', FnSub(master_login['password_ssm_param']), ':1}}' ]), Ref('AWS::NoValue'))
4444
DBSubnetGroupName Ref(:DBClusterSubnetGroup)
4545
VpcSecurityGroupIds [ Ref(:SecurityGroup) ]
4646
Port cluster_port

aurora-postgres.config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ hostname: aurora2pg
33

44
cluster_port: 5432
55

6+
master_login:
7+
username_ssm_param: /rds/AURORA_POSTGRES_MASTER_USERNAME
8+
password_ssm_param: /rds/AURORA_POSTGRES_MASTER_PASSWORD
9+
610
# cluster_parameters:
711

812
# instance_parameters:

0 commit comments

Comments
 (0)