Skip to content

Commit

Permalink
Merge pull request #3 from Samseppiol/master
Browse files Browse the repository at this point in the history
Convert component to use new cfndsl yaml constant syntax
  • Loading branch information
Guslington authored Jan 13, 2020
2 parents 528fefa + cbbe42d commit 2c38f3f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions eks-cluster.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
Condition("SpotEnabled", FnNot(FnEquals(Ref('SpotPrice'), '')))

tags = []
extra_tags.each { |key,value| tags << { Key: FnSub(key), Value: FnSub(value) } } if defined? extra_tags
extra_tags = external_parameters.fetch(:extra_tags, {})
extra_tags.each { |key,value| tags << { Key: FnSub(key), Value: FnSub(value) } }

IAM_Role(:EksClusterRole) {
AssumeRolePolicyDocument service_role_assume_policy('eks')
Expand Down Expand Up @@ -104,17 +105,20 @@
FromPort 443
}

cluster_name = external_parameters.fetch(:cluster_name, '')
eks_version = external_parameters.fetch(:eks_version, nil)
EKS_Cluster(:EksCluster) {
Name FnSub(cluster_name) if defined? cluster_name
Name FnSub(cluster_name) unless cluster_name.empty?
ResourcesVpcConfig({
SecurityGroupIds: [ Ref(:EksClusterSecurityGroup) ],
SubnetIds: FnSplit(',', Ref('SubnetIds'))
})
RoleArn FnGetAtt(:EksClusterRole, :Arn)
Version eks_version if defined? eks_version
Version eks_version unless eks_version.nil?
}

policies = []
iam = external_parameters[:iam]
iam['policies'].each do |name,policy|
policies << iam_policy_allow(name,policy['action'],policy['resource'] || '*')
end if iam.has_key?('policies')
Expand All @@ -133,9 +137,9 @@

# Setup userdata string
node_userdata = "#!/bin/bash\nset -o xtrace\n"
node_userdata << eks_bootstrap if defined? eks_bootstrap
node_userdata << userdata if defined? userdata
node_userdata << cfnsignal if defined? cfnsignal
node_userdata << external_parameters.fetch(:eks_bootstrap, '')
node_userdata << userdata = external_parameters.fetch(:userdata, '')
node_userdata << cfnsignal = external_parameters.fetch(:cfnsignal, '')

launch_template_tags = [
{ Key: 'Name', Value: FnSub("${EnvironmentName}-eks-node-xx") },
Expand All @@ -157,7 +161,8 @@
InstanceType: Ref('InstanceType')
}

if defined? spot
spot = external_parameters.fetch(:spot, {})
unless spot.empty?
spot_options = {
MarketType: 'spot',
SpotOptions: {
Expand Down Expand Up @@ -190,4 +195,8 @@
})
}


Output(:EksNodeSecurityGroup) {
Value(Ref(:EksNodeSecurityGroup))
}
end

0 comments on commit 2c38f3f

Please sign in to comment.