From db304dddee01a011401a69f2bf12e021faad259d Mon Sep 17 00:00:00 2001 From: icereval Date: Fri, 30 Dec 2016 20:34:37 -0500 Subject: [PATCH] use computed stack name to ensure node pools are nested within the cluster --- cluster/cluster.go | 6 +++--- config/config.go | 2 +- nodepool/cluster/cluster.go | 2 +- nodepool/config/config.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cluster/cluster.go b/cluster/cluster.go index 8625b59c5..42f0ff21c 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -148,7 +148,7 @@ func (c *Cluster) stackProvisioner() *cfnstack.Provisioner { ] } ` - return cfnstack.NewProvisioner(c.ClusterName, c.WorkerDeploymentSettings().StackTags(), stackPolicyBody, c.session) + return cfnstack.NewProvisioner(c.StackName(), c.WorkerDeploymentSettings().StackTags(), stackPolicyBody, c.session) } func (c *Cluster) Create(stackBody string, s3URI string) error { @@ -209,7 +209,7 @@ func (c *Cluster) lockEtcdResources(cfSvc *cloudformation.CloudFormation, stackB //Fetch and unmarshal existing stack resource defintions res, err := cfSvc.GetTemplate(&cloudformation.GetTemplateInput{ - StackName: aws.String(c.ClusterName), + StackName: aws.String(c.StackName()), }) if err != nil { return "", fmt.Errorf("error getting stack template: %v", err) @@ -269,7 +269,7 @@ func (c *Cluster) Info() (*Info, error) { resp, err := cfSvc.DescribeStackResource( &cloudformation.DescribeStackResourceInput{ LogicalResourceId: aws.String("ElbAPIServer"), - StackName: aws.String(c.ClusterName), + StackName: aws.String(c.StackName()), }, ) if err != nil { diff --git a/config/config.go b/config/config.go index ec9efb6b4..145cc350d 100644 --- a/config/config.go +++ b/config/config.go @@ -693,7 +693,7 @@ type Config struct { // CloudFormation stack name which is unique in an AWS account. // This is intended to be used to reference stack name from cloud-config as the target of awscli or cfn-bootstrap-tools commands e.g. `cfn-init` and `cfn-signal` -func (c Config) StackName() string { +func (c Cluster) StackName() string { return c.ClusterName } diff --git a/nodepool/cluster/cluster.go b/nodepool/cluster/cluster.go index 2d839fc54..b51690dee 100644 --- a/nodepool/cluster/cluster.go +++ b/nodepool/cluster/cluster.go @@ -59,7 +59,7 @@ func (c *Cluster) stackProvisioner() *cfnstack.Provisioner { ] }` - return cfnstack.NewProvisioner(c.NodePoolName, c.WorkerDeploymentSettings().StackTags(), stackPolicyBody, c.session) + return cfnstack.NewProvisioner(c.StackName(), c.WorkerDeploymentSettings().StackTags(), stackPolicyBody, c.session) } func (c *Cluster) Create(stackBody string, s3URI string) error { diff --git a/nodepool/config/config.go b/nodepool/config/config.go index f05810584..66942bbd5 100644 --- a/nodepool/config/config.go +++ b/nodepool/config/config.go @@ -213,8 +213,8 @@ func (c ProvidedConfig) valid() error { // CloudFormation stack name which is unique in an AWS account. // This is intended to be used to reference stack name from cloud-config as the target of awscli or cfn-bootstrap-tools commands e.g. `cfn-init` and `cfn-signal` -func (c ComputedConfig) StackName() string { - return c.NodePoolName +func (c ProvidedConfig) StackName() string { + return c.ClusterName + "-" + c.NodePoolName } func (c ComputedConfig) VPCRef() string {