Manage image sharing permissions. You can share your custom image to other Alibaba Cloud users. The user can use the shared custom image to create ECS instances or replace the system disk of the instance.
data "alicloud_zones" "default" {
available_resource_creation = "Instance"
}
data "alicloud_instance_types" "default" {
instance_type_family = "ecs.sn1ne"
}
data "alicloud_images" "default" {
name_regex = "^ubuntu_[0-9]+_[0-9]+_x64*"
owners = "system"
}
resource "alicloud_vpc" "default" {
vpc_name = "terraform-example"
cidr_block = "172.17.3.0/24"
}
resource "alicloud_vswitch" "default" {
vswitch_name = "terraform-example"
cidr_block = "172.17.3.0/24"
vpc_id = alicloud_vpc.default.id
zone_id = data.alicloud_zones.default.zones.0.id
}
resource "alicloud_security_group" "default" {
name = "terraform-example"
vpc_id = alicloud_vpc.default.id
}
resource "alicloud_instance" "default" {
availability_zone = data.alicloud_zones.default.zones.0.id
instance_name = "terraform-example"
security_groups = [alicloud_security_group.default.id]
vswitch_id = alicloud_vswitch.default.id
instance_type = data.alicloud_instance_types.default.ids[0]
image_id = data.alicloud_images.default.ids[0]
internet_max_bandwidth_out = 10
}
resource "alicloud_image" "default" {
instance_id = alicloud_instance.default.id
image_name = "terraform-example"
description = "terraform-example"
}
variable "account_id" {
default = "123456789"
}
resource "alicloud_image_share_permission" "default" {
image_id = alicloud_image.default.id
account_id = var.account_id
}
The following arguments are supported:
image_id
- (Required, ForceNew) The source image ID.account_id
- (Required, ForceNew) Alibaba Cloud Account ID. It is used to share images.The following attributes are exported:
id
- ID of the image. It formats as <image_id>:<account_id>
image can be imported using the id, e.g.
$ terraform import alicloud_image_share_permission.default m-uf66yg1q:123456789