Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
Move r53 schecks to create, update nodepool stack template
Browse files Browse the repository at this point in the history
  • Loading branch information
Saso Matejina committed Jan 11, 2017
1 parent 55721f1 commit 81316bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 35 deletions.
10 changes: 5 additions & 5 deletions cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ func (c *Cluster) stackProvisioner() *cfnstack.Provisioner {
}

func (c *Cluster) Validate(stackBody string, s3URI string) error {
r53Svc := route53.New(c.session)
if err := c.validateDNSConfig(r53Svc); err != nil {
return err
}

ec2Svc := ec2.New(c.session)
if err := c.validateKeyPair(ec2Svc); err != nil {
return err
Expand All @@ -178,6 +173,11 @@ func (c *Cluster) Validate(stackBody string, s3URI string) error {
}

func (c *Cluster) Create(stackBody string, s3URI string) error {
r53Svc := route53.New(c.session)
if err := c.validateDNSConfig(r53Svc); err != nil {
return err
}

if err := c.Validate(stackBody, s3URI); err != nil {
return err
}
Expand Down
45 changes: 15 additions & 30 deletions nodepool/config/templates/stack-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"SpotPrice": "{{$.Worker.SpotFleet.SpotPrice}}",
"LaunchSpecifications": [
{{range $subnetIndex, $subnet := $.Subnets}}
{{with $subnetLogicalName := printf "Subnet%d" $subnetIndex}}
{{range $specIndex, $spec := $.Worker.SpotFleet.LaunchSpecifications}}
{{if or (gt $subnetIndex 0) (gt $specIndex 0) }},{{end}}
{
Expand Down Expand Up @@ -44,13 +43,12 @@
{{end}}
],
"SubnetId": {
"Ref": "{{$subnetLogicalName}}"
{{$subnet.Ref}}
},
"UserData": "{{$.UserDataWorker}}"
}
{{end}}
{{end}}
{{end}}
]
}
}
Expand Down Expand Up @@ -104,12 +102,8 @@
{{end}}
"VPCZoneIdentifier": [
{{range $index, $subnet := .Subnets}}
{{with $subnetLogicalName := printf "Subnet%d" $index}}
{{if gt $index 0}},{{end}}
{
"Ref": "{{$subnetLogicalName}}"
}
{{end}}
{{$subnet.Ref}}
{{end}}
]
},
Expand Down Expand Up @@ -318,17 +312,17 @@
"Type": "AWS::IAM::Role"
}
{{range $index, $subnet := .Subnets}}
{{with $subnetLogicalName := printf "Subnet%d" $index}}
{{if not $subnet.SubnetId }}
,
"{{$subnetLogicalName}}": {
"{{$subnet.SubnetLogicalName}}": {
"Properties": {
"AvailabilityZone": "{{$subnet.AvailabilityZone}}",
"CidrBlock": "{{$subnet.InstanceCIDR}}",
"MapPublicIpOnLaunch": {{$.MapPublicIPs}},
"Tags": [
{
"Key": "Name",
"Value": "{{$.NodePoolName}}-{{$subnetLogicalName}}"
"Value": "{{$.NodePoolName}}-{{$subnet.SubnetLogicalName}}"
},
{
"Key": "KubernetesCluster",
Expand All @@ -338,35 +332,26 @@
"VpcId": {{$.VPCRef}}
},
"Type": "AWS::EC2::Subnet"
},
"{{$subnet.SubnetLogicalName}}RouteTableAssociation": {
"Properties": {
"RouteTableId": {{$.RouteTableRef}},
"SubnetId": {{$subnet.Ref}},
},
"Type": "AWS::EC2::SubnetRouteTableAssociation"
}
{{end}}
{{if $.ElasticFileSystemID}}
,
"{{$subnetLogicalName}}MountTarget": {
"{{$subnet.SubnetLogicalName}}MountTarget": {
"Properties" : {
"FileSystemId": "{{$.ElasticFileSystemID}}",
"SubnetId": { "Ref": "{{$subnetLogicalName}}" },
"SubnetId": { "Ref": "{{$subnet.SubnetLogicalName}}" },
"SecurityGroups": [ { "Ref": "SecurityGroupMountTarget" } ]
},
"Type" : "AWS::EFS::MountTarget"
}
{{end}}
{{end}}
{{end}}

{{range $index, $subnet := .Subnets}}
{{with $subnetLogicalName := printf "Subnet%d" $index}}
,
"{{$subnetLogicalName}}RouteTableAssociation": {
"Properties": {
"RouteTableId": {{$.RouteTableRef}},
"SubnetId": {
"Ref": "{{$subnetLogicalName}}"
}
},
"Type": "AWS::EC2::SubnetRouteTableAssociation"
}
{{end}}
{{end}}

}
}

0 comments on commit 81316bd

Please sign in to comment.