terraform-provider-alicloud: Error on creating a ManagedKubernetes Cluster

Terraform Version

0.11.7

Affected Resource(s)

  • alicloud_cs_managed_kubernetes

Terraform Configuration Files


resource "alicloud_vswitch" "vswitches" {
  count             = "${length(var.vswitch_ids) > 0 ? 0 : length(var.vswitch_cidrs)}"
  vpc_id            = "${var.vpc_id == "" ? join("", alicloud_vpc.vpc.*.id) : var.vpc_id}"
  cidr_block        = "${element(var.vswitch_cidrs, count.index)}"
  availability_zone = "${lookup(data.alicloud_zones.main.zones[count.index%length(data.alicloud_zones.main.zones)], "id")}"
  name              = "${var.vswitch_name_prefix == "" ? format("%s-%s", var.example_name, format(var.number_format, count.index+1)) : format("%s-%s", var.vswitch_name_prefix, format(var.number_format, count.index+1))}"
}

resource "alicloud_nat_gateway" "default" {
  count  = "${var.new_nat_gateway == true ? 1 : 0}"
  vpc_id = "${var.vpc_id == "" ? join("", alicloud_vpc.vpc.*.id) : var.vpc_id}"
  name   = "${var.example_name}"
  specification = "Small"
}

resource "alicloud_eip" "default" {
  count     = "${var.new_nat_gateway == "true" ? 1 : 0}"
  bandwidth = "${var.eip_bandwidth}"
}

resource "alicloud_eip_association" "default" {
  count         = "${var.new_nat_gateway == "true" ? 1 : 0}"
  allocation_id = "${alicloud_eip.default.id}"
  instance_id   = "${alicloud_nat_gateway.default.id}"
}

resource "alicloud_snat_entry" "default" {
  count             = "${var.new_nat_gateway == "false" ? 0 : length(var.vswitch_ids) > 0 ? length(var.vswitch_ids) : length(var.vswitch_cidrs)}"
  snat_table_id     = "${alicloud_nat_gateway.default.snat_table_ids}"
  source_vswitch_id = "${length(var.vswitch_ids) > 0 ? element(split(",", join(",", var.vswitch_ids)), count.index%length(split(",", join(",", var.vswitch_ids)))) : length(var.vswitch_cidrs) < 1 ? "" : element(split(",", join(",", alicloud_vswitch.vswitches.*.id)), count.index%length(split(",", join(",", alicloud_vswitch.vswitches.*.id))))}"
  snat_ip           = "${alicloud_eip.default.ip_address}"
}

resource "alicloud_cs_managed_kubernetes" "k8s" {
  name = "${var.name}"
  availability_zone = "${data.alicloud_zones.main.zones.0.id}"
  new_nat_gateway = false
  vswitch_ids = ["${length(var.vswitch_ids) > 0 ? element(split(",", join(",", var.vswitch_ids)), count.index%length(split(",", join(",", var.vswitch_ids)))) : length(var.vswitch_cidrs) < 1 ? "" : element(split(",", join(",", alicloud_vswitch.vswitches.*.id)), count.index%length(split(",", join(",", alicloud_vswitch.vswitches.*.id))))}"]
  worker_instance_types = ["${data.alicloud_instance_types.default.instance_types.0.id}"]
  worker_numbers = [2]
  key_name = "${alicloud_key_pair.k8s.key_name}"
  pod_cidr = "172.20.0.0/16"
  service_cidr = "172.21.0.0/20"
  install_cloud_monitor = true
  slb_internet_enabled = true
  worker_disk_category  = "cloud_efficiency"
  worker_disk_size  = "50"
}

Debug Output

alicloud_cs_managed_kubernetes.k8s: Creating...
  availability_zone:           "" => "cn-shenzhen-c"
  install_cloud_monitor:       "" => "true"
  key_name:                    "" => "aliyun_k8s_key_pair"
  name:                        "" => "cluster-k8s"
  name_prefix:                 "" => "Terraform-Creation"
  new_nat_gateway:             "" => "false"
  pod_cidr:                    "" => "172.20.0.0/16"
  security_group_id:           "" => "<computed>"
  service_cidr:                "" => "172.21.0.0/20"
  slb_internet_enabled:        "" => "true"
  vpc_id:                      "" => "<computed>"
  vswitch_ids.#:               "" => "1"
  vswitch_ids.0:               "" => "vsw-wz97ptmmopa17pjrr1bi9"
  worker_disk_category:        "" => "cloud_efficiency"
  worker_disk_size:            "" => "50"
  worker_instance_charge_type: "" => "PostPaid"
  worker_instance_types.#:     "" => "1"
  worker_instance_types.0:     "" => "ecs.n1.small"
  worker_nodes.#:              "" => "<computed>"
  worker_numbers.#:            "" => "1"
  worker_numbers.0:            "" => "2"
alicloud_cs_managed_kubernetes.k8s: Still creating... (10s elapsed)
alicloud_cs_managed_kubernetes.k8s: Still creating... (20s elapsed)

Error: Error applying plan:

1 error(s) occurred:

* alicloud_cs_managed_kubernetes.k8s: 1 error(s) occurred:

* alicloud_cs_managed_kubernetes.k8s: Creating ManagedKubernetes Cluster got an error: &common.Error{ErrorResponse:common.ErrorResponse{Response:common.Response{RequestId:"1155A090-BC2E-4F60-9F05-4068F2134866"}, HostId:"", Code:"ErrKubernetesAuditRoleNotAttach", Message:"service role not attach"}, StatusCode:400}

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.

Steps to Reproduce

  1. terraform apply

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Is there any update here? Should terraform be handling this or should Alicloud provide an api with which this can be handled?