我正在使用terraform创建Ali云托管的kubernetes。我关注的链接如下: https://www.terraform.io/docs/providers/alicloud/r/cs_managed_kubernetes.html
我正在使用与地形状态完全相同的代码。我正在使用的可用区域是cn-shenzhen-a
,但是,当我运行terraform apply
时,总是会出现此错误
alicloud_cs_managed_kubernetes.k8s: [ERROR] terraform-provider-alicloud/alicloud/resource_alicloud_cs_managed_kubernetes.go:322: Resource alicloud_cs_managed_kubernetes CreateKubernetesCluster Failed!!! [SDK denverdino/aliyungo ERROR]:
Aliyun API Error: RequestId: C598AA1D-6993-46F6-A831-A9A6E8B8CEC1 Status Code: 400 Code: ZoneNotSupported Message: The current zone does not support creating SLB, please try other zones
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
我仔细检查了SLB,发现cn-shenzhen-a
可以创建SLB。
我使用的阿里云帐户是中国帐户而不是国际帐户。
答案 0 :(得分:0)
您应该尽早创建vpc和vswitch,并在k8s配置中设置vswitch_ids。 它可以解决我环境中的相同问题。
data "alicloud_vswitches" "vswitch"{
}
resource "alicloud_cs_managed_kubernetes" "k8s" {
......
vswitch_ids = [data.alicloud_vswitches.vswitch.vswitches[0].id]
}
答案 1 :(得分:0)
通过指定vswitch_ids而不是Availability_zone来尝试:
resource "alicloud_cs_managed_kubernetes" "k8s" {
name = "${var.name}"
# availability_zone = "cn-beijing-c"
vswitch_ids = ["vsw-2ze........."]
# availability_zone = "${data.alicloud_zones.main.zones.2.id}"
new_nat_gateway = true
...