Alicloud ECS Disk Terraform Module On Alibaba Cloud terraform-alicloud-disk
Terraform module which creates several ECS disks and attach them to one specified ECS instance on Alibaba Cloud.
These types of resources are supported:
You can use this in your terraform template with the following steps.
-
Adding a module resource to your template, e.g. main.tf
module "disks" { source = "terraform-alicloud-modules/disk/alicloud" disk_count = 2 name = "disk-exapmle" category = "cloud_ssd" size = 40 tags = { Owner = "user" Environment = "dev" } attach_disk = true instance_id = "i-ce3nf3cf" }
-
Setting
access_key
andsecret_key
values through environment variables:- ALICLOUD_ACCESS_KEY
- ALICLOUD_SECRET_KEY
- ALICLOUD_REGION
From the version v1.5.0, the module has removed the following provider
setting:
provider "alicloud" {
version = ">=1.56.0"
region = var.region != "" ? var.region : null
configuration_source = "terraform-alicloud-modules/disk"
}
If you still want to use the provider
setting to apply this module, you can specify a supported version, like 1.4.0:
module "disks" {
source = "terraform-alicloud-modules/disk/alicloud"
version = "1.4.0"
region = "cn-beijing"
disk_count = 2
name = "disk-exapmle"
// ...
}
If you want to upgrade the module to 1.5.0 or higher in-place, you can define a provider which same region with previous region:
provider "alicloud" {
region = "cn-beijing"
}
module "disks" {
source = "terraform-alicloud-modules/disk/alicloud"
disk_count = 2
name = "disk-exapmle"
// ...
}
or specify an alias provider with a defined region to the module using providers
:
provider "alicloud" {
region = "cn-beijing"
alias = "bj"
}
module "disks" {
source = "terraform-alicloud-modules/disk/alicloud"
providers = {
alicloud = alicloud.bj
}
disk_count = 2
name = "disk-exapmle"
// ...
}
and then run terraform init
and terraform apply
to make the defined provider effect to the existing module state.
More details see How to use provider in the module
Name | Version |
---|---|
terraform | >= 0.13 |
No providers.
Name | Source | Version |
---|---|---|
disk_attachment | ./modules/disk_attachment | n/a |
disks | ./modules/disk | n/a |
No resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
attach_disk | Whether to attach disks to one instance. | bool |
false |
no |
availability_zone | The available zone to launch ecs disks. Default from data source alicloud_zones . |
string |
"" |
no |
category | The data disk category used to launch one or more data disks. | string |
"cloud_efficiency" |
no |
disk_count | Number of disks to launch. | number |
1 |
no |
disk_ids | A list ECS disks ID. | list(string) |
[] |
no |
encrypted | Whether to encrypt the disks. | bool |
false |
no |
instance_id | The ID of ECS instance. | string |
"" |
no |
name | Name used on all disks as prefix. Like TF_ECS_Disk-1, TF_ECS_Disk-2. | string |
"" |
no |
size | The data disk size used to launch one or more data disks. | string |
"40" |
no |
tags | Used to mark specified ecs data disks. Name will be merged into tags automactially. | map(string) |
{ |
no |
Name | Description |
---|---|
this_availability_zone | The zone ID of the ECS disks belongs to. |
this_category | Category of the disk. |
this_disk_count | Whether to encrypt the disks. |
this_disk_ids | List of disks ID. |
this_name | Name of the ECS disk. |
this_size | The data disk size used to launch one or more data disks. |
this_tags | Used to mark specified ecs data disks. |
Created and maintained by Alibaba Cloud Terraform Team(terraform@alibabacloud.com)