kubernetes-retired / kube-aws

[EOL] A command-line tool to declaratively manage Kubernetes clusters on AWS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid cloudformation stack template in 0.14.0-rc1

cw-sakamoto opened this issue · comments

I'm try to create cluster with 0.14.0-rc1, failed to validate control plane.

Unresolved resource dependencies [Test1aSubnet, Test1dSubnet, Test1cSubnet] in the Resources block of the template

I confirmed stack-template:
0.14.0-rc1

            "VPCZoneIdentifier":[
               {
                  "Ref":"Test1aSubnet"
               },
               {
                  "Ref":"Test1cSubnet"
               },
               {
                  "Ref":"Test1dSubnet"
               }

0.12.3

            "VPCZoneIdentifier":[
               {
                  "Fn::ImportValue":{
                     "Fn::Sub":"${NetworkStackName}-Test1aSubnet"
                  }
               },
               {
                  "Fn::ImportValue":{
                     "Fn::Sub":"${NetworkStackName}-Test1cSubnet"
                  }
               }
            ],

cluster.yaml:

subnets:
  - name: test-1a-subnet
    availabilityZone: ap-northeast-1a
    instanceCIDR: "10.0.5.0/25"

  - name: test-1c-subnet
    availabilityZone: ap-northeast-1c
    instanceCIDR: "10.0.5.128/25"

  - name: test-1d-subnet
    availabilityZone: ap-northeast-1d
    instanceCIDR: "10.0.6.0/25"

Have you changed the writing method for subnets in cluster.yaml?

ok, was wondering why I'm not seeing that issue and for me it be because I am deploying into existing subnets: -

subnets:
  - name: a
    availabilityZone: us-west-2a
    private: true
    id: subnet-xxx
  - name: b
    availabilityZone: us-west-2b
    private: true
    id: subnet-xxx
  - name: c
    availabilityZone: us-west-2c
    private: true
    id: subnet-xxx

So the issue here must be in the behavoir when creating the subnets...

Judging from your output it looks as though the subnet reference is being supplied by the logicalNameProvider function and not from the stackoutput as previously indicated.

func (i Identifier) Ref(logicalNameProvider func() string) string {
	if i.IDFromStackOutput != "" {
		return fmt.Sprintf(`{ "Fn::ImportValue" : %q }`, i.IDFromStackOutput)
	} else if i.ID != "" {
		return fmt.Sprintf(`"%s"`, i.ID)
	} else if i.IDFromFn != "" {
		return i.IDFromFn
	} else {
		return fmt.Sprintf(`{ "Ref" : %q }`, logicalNameProvider())
	}
}

I will look a bit more as to why this could be happening.

Reproduced the error

This operation will create/update the cluster. Are you sure? [y,n]: y
generating assets for control-plane, network, etcd, nodepool-a, nodepool-b, nodepool-c
Error: failed to validate control plane: invalid cloudformation stack template https://s3.amazonaws.com/034324643013-k8tool-us-west-2/cf/davem-lab-secure/kube-aws/clusters/davem-lab-secure/exported/stacks/control-plane/stack.json: ValidationError: Template format error: Unresolved resource dependencies [A, B, C] in the Resources block of the template
	status code: 400, request id: c41b3bda-7895-11e9-b023-4bc9204ec5c0

Hi please can you test the code at my PR #1598? We don't create subnets using kube-aws so I can't test this. I hope this change will resolve your issue (and we can roll it into a rc.2 release)

I confirmed that #1598 works well. Thank you for your work !!

stack.json:

            "VPCZoneIdentifier":[  
               {  
                  "Fn::ImportValue":{  
                     "Fn::Sub":"${NetworkStackName}-Test1aSubnet"
                  }
               },
               {  
                  "Fn::ImportValue":{  
                     "Fn::Sub":"${NetworkStackName}-Test1cSubnet"
                  }
               },
               {  
                  "Fn::ImportValue":{  
                     "Fn::Sub":"${NetworkStackName}-Test1dSubnet"
                  }
               }
            ],