» alicloud_key_pair_attachment

Provides a key pair attachment resource to bind key pair for several ECS instances.

» Example Usage

Basic Usage

resource "alicloud_key_pair" "key" {
    key_name = "terraform-test-key-pair"
}

resource "alicloud_instance" "instance" {
  instance_name = "test-keypair-${format(var.count_format, count.index+1)}"
  image_id = "ubuntu_140405_64_40G_cloudinit_20161115.vhd"
  instance_type = "ecs.n4.small"
  count = 2
  availability_zone = "${var.availability_zones}"
  ...
}

resource "alicloud_key_pair_attachment" "attach" {
  key_name = "${alicloud_key_pair.key.id}"
  instance_ids = ["${alicloud_instance.instance.*.id}"]
}

» Argument Reference

The following arguments are supported:

  • key_name - (Required, Force new resource) The name of key pair used to bind.
  • instance_ids - (Required, Force new resource) The list of ECS instance's IDs.
  • force - (Required, Force new resource) Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.

» Attributes Reference