Skip to content

alibabacloud-automation/terraform-alicloud-disk

Repository files navigation

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:


Usage

You can use this in your terraform template with the following steps.

  1. 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"
    
    }
    
  2. Setting access_key and secret_key values through environment variables:

    • ALICLOUD_ACCESS_KEY
    • ALICLOUD_SECRET_KEY
    • ALICLOUD_REGION

Notes

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

Requirements

Name Version
terraform >= 0.13

Providers

No providers.

Modules

Name Source Version
disk_attachment ./modules/disk_attachment n/a
disks ./modules/disk n/a

Resources

No resources.

Inputs

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)
{
"created_by": "Terraform",
"created_from": "module-terraform-alicloud-disk"
}
no

Outputs

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.

Authors

Created and maintained by Alibaba Cloud Terraform Team(terraform@alibabacloud.com)

Reference

About

Terraform module which creates ECS Disks and attach them to ECS instance on Alibaba Cloud

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5