Skip to content

Commit

Permalink
Made the keypair parameter optional
Browse files Browse the repository at this point in the history
* Removed stupid debug output

* Made the keypair parameter optional
  • Loading branch information
kyletbase2 committed Jul 2, 2021
1 parent 5f84e30 commit e46b8d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bastion.cfhighlander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
ComponentParam 'Ami', type: 'AWS::EC2::Image::Id'
ComponentParam 'SpotPrice', ''
ComponentParam 'InstanceType'
ComponentParam 'KeyName'
ComponentParam 'KeyName', ''
ComponentParam 'DnsDomain'
ComponentParam 'SubnetIds', type: 'CommaDelimitedList'
ComponentParam 'VPCId', type: 'AWS::EC2::VPC::Id'
Expand Down
5 changes: 2 additions & 3 deletions bastion.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
private_only = external_parameters.fetch(:private_only, false)

Condition("SpotPriceSet", FnNot(FnEquals(Ref('SpotPrice'), '')))
Condition("KeypairSet", FnNot(FnEquals(Ref('KeyName'), '')))

EC2_SecurityGroup('SecurityGroupBastion') do
GroupDescription FnJoin(' ', [ Ref('EnvironmentName'), component_name ])
Expand Down Expand Up @@ -73,12 +74,10 @@

if defined? userdata
if userdata.is_a?(String)
puts("IS A STRING")
bastion_userdata.push(*userdata.split("\n")) if defined? userdata
end

if userdata.kind_of?(Array)
puts("IS AN ARRAY")
bastion_userdata.push(*userdata) if defined? userdata
end
end
Expand All @@ -88,7 +87,7 @@
InstanceType Ref('InstanceType')
AssociatePublicIpAddress true unless private_only.equal? true
IamInstanceProfile Ref('InstanceProfile')
KeyName Ref('KeyName')
KeyName FnIf('KeypairSet', Ref('KeyName'), Ref('AWS::NoValue'))
SpotPrice FnIf('SpotPriceSet', Ref('SpotPrice'), Ref('AWS::NoValue'))
SecurityGroups [ Ref('SecurityGroupBastion') ]
UserData FnBase64(FnJoin("",bastion_userdata))
Expand Down

0 comments on commit e46b8d0

Please sign in to comment.