aliyun / terraform-provider-alicloud

Terraform AliCloud provider
https://www.terraform.io/docs/providers/alicloud/
Mozilla Public License 2.0
585 stars 549 forks source link

alicloud_cs_managed_kubernetes does not export nat_gateway_id #1704

Open edonosotti opened 4 years ago

edonosotti commented 4 years ago

According to the documentation at: https://www.terraform.io/docs/providers/alicloud/r/cs_managed_kubernetes.html

alicloud_cs_managed_kubernetes should export:

nat_gateway_id - The ID of nat gateway used to launch kubernetes cluster.

When trying to get the NAT gateway ID to associate an EIP, I get this error (from terraform validate):

Error: Unsupported attribute

  on cs.tf line 27, in resource "alicloud_eip_association" "eip_nat":
  27:   instance_id = "${alicloud_cs_managed_kubernetes.k8s.nat_gateway_id}"

This object has no argument, nested block, or exported attribute named
"nat_gateway_id".
demonwy commented 4 years ago

hi @edonosotti the resource alicloud_cs_managed_kubernetes does not export nat_gateway_id, but you can get it by data resource "alicloud_nat_gateways", here is the example https://www.terraform.io/docs/providers/alicloud/d/nat_gateways.html#example-usage

edonosotti commented 4 years ago

@demonwy thank you for the suggestion. However, if you want to do something with the nat_gateway_id in the same plan where the NAT Gateway is created, you would have to use the depends_on directive on the data resource, which is not recommended as a best practice: https://www.terraform.io/docs/configuration/data-sources.html

demonwy commented 4 years ago

@edonosotti ok, i see. another way, We recommend creating VPC/NAT/SNAT in advance, and then set new_nat_gateway to false on resource cs_managed_kubernetes. https://www.terraform.io/docs/providers/alicloud/r/cs_managed_kubernetes.html#new_nat_gateway

edonosotti commented 4 years ago

Thanks @demonwy