Skip to content

Commit

Permalink
Merge pull request #2 from theonestack/custom_ssm_username_path
Browse files Browse the repository at this point in the history
allows passing custom path values for the username and password
  • Loading branch information
Guslington authored Mar 4, 2019
2 parents c4d5c06 + bd003ab commit b123004
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions amazonmq.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@

security_groups.each do |name, sg|
sg['ports'].each do |port|

EC2_SecurityGroupIngress("#{name}SGRule#{port['from']}") do
Description FnSub("Allows #{port['from']} from #{name}")
IpProtocol 'tcp'
FromPort port['from']
ToPort port.key?('to') ? port['to'] : port['from']
GroupId FnGetAtt("SecurityGroup#{safe_component_name}",'GroupId')
SourceSecurityGroupId sg.key?('stack_param') ? Ref(sg['stack_param']) : Ref(name)
SourceSecurityGroupId sg.key?('stack_param') ? Ref(sg['stack_param']) : Ref(name) unless sg.has_key?('cidrip')
CidrIp sg['cidrip'] if sg.has_key?('cidrip')
end
end if sg.key?('ports')
end if defined? security_groups
Expand All @@ -49,11 +51,13 @@
amq_users=[]
users.each do |user|

username_key = user.has_key?('username_key') ? user['username_key'] : 'username'
password_key = user.has_key?('password_key') ? user['password_key'] : 'password'
Resource("#{user['username']}SSMSecureParameter") {
Type "Custom::SSMSecureParameter"
Property('ServiceToken', FnGetAtt('SSMSecureParameterCR', 'Arn'))
Property('Length', user['password_length']) if user.has_key?('password_length')
Property('Path', FnSub("#{user['ssm_path']}/password"))
Property('Path', FnSub("#{user['ssm_path']}/#{password_key}"))
Property('Description', FnSub("${EnvironmentName} AMQ User #{user['username']} Password"))
Property('Tags',[
{ Key: 'Name', Value: FnSub("${EnvironmentName}-#{user['username']}-amq-password")},
Expand All @@ -63,7 +67,7 @@
}

SSM_Parameter("#{user['username']}ParameterSecretKey") {
Name FnSub("#{user['ssm_path']}/username")
Name FnSub("#{user['ssm_path']}/#{username_key}")
Type 'String'
Value "#{user['username']}"
}
Expand Down

0 comments on commit b123004

Please sign in to comment.