├── versions.tf
├── examples
├── basic
│ ├── versions.tf
│ ├── variables.tf
│ ├── README.md
│ └── outputs.tf
├── bare-metal
│ ├── versions.tf
│ ├── variables.tf
│ ├── README.md
│ ├── main.tf
│ └── outputs.tf
├── complete
│ ├── versions.tf
│ ├── README.md
│ ├── tfvars
│ │ └── 01-update.tfvars
│ ├── outputs.tf
│ ├── variables.tf
│ └── main.tf
├── disk-attachment
│ ├── versions.tf
│ ├── variables.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── eip-association
│ ├── versions.tf
│ ├── variables.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── x86-architecture
│ ├── big-data
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ ├── README.md
│ │ └── outputs.tf
│ ├── entry-level
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ ├── README.md
│ │ └── outputs.tf
│ ├── local-ssd
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ ├── README.md
│ │ └── outputs.tf
│ ├── compute-optimized
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ ├── README.md
│ │ └── outputs.tf
│ ├── general-purpose
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ ├── README.md
│ │ └── outputs.tf
│ ├── high-clock-speed
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ ├── README.md
│ │ └── outputs.tf
│ └── memory-optimized
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── main.tf
│ │ ├── README.md
│ │ └── outputs.tf
├── super-computing-cluster
│ └── cpu
│ │ ├── versions.tf
│ │ ├── variables.tf
│ │ ├── README.md
│ │ ├── main.tf
│ │ └── outputs.tf
└── heterogeneous-computing
│ ├── compute-optimized-type-with-gpu
│ ├── versions.tf
│ ├── variables.tf
│ ├── README.md
│ ├── main.tf
│ └── outputs.tf
│ ├── (Deprecated)compute-optimized-type-with-fpga
│ ├── versions.tf
│ ├── variables.tf
│ ├── README.md
│ ├── main.tf
│ └── outputs.tf
│ └── visualization-compute-optimized-type-with-gpu
│ ├── versions.tf
│ ├── variables.tf
│ ├── main.tf
│ ├── README.md
│ └── outputs.tf
├── modules
├── bare-metal-cpu
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── bare-metal-gpu
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ ├── main.tf
│ └── variables.tf
├── x86-architecture-big-data
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── x86-architecture-local-ssd
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── compute-optimized-type-with-gpu
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── super-computing-cluster-cpu
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── x86-architecture-entry-level
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── compute-optimized-type-with-fpga
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── x86-architecture-compute-optimized
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── x86-architecture-general-purpose
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── x86-architecture-high-clock-speed
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── x86-architecture-memory-optimized
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
└── visualization-compute-optimized-type-with-gpu
│ ├── versions.tf
│ ├── README.md
│ ├── outputs.tf
│ └── main.tf
├── .gitignore
├── local.tf
├── LICENSE
├── .github
└── workflows
│ ├── release.yml
│ ├── weekly_e2e.yml
│ └── e2e.yml
├── .releaserc.json
├── scripts
├── curl_fc_trigger.go
├── terraform-test.sh
└── e2e_check.go
├── CHANGELOG.md
├── main.tf
└── README-CN.md
/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/basic/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/bare-metal/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/complete/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/disk-attachment/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/eip-association/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/bare-metal-cpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/bare-metal-gpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/big-data/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/x86-architecture-big-data/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/x86-architecture-local-ssd/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/super-computing-cluster/cpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/entry-level/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/local-ssd/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/compute-optimized-type-with-gpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/super-computing-cluster-cpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/x86-architecture-entry-level/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/compute-optimized/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/general-purpose/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/high-clock-speed/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/memory-optimized/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/compute-optimized-type-with-fpga/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/x86-architecture-compute-optimized/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/x86-architecture-general-purpose/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/x86-architecture-high-clock-speed/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/x86-architecture-memory-optimized/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/modules/visualization-compute-optimized-type-with-gpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/compute-optimized-type-with-gpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/(Deprecated)compute-optimized-type-with-fpga/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/visualization-compute-optimized-type-with-gpu/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.13"
3 | }
--------------------------------------------------------------------------------
/examples/basic/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/examples/disk-attachment/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "instances_number" {
8 | description = "The number of instances to be created."
9 | default = 1
10 | type = number
11 | }
--------------------------------------------------------------------------------
/examples/eip-association/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "instances_number" {
8 | description = "The number of instances to be created."
9 | type = number
10 | default = 2
11 | }
--------------------------------------------------------------------------------
/examples/bare-metal/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | description = "The zone where the instance is located."
9 | type = string
10 | default = "cn-hangzhou-i"
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/examples/super-computing-cluster/cpu/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-h"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/big-data/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-i"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/entry-level/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-h"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/local-ssd/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-h"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/compute-optimized/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-h"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/general-purpose/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-j"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/high-clock-speed/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-h"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/memory-optimized/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-h"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled files
2 | *.tfstate
3 | *.tfstate.backup
4 | *.terraform.*
5 |
6 | # Module directory
7 | .terraform/
8 |
9 | # terraform log
10 | *.log
11 |
12 | # auto-generated key pair file
13 | *.pem
14 |
15 | # tools files
16 | .DS_Store
17 | .idea
18 |
19 | # others
20 | *.bak
21 | *.bk
22 | **/.terraform/*
23 | .terraform.lock.hcl
24 | .terraform.tfstate.lock.info
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/compute-optimized-type-with-gpu/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-hangzhou"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-hangzhou-i"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/(Deprecated)compute-optimized-type-with-fpga/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-beijing"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-beijing-g"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/visualization-compute-optimized-type-with-gpu/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | default = "cn-heyuan"
3 | type = string
4 | description = "The region where the instance is located."
5 | }
6 |
7 | variable "zone_id" {
8 | default = "cn-heyuan-a"
9 | type = string
10 | description = "The zone where the instance is located."
11 | }
--------------------------------------------------------------------------------
/local.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | subscription = var.instance_charge_type == "PostPaid" ? {} : var.subscription
3 | name = var.name != "" ? var.name : var.instance_name != "" ? var.instance_name : "TF-Module-ECS-Instance"
4 | system_disk_name = var.system_disk_name != "" ? var.system_disk_name : local.name
5 | security_group_ids = length(var.security_group_ids) > 0 ? var.security_group_ids : var.group_ids
6 | }
--------------------------------------------------------------------------------
/modules/bare-metal-cpu/README.md:
--------------------------------------------------------------------------------
1 | # bare-metal-cpu - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/bare-metal-cpu"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/bare-metal-gpu/README.md:
--------------------------------------------------------------------------------
1 | # bare-metal-gpu - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/bare-metal-gpu"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/x86-architecture-big-data/README.md:
--------------------------------------------------------------------------------
1 | # x86-architecture-big-data - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/x86-architecture-big-data"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/x86-architecture-local-ssd/README.md:
--------------------------------------------------------------------------------
1 | # x86-architecture-local-ssd - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/x86-architecture-local-ssd"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/super-computing-cluster-cpu/README.md:
--------------------------------------------------------------------------------
1 | # super-computing-cluster-cpu - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/super-computing-cluster-cpu"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/x86-architecture-entry-level/README.md:
--------------------------------------------------------------------------------
1 | # x86-architecture-entry-level - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/x86-architecture-entry-level"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/compute-optimized-type-with-gpu/README.md:
--------------------------------------------------------------------------------
1 | # compute-optimized-type-with-gpu - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/compute-optimized-type-with-gpu"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/compute-optimized-type-with-fpga/README.md:
--------------------------------------------------------------------------------
1 | # compute-optimized-type-with-fpga - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/compute-optimized-type-with-fpga"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/x86-architecture-general-purpose/README.md:
--------------------------------------------------------------------------------
1 | # x86-architecture-general-purpose - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/x86-architecture-general-purpose"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/x86-architecture-high-clock-speed/README.md:
--------------------------------------------------------------------------------
1 | # x86-architecture-high-clock-speed - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/x86-architecture-high-clock-speed"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/x86-architecture-memory-optimized/README.md:
--------------------------------------------------------------------------------
1 | # x86-architecture-memory-optimized - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/x86-architecture-memory-optimized"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/x86-architecture-compute-optimized/README.md:
--------------------------------------------------------------------------------
1 | # x86-architecture-compute-optimized - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/x86-architecture-compute-optimized"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/modules/visualization-compute-optimized-type-with-gpu/README.md:
--------------------------------------------------------------------------------
1 | # visualization-compute-optimized-type-with-gpu - Alibaba Cloud ECS-Instance Terraform Module
2 |
3 | ## Usage
4 |
5 | ```hcl
6 | module "bare_metal_cpu_ecs_instance" {
7 | source = "alibaba/ecs-instance/alicloud//modules/visualization-compute-optimized-type-with-gpu"
8 | version = "~> 2.0"
9 |
10 | # omitted...
11 | }
12 |
13 | ```
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/examples/basic/README.md:
--------------------------------------------------------------------------------
1 | # Complete ECS Instance example
2 |
3 | Configuration in this directory creates set of ECS instance resource in various combinations.
4 |
5 | Data sources are used to discover existing instance type.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_vswitch\_id | The ID of the Vswitch |
27 | | this\_security\_group\_ids | The ID of the Security Group |
28 | | this\_private\_ip | The private ip of the ECS instance |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/disk-attachment/README.md:
--------------------------------------------------------------------------------
1 | # Complete ECS Instance example
2 |
3 | Configuration in this directory creates set of ECS instance resource in various combinations.
4 |
5 | Data sources are used to discover existing instance type.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_vswitch\_id | The ID of the Vswitch |
27 | | this\_security\_group\_ids | The ID of the Security Group |
28 | | this\_private\_ip | The private ip of the ECS instance |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/eip-association/README.md:
--------------------------------------------------------------------------------
1 | # Complete ECS Instance example
2 |
3 | Configuration in this directory creates set of ECS instance resource in various combinations.
4 |
5 | Data sources are used to discover existing instance type.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_vswitch\_id | The ID of the Vswitch |
27 | | this\_security\_group\_ids | The ID of the Security Group |
28 | | this\_private\_ip | The private ip of the ECS instance |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/complete/README.md:
--------------------------------------------------------------------------------
1 | # Complete
2 |
3 | Configuration in this directory creates ECS instance(s).
4 |
5 | ## Usage
6 |
7 | To run this example you need to execute:
8 |
9 | ```bash
10 | $ terraform init
11 | $ terraform plan
12 | $ terraform apply
13 | ```
14 |
15 | Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
16 |
17 | This example provides the tf variables file in the folder `tfvars`. If you want to create or update this example,
18 | you can run this example as the following commands:
19 | ```bash
20 | $ terraform plan -var-file=tfvars/01-update.tfvars
21 | $ terraform apply -var-file=tfvars/01-update.tfvars
22 | ```
23 |
24 | Also, you can add more variables files in the folder `tfvars`.
25 |
26 |
27 | ## Requirements
28 |
29 | | Name | Version |
30 | |------|---------|
31 | | [terraform](#requirement\_terraform) | >= 0.13.0 |
32 | | [alicloud](#requirement\_alicloud) | >= 1.56.0 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Terraform Alibaba Cloud Modules
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/x86-architecture/big-data/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 |
26 | # ECS Module
27 | module "ecs_instance" {
28 | source = "../../../modules/x86-architecture-big-data"
29 |
30 | instance_type_family = "ecs.d1ne"
31 | # Also can specify a instance type
32 | # instance_type = "ecs.d1ne.2xlarge"
33 |
34 | vswitch_id = alicloud_vswitch.default.id
35 |
36 | security_group_ids = [alicloud_security_group.default.id]
37 |
38 | associate_public_ip_address = true
39 |
40 | internet_max_bandwidth_out = 10
41 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/entry-level/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 | # ECS Module
26 | module "ecs_instance" {
27 | source = "../../../modules/x86-architecture-entry-level"
28 |
29 | instance_type_family = "ecs.t6"
30 | # Also can specify a instance type
31 | # instance_type = "ecs.t6-c4m1.large"
32 |
33 | vswitch_id = alicloud_vswitch.default.id
34 |
35 | security_group_ids = [alicloud_security_group.default.id]
36 |
37 | associate_public_ip_address = true
38 |
39 | internet_max_bandwidth_out = 10
40 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/local-ssd/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 |
26 | # ECS Module
27 | module "ecs_instance" {
28 | source = "../../../modules/x86-architecture-local-ssd"
29 |
30 | instance_type_family = "ecs.i2g"
31 | # Also can specify a instance type
32 | # instance_type = "ecs.i2g.2xlarge"
33 |
34 | vswitch_id = alicloud_vswitch.default.id
35 |
36 | security_group_ids = [alicloud_security_group.default.id]
37 |
38 | associate_public_ip_address = true
39 |
40 | internet_max_bandwidth_out = 10
41 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/general-purpose/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 | # ECS Module
26 | module "ecs_instance" {
27 | source = "../../../modules/x86-architecture-general-purpose"
28 |
29 | instance_type_family = "ecs.g6"
30 | # Also can specify a instance type
31 | # instance_type = "ecs.g6.large"
32 |
33 | vswitch_id = alicloud_vswitch.default.id
34 |
35 | security_group_ids = [alicloud_security_group.default.id]
36 |
37 | associate_public_ip_address = true
38 |
39 | internet_max_bandwidth_out = 10
40 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/compute-optimized/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 |
26 | # ECS Module
27 | module "ecs_instance" {
28 | source = "../../../modules/x86-architecture-compute-optimized"
29 |
30 | instance_type_family = "ecs.c6"
31 | # Also can specify a instance type
32 | # instance_type = "ecs.c6.large"
33 |
34 | vswitch_id = alicloud_vswitch.default.id
35 |
36 | security_group_ids = [alicloud_security_group.default.id]
37 |
38 | associate_public_ip_address = true
39 |
40 | internet_max_bandwidth_out = 10
41 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/high-clock-speed/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 |
26 | # ECS Module
27 | module "ecs_instance" {
28 | source = "../../../modules/x86-architecture-high-clock-speed"
29 |
30 | instance_type_family = "ecs.hfg6"
31 | # Also can specify a instance type
32 | # instance_type = "ecs.hfg6.large"
33 |
34 | vswitch_id = alicloud_vswitch.default.id
35 |
36 | security_group_ids = [alicloud_security_group.default.id]
37 |
38 | associate_public_ip_address = true
39 |
40 | internet_max_bandwidth_out = 10
41 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/memory-optimized/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 | # ECS Module
26 | module "ecs_instance" {
27 | source = "../../../modules/x86-architecture-memory-optimized"
28 | instance_type_family = "ecs.r6"
29 | # Also can specify a instance type
30 | # instance_type = "ecs.r6.large"
31 |
32 | vswitch_id = alicloud_vswitch.default.id
33 |
34 | security_group_ids = [alicloud_security_group.default.id]
35 |
36 | associate_public_ip_address = true
37 |
38 | internet_max_bandwidth_out = 10
39 | }
--------------------------------------------------------------------------------
/examples/basic/outputs.tf:
--------------------------------------------------------------------------------
1 | # Output the IDs of the ECS instances created
2 | output "this_instance_ids" {
3 | description = "The instance ids."
4 | value = module.ecs.this_instance_id
5 | }
6 |
7 | output "this_instance_names" {
8 | description = "The instance names."
9 | value = module.ecs.this_instance_name
10 | }
11 |
12 | # VSwitch ID
13 | output "this_vswitch_ids" {
14 | description = "The vswitch id in which the instance."
15 | value = module.ecs.this_vswitch_id
16 | }
17 |
18 | # Security Group outputs
19 | output "this_security_group_ids" {
20 | description = "The security group ids in which the instance."
21 | value = module.ecs.this_security_group_ids
22 | }
23 |
24 | output "this_private_ip" {
25 | description = "The private ip of the instance."
26 | value = module.ecs.this_private_ip
27 | }
28 |
29 | output "this_tags" {
30 | description = "The tags for the instance."
31 | value = module.ecs.this_instance_tags
32 | }
33 |
34 | output "credit_specification" {
35 | description = "Credit specification of ECS instance (empty list for not t6 instance types)."
36 | value = module.ecs.this_credit_specification
37 | }
38 |
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/visualization-compute-optimized-type-with-gpu/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 |
26 | # ECS Module
27 | module "ecs_instance" {
28 | source = "../../../modules/visualization-compute-optimized-type-with-gpu"
29 |
30 | instance_type_family = "ecs.vgn7i-vws"
31 | # Also can specify a instance type
32 | # instance_type = "ecs.vgn7i-vws-m24.7xlarge"
33 |
34 | system_disk_category = "cloud_essd"
35 |
36 | vswitch_id = alicloud_vswitch.default.id
37 |
38 | security_group_ids = [alicloud_security_group.default.id]
39 |
40 | associate_public_ip_address = true
41 |
42 | internet_max_bandwidth_out = 10
43 | }
--------------------------------------------------------------------------------
/examples/bare-metal/README.md:
--------------------------------------------------------------------------------
1 | # Bare-Metal ECS Instance example
2 |
3 | Configuration in this directory creates set of bare-metal ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/bare-metal/main.tf:
--------------------------------------------------------------------------------
1 |
2 | provider "alicloud" {
3 | region = var.region
4 | }
5 |
6 | #############################################################
7 | # create VPC, vswitch and security group
8 | #############################################################
9 |
10 | resource "alicloud_vpc" "default" {
11 | vpc_name = "tf_module"
12 | cidr_block = "172.16.0.0/12"
13 | }
14 |
15 | resource "alicloud_vswitch" "default" {
16 | vpc_id = alicloud_vpc.default.id
17 | cidr_block = "172.16.0.0/21"
18 | zone_id = var.zone_id
19 | }
20 |
21 | resource "alicloud_security_group" "default" {
22 | security_group_name = "default"
23 | vpc_id = alicloud_vpc.default.id
24 | }
25 |
26 | # ECS Module
27 | module "bare_metal_cpu_ecs_instance" {
28 | source = "../../modules/bare-metal-cpu"
29 |
30 | instance_type_family = "ecs.ebmc6"
31 | # Also can specify a instance type
32 | # instance_type = "ecs.ebmhfg5.2xlarge"
33 |
34 | vswitch_id = alicloud_vswitch.default.id
35 |
36 | security_group_ids = [alicloud_security_group.default.id]
37 |
38 | associate_public_ip_address = true
39 |
40 | internet_max_bandwidth_out = 10
41 |
42 | # Post-paid instances are out of stock, pre-paid instances must be specified for this type of instance
43 | # instance_charge_type = "PrePaid"
44 | }
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | release:
8 | name: Release
9 | runs-on: ubuntu-latest
10 | if: github.repository_owner == 'alibabacloud-automation' && github.actor == 'shanye997'
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v4
14 | with:
15 | persist-credentials: false
16 | fetch-depth: 0
17 |
18 | - name: Release
19 | id: semantic
20 | uses: cycjimmy/semantic-release-action@v4
21 | with:
22 | semantic_version: 23.0.2
23 | extra_plugins: |
24 | @semantic-release/changelog@6.0.3
25 | @semantic-release/git@10.0.1
26 | conventional-changelog-conventionalcommits@7.0.2
27 | env:
28 | GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
29 |
30 | - name: Trigger Metadata Upload
31 | if: steps.semantic.outputs.new_release_published == 'true'
32 | run: |
33 | url="${{ secrets.FC_UPLOAD_META_ENDPOINT }}/?from=git&syncModuleMeta=true&moduleName=${{ github.event.repository.name }}&moduleVersion=${{ steps.semantic.outputs.new_release_version }}"
34 | echo "Uploading metadata to $url"
35 | curl -H "X-Fc-Invocation-Type:Async" \
36 | -s "$url"
37 |
--------------------------------------------------------------------------------
/examples/x86-architecture/big-data/README.md:
--------------------------------------------------------------------------------
1 | # x86-Architecture-Big-Data ECS Instance example
2 |
3 | Configuration in this directory creates set of x86-architecture-big-data ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/x86-architecture/local-ssd/README.md:
--------------------------------------------------------------------------------
1 | # x86-Architecture-Local-Ssd ECS Instance example
2 |
3 | Configuration in this directory creates set of x86-architecture-local-ssd ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/super-computing-cluster/cpu/README.md:
--------------------------------------------------------------------------------
1 | # Super-Computing-Cluster-Cpu ECS Instance example
2 |
3 | Configuration in this directory creates set of super-computing-cluster-cpu ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/x86-architecture/entry-level/README.md:
--------------------------------------------------------------------------------
1 | # x86-Architecture-Entry-Level ECS Instance example
2 |
3 | Configuration in this directory creates set of x86-architecture-entry-level ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.releaserc.json:
--------------------------------------------------------------------------------
1 | {
2 | "branches": [
3 | "main",
4 | "master"
5 | ],
6 | "plugins": [
7 | [
8 | "@semantic-release/commit-analyzer",
9 | {
10 | "preset": "conventionalcommits",
11 | "releaseRules": [
12 | {
13 | "type": "docs",
14 | "release": "patch"
15 | }
16 | ]
17 | }
18 | ],
19 | [
20 | "@semantic-release/release-notes-generator",
21 | {
22 | "preset": "conventionalcommits"
23 | }
24 | ],
25 | [
26 | "@semantic-release/github",
27 | {
28 | "successComment": false,
29 | "labels": false,
30 | "releasedLabels": false
31 | }
32 | ],
33 | [
34 | "@semantic-release/changelog",
35 | {
36 | "changelogFile": "CHANGELOG.md"
37 | }
38 | ],
39 | [
40 | "@semantic-release/git",
41 | {
42 | "assets": [
43 | "CHANGELOG.md"
44 | ],
45 | "message": "chore(release): CHANGELOG v${nextRelease.version}"
46 | }
47 | ]
48 | ]
49 | }
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/compute-optimized-type-with-gpu/README.md:
--------------------------------------------------------------------------------
1 | # Compute-Optimized-Type-With-Gpu ECS Instance example
2 |
3 | Configuration in this directory creates set of bare-metal ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/compute-optimized-type-with-gpu/main.tf:
--------------------------------------------------------------------------------
1 | provider "alicloud" {
2 | region = var.region
3 | }
4 |
5 | #############################################################
6 | # create VPC, vswitch and security group
7 | #############################################################
8 |
9 | resource "alicloud_vpc" "default" {
10 | vpc_name = "tf_module"
11 | cidr_block = "172.16.0.0/12"
12 | }
13 |
14 | resource "alicloud_vswitch" "default" {
15 | vpc_id = alicloud_vpc.default.id
16 | cidr_block = "172.16.0.0/21"
17 | zone_id = var.zone_id
18 | }
19 |
20 | resource "alicloud_security_group" "default" {
21 | security_group_name = "default"
22 | vpc_id = alicloud_vpc.default.id
23 | }
24 |
25 |
26 | # ECS Module
27 | module "ecs_instance" {
28 | source = "../../../modules/compute-optimized-type-with-gpu"
29 |
30 | instance_type_family = "ecs.gn6v"
31 | # Also can specify a instance type
32 | # instance_type = "ecs.gn6v-c8g1.2xlarge"
33 |
34 | vswitch_id = alicloud_vswitch.default.id
35 |
36 | security_group_ids = [alicloud_security_group.default.id]
37 |
38 | associate_public_ip_address = true
39 |
40 | internet_max_bandwidth_out = 10
41 |
42 | # Post-paid instances are out of stock, pre-paid instances must be specified for this type of instance
43 | # instance_charge_type = "PrePaid"
44 | }
--------------------------------------------------------------------------------
/examples/x86-architecture/general-purpose/README.md:
--------------------------------------------------------------------------------
1 | # x86-Architecture-General-Purpose ECS Instance example
2 |
3 | Configuration in this directory creates set of x86-architecture-general-purpose ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/x86-architecture/compute-optimized/README.md:
--------------------------------------------------------------------------------
1 | # x86-Architecture-Compute-Optimized ECS Instance example
2 |
3 | Configuration in this directory creates set of x86-architecture-compute-optimized ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/x86-architecture/high-clock-speed/README.md:
--------------------------------------------------------------------------------
1 | # x86-Architecture-High-Clock-Speed ECS Instance example
2 |
3 | Configuration in this directory creates set of x86-architecture-high-clock-speed ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/x86-architecture/memory-optimized/README.md:
--------------------------------------------------------------------------------
1 | # x86-Architecture-Memory-Optimized ECS Instance example
2 |
3 | Configuration in this directory creates set of x86-architecture-memory-optimized ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/(Deprecated)compute-optimized-type-with-fpga/README.md:
--------------------------------------------------------------------------------
1 | # Compute-Optimized-Type-With-Fpga ECS Instance example
2 |
3 | Configuration in this directory creates set of bare-metal ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/(Deprecated)compute-optimized-type-with-fpga/main.tf:
--------------------------------------------------------------------------------
1 |
2 | provider "alicloud" {
3 | region = var.region
4 | }
5 |
6 | #############################################################
7 | # create VPC, vswitch and security group
8 | #############################################################
9 |
10 | resource "alicloud_vpc" "default" {
11 | vpc_name = "tf_module"
12 | cidr_block = "172.16.0.0/12"
13 | }
14 |
15 | resource "alicloud_vswitch" "default" {
16 | vpc_id = alicloud_vpc.default.id
17 | cidr_block = "172.16.0.0/21"
18 | zone_id = var.zone_id
19 | }
20 |
21 | resource "alicloud_security_group" "default" {
22 | security_group_name = "default"
23 | vpc_id = alicloud_vpc.default.id
24 | }
25 |
26 |
27 | # ECS Module
28 | module "ecs_instance" {
29 | source = "../../../modules/compute-optimized-type-with-fpga"
30 |
31 | instance_type_family = "ecs.f3"
32 | # Also can specify a instance type
33 | # instance_type = "ecs.f3-c8f1.2xlarge"
34 |
35 | vswitch_id = alicloud_vswitch.default.id
36 |
37 | security_group_ids = [alicloud_security_group.default.id]
38 |
39 | associate_public_ip_address = true
40 |
41 | internet_max_bandwidth_out = 10
42 |
43 | # Post-paid instances are out of stock, pre-paid instances must be specified for this type of instance
44 | # instance_charge_type = "PrePaid"
45 | }
--------------------------------------------------------------------------------
/examples/disk-attachment/outputs.tf:
--------------------------------------------------------------------------------
1 | # Output the IDs of the ECS instances created
2 | output "this_disk_attachment_disk_id" {
3 | description = "The disk ID"
4 | value = alicloud_disk_attachment.this_ecs[*].disk_id
5 | }
6 |
7 | output "this_disk_attachment_instance_id" {
8 | description = "The instance ID"
9 | value = alicloud_disk_attachment.this_ecs[*].instance_id
10 | }
11 |
12 | output "this_instance_ids" {
13 | description = "The instance ID"
14 | value = module.ecs.this_instance_id
15 | }
16 |
17 | output "this_instance_names" {
18 | description = "The instance name"
19 | value = module.ecs.this_instance_name
20 | }
21 |
22 | # VSwitch ID
23 | output "this_vswitch_ids" {
24 | description = "The vswitch ID"
25 | value = module.ecs.this_vswitch_id
26 | }
27 |
28 | # Security Group outputs
29 | output "this_security_group_ids" {
30 | description = "The security group ID"
31 | value = module.ecs.this_security_group_ids
32 | }
33 |
34 | output "this_private_ip" {
35 | description = "The private IP address of the ECS instance"
36 | value = module.ecs.this_private_ip
37 | }
38 |
39 | output "this_public_ip" {
40 | description = "The public IP address of the ECS instance"
41 | value = module.ecs.this_public_ip
42 | }
43 |
44 | output "this_tags" {
45 | description = "The tags of the ECS instance"
46 | value = module.ecs.this_instance_tags
47 | }
--------------------------------------------------------------------------------
/examples/heterogeneous-computing/visualization-compute-optimized-type-with-gpu/README.md:
--------------------------------------------------------------------------------
1 | # Visualization-Compute-Optimized-Type-With-Gpu ECS Instance example
2 |
3 | Configuration in this directory creates set of visualization-compute-optimized-type-with-gpu ECS instance resources.
4 |
5 | Data sources are used to discover existing vpc, vswitch and security groups.
6 |
7 | ## Usage
8 |
9 | To run this example you need to execute:
10 |
11 | ```bash
12 | $ terraform init
13 | $ terraform plan
14 | $ terraform apply
15 | ```
16 |
17 | Note that this example will create resources which cost money. Run `terraform destroy` when you don't need these resources.
18 |
19 |
20 | ## Outputs
21 |
22 | | Name | Description |
23 | |------|-------------|
24 | | this\_instance\_id | The ID of the ECS instance |
25 | | this\_instance\_name | The name of the ECS instance |
26 | | this\_instance\_type | The ECS instance type|
27 | | this\_image\_id | The ECS instance image id|
28 | | this\_vswitch\_id | The ID of the Vswitch |
29 | | this\_security\_group\_ids | The ID of the Security Group |
30 | | this\_private\_ip | The private ip of the ECS instance |
31 | | this\_public\_ip | The public ip of the ECS instance |
32 | | this_instance_tags | The instance tags|
33 | | this_availability_zone | The available zone id in which instance launched |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/eip-association/outputs.tf:
--------------------------------------------------------------------------------
1 | # Output the IDs of the ECS instances created
2 | output "this_instance_id" {
3 | description = "The instance id of the ECS instance."
4 | value = module.ecs.this_instance_id
5 | }
6 |
7 | output "this_instance_name" {
8 | description = "The instance name of the ECS instance."
9 | value = module.ecs.this_instance_name
10 | }
11 |
12 | # VSwitch ID
13 | output "this_vswitch_id" {
14 | description = "The vswitch id of the ECS instance."
15 | value = module.ecs.this_vswitch_id
16 | }
17 |
18 | # Security Group outputs
19 | output "this_security_group_ids" {
20 | description = "The security group ids of the ECS instance."
21 | value = module.ecs.this_security_group_ids
22 | }
23 |
24 | output "this_private_ip" {
25 | description = "The instance private ip"
26 | value = module.ecs.this_private_ip
27 | }
28 |
29 | output "this_public_ip" {
30 | description = "The instance public ip"
31 | value = module.ecs.this_public_ip
32 | }
33 |
34 | output "this_eip" {
35 | description = "The eip address"
36 | value = alicloud_eip.this[*].ip_address
37 | }
38 |
39 | output "this_eip_association_instance_id" {
40 | description = "The instance id"
41 | value = alicloud_eip_association.this_ecs[*].instance_id
42 | }
43 | output "this_eip_association_eip_id" {
44 | description = "The eip id"
45 | value = alicloud_eip_association.this_ecs[*].allocation_id
46 | }
--------------------------------------------------------------------------------
/examples/complete/tfvars/01-update.tfvars:
--------------------------------------------------------------------------------
1 | #alicloud_kms_key
2 | pending_window_in_days = 7
3 |
4 | #alicloud_ram_role
5 | document = < 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 |
27 | number_of_instances = var.number_of_instances
28 |
29 | # Specify a ecs image
30 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
31 | image_ids = var.image_ids
32 |
33 | # Specify instance type
34 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
35 |
36 | # Specify network setting
37 | security_group_ids = var.security_group_ids
38 | vswitch_id = var.vswitch_id
39 | vswitch_ids = var.vswitch_ids
40 | private_ip = var.private_ip
41 | private_ips = var.private_ips
42 |
43 |
44 | # Specify instance basic attributes
45 | name = "TF-bare-metal-gpu"
46 | use_num_suffix = true
47 | tags = var.tags
48 | resource_group_id = var.resource_group_id
49 | user_data = var.user_data
50 |
51 | # Specify instance charge attributes
52 | internet_charge_type = var.internet_charge_type
53 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
54 | associate_public_ip_address = var.associate_public_ip_address
55 | instance_charge_type = var.instance_charge_type
56 | subscription = var.subscription
57 | dry_run = var.dry_run
58 |
59 |
60 | # Specify instance disk setting
61 | system_disk_category = var.system_disk_category
62 | system_disk_size = var.system_disk_size
63 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
64 | data_disks = var.data_disks
65 | volume_tags = var.volume_tags
66 |
67 | # Specify instance access setting
68 | password = var.password
69 | kms_encrypted_password = var.kms_encrypted_password
70 | kms_encryption_context = var.kms_encryption_context
71 | key_name = var.key_name
72 |
73 | # Attach ecs instance to a RAM role
74 | role_name = var.role_name
75 |
76 | # Security Setting
77 | deletion_protection = var.deletion_protection
78 | force_delete = var.force_delete
79 | security_enhancement_strategy = var.security_enhancement_strategy
80 |
81 | # Set the useless parameters
82 | credit_specification = null
83 | spot_strategy = "NoSpot"
84 | }
85 |
--------------------------------------------------------------------------------
/modules/super-computing-cluster-cpu/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.scch5", "ecs.scch5s", "ecs.sccg5"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.scch5s"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-super-computing-cluster-cpu"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 | spot_strategy = "NoSpot"
83 |
84 | hpc_cluster_id = var.hpc_cluster_id
85 | }
86 |
--------------------------------------------------------------------------------
/modules/compute-optimized-type-with-fpga/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.f3"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.f1"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-compute-optimized-type-with-fpga"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/x86-architecture-big-data/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.d1ne", "ecs.d1"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.d1ne"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 |
27 | number_of_instances = var.number_of_instances
28 |
29 | # Specify a ecs image
30 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
31 | image_ids = var.image_ids
32 |
33 | # Specify instance type
34 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
35 |
36 | # Specify network setting
37 | security_group_ids = var.security_group_ids
38 | vswitch_id = var.vswitch_id
39 | vswitch_ids = var.vswitch_ids
40 | private_ip = var.private_ip
41 | private_ips = var.private_ips
42 |
43 |
44 | # Specify instance basic attributes
45 | instance_name = "TF-x86-architecture-big-data"
46 | use_num_suffix = true
47 | tags = var.tags
48 | resource_group_id = var.resource_group_id
49 | user_data = var.user_data
50 |
51 | # Specify instance charge attributes
52 | internet_charge_type = var.internet_charge_type
53 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
54 | associate_public_ip_address = var.associate_public_ip_address
55 | instance_charge_type = var.instance_charge_type
56 | subscription = var.subscription
57 | dry_run = var.dry_run
58 |
59 |
60 | # Specify instance disk setting
61 | system_disk_category = var.system_disk_category
62 | system_disk_size = var.system_disk_size
63 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
64 | data_disks = var.data_disks
65 | volume_tags = var.volume_tags
66 |
67 | # Specify instance access setting
68 | password = var.password
69 | kms_encrypted_password = var.kms_encrypted_password
70 | kms_encryption_context = var.kms_encryption_context
71 | key_name = var.key_name
72 |
73 | # Attach ecs instance to a RAM role
74 | role_name = var.role_name
75 |
76 | # Security Setting
77 | deletion_protection = var.deletion_protection
78 | force_delete = var.force_delete
79 | security_enhancement_strategy = var.security_enhancement_strategy
80 |
81 | # Set the useless parameters
82 | credit_specification = null
83 |
84 | # Set the spot strategy
85 | spot_strategy = var.spot_strategy
86 | spot_price_limit = var.spot_price_limit
87 | }
88 |
--------------------------------------------------------------------------------
/modules/x86-architecture-general-purpose/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.g6", "ecs.g5"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.g6"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-x86-architecture-general-purpose"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/x86-architecture-local-ssd/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.i2g", "ecs.i2", "ecs.i1"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.i2g"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-x86-architecture-local-ssd"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/x86-architecture-compute-optimized/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.c6", "ecs.c5", "ecs.ic5"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.c6"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | instance_name = "TF-x86-architecture-compute-optimized"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/x86-architecture-entry-level/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.t6", "ecs.t5"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.t6"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-x86-architecture-entry-level"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the credit specification
81 | credit_specification = var.credit_specification
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/x86-architecture-memory-optimized/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.r6", "ecs.r5", "ecs.re4"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.r6"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-x86-architecture-memory-optimized"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/x86-architecture-high-clock-speed/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.hfg6", "ecs.hfg5", "ecs.hfc5"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.hfg6"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-x86-architecture-high-clock-speed"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/visualization-compute-optimized-type-with-gpu/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.vgn7i-vws", "ecs.vgn6i"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.ga1"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | instance_name = "TF-visualization-compute-optimized-type-with-gpu"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/compute-optimized-type-with-gpu/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.gn7e", "ecs.gn7i", "ecs.gn7s", "ecs.gn7", "ecs.gn6v", "ecs.gn5", "ecs.gn6i"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.gn6v"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-bare-metal-cpu"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 |
83 | # Set the spot strategy
84 | spot_strategy = var.spot_strategy
85 | spot_price_limit = var.spot_price_limit
86 | }
87 |
--------------------------------------------------------------------------------
/modules/bare-metal-cpu/main.tf:
--------------------------------------------------------------------------------
1 | locals {
2 | # This type of instance contains the following instance type families
3 | instance_type_families = ["ecs.ebmc6", "ecs.ebmg6", "ecs.ebmr6", "ecs.ebmhfc6", "ecs.ebmhfg6", "ecs.ebmhfr6", "ecs.ebmc5s", "ecs.ebmg5s", "ecs.ebmr5s", "ecs.ebmhfg5", "ecs.ebmc4", "ecs.ebmg5", "ecs.scch5", "ecs.sccg5"]
4 | }
5 |
6 |
7 | data "alicloud_instance_types" "this" {
8 | instance_type_family = var.instance_type_family != "" && contains(local.instance_type_families, var.instance_type_family) ? var.instance_type_family : "ecs.ebmc6"
9 | instance_charge_type = var.instance_charge_type
10 | cpu_core_count = var.cpu_core_count > 0 ? var.cpu_core_count : null
11 | memory_size = var.memory_size > 0 ? var.memory_size : null
12 | availability_zone = length(var.vswitch_ids) > 0 || var.vswitch_id != "" ? data.alicloud_vswitches.this.vswitches[0].zone_id : null
13 | }
14 |
15 | data "alicloud_vswitches" "this" {
16 | ids = length(var.vswitch_ids) > 0 ? var.vswitch_ids : [var.vswitch_id]
17 | }
18 | data "alicloud_images" "this" {
19 | most_recent = var.most_recent
20 | owners = var.owners
21 | name_regex = var.image_name_regex
22 | }
23 | module "ecs-instance" {
24 | source = "../../"
25 |
26 | number_of_instances = var.number_of_instances
27 |
28 | # Specify a ecs image
29 | image_id = var.image_id != "" ? var.image_id : data.alicloud_images.this.ids[0]
30 | image_ids = var.image_ids
31 |
32 | # Specify instance type
33 | instance_type = var.instance_type != "" ? var.instance_type : data.alicloud_instance_types.this.ids[0]
34 |
35 | # Specify network setting
36 | security_group_ids = var.security_group_ids
37 | vswitch_id = var.vswitch_id
38 | vswitch_ids = var.vswitch_ids
39 | private_ip = var.private_ip
40 | private_ips = var.private_ips
41 |
42 |
43 | # Specify instance basic attributes
44 | name = "TF-bare-metal-cpu"
45 | use_num_suffix = true
46 | tags = var.tags
47 | resource_group_id = var.resource_group_id
48 | user_data = var.user_data
49 |
50 | # Specify instance charge attributes
51 | internet_charge_type = var.internet_charge_type
52 | internet_max_bandwidth_out = var.internet_max_bandwidth_out
53 | associate_public_ip_address = var.associate_public_ip_address
54 | instance_charge_type = var.instance_charge_type
55 | subscription = var.subscription
56 | dry_run = var.dry_run
57 |
58 |
59 | # Specify instance disk setting
60 | system_disk_category = var.system_disk_category
61 | system_disk_size = var.system_disk_size
62 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
63 | data_disks = var.data_disks
64 | volume_tags = var.volume_tags
65 |
66 | # Specify instance access setting
67 | password = var.password
68 | kms_encrypted_password = var.kms_encrypted_password
69 | kms_encryption_context = var.kms_encryption_context
70 | key_name = var.key_name
71 |
72 | # Attach ecs instance to a RAM role
73 | role_name = var.role_name
74 |
75 | # Security Setting
76 | deletion_protection = var.deletion_protection
77 | force_delete = var.force_delete
78 | security_enhancement_strategy = var.security_enhancement_strategy
79 |
80 | # Set the useless parameters
81 | credit_specification = null
82 | spot_strategy = "NoSpot"
83 | }
84 |
--------------------------------------------------------------------------------
/scripts/terraform-test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | version=""
4 | updateFolder="examples/complete"
5 | tfvars="tfvars/01-update.tfvars"
6 | f=${1}
7 | success=true
8 | # echo $f
9 | exitCode=0
10 | terraformVersionFile="tfversion.md"
11 |
12 | if [ $# -ge 2 ]; then
13 | echo "" > $terraformVersionFile
14 | fi
15 |
16 | echo ""
17 | echo "====> Terraform testing in" $f
18 | # init
19 | terraform -chdir=$f init -upgrade >/dev/null
20 | if [[ $? -ne 0 ]]; then
21 | success=false
22 | exitCode=1
23 | echo -e "\033[31m[ERROR]\033[0m: running terraform init failed."
24 | else
25 | # plan
26 | echo ""
27 | echo -e "----> Plan Testing\n"
28 | terraform -chdir=$f plan >/dev/null
29 | if [[ $? -ne 0 ]]; then
30 | success=false
31 | exitCode=2
32 | echo -e "\033[31m[ERROR]\033[0m: running terraform plan failed."
33 | else
34 | echo -e "\033[32m - plan check: success\033[0m"
35 | # apply
36 | echo ""
37 | echo -e "----> Apply Testing\n"
38 | terraform -chdir=$f apply -auto-approve >/dev/null
39 | if [[ $? -ne 0 ]]; then
40 | success=false
41 | exitCode=3
42 | echo -e "\033[31m[ERROR]\033[0m: running terraform apply failed."
43 | else
44 | echo -e "\033[32m - apply check: success\033[0m"
45 | # update & check diff
46 | if [ $f == $updateFolder ] && [ -f "${updateFolder}/${tfvars}" ];then
47 | # if example is complete and has tfvars folder
48 | echo ""
49 | echo -e " ----> Apply Update Testing\n"
50 | terraform -chdir=$f apply -auto-approve -var-file=$tfvars >/dev/null
51 | if [[ $? -ne 0 ]]; then
52 | success=false
53 | exitCode=3
54 | echo -e "\033[31m[ERROR]\033[0m: running terraform apply update failed."
55 | else
56 | echo -e "\033[32m - apply update check: success\033[0m"
57 | echo ""
58 | echo -e " ----> Apply Diff Checking\n"
59 | terraform -chdir=$f plan -var-file=$tfvars -detailed-exitcode
60 | if [[ $? -ne 0 ]]; then
61 | success=false
62 | if [[ $exitCode -eq 0 ]]; then
63 | exitCode=4
64 | fi
65 | echo -e "\033[31m[ERROR]\033[0m: running terraform plan for checking diff failed."
66 | else
67 | echo -e "\033[32m - apply diff check: success\033[0m"
68 | fi
69 | fi
70 | else
71 | # if example is no need to update
72 | echo ""
73 | echo -e " ----> Apply Diff Checking\n"
74 | terraform -chdir=$f plan -detailed-exitcode
75 | if [[ $? -ne 0 ]]; then
76 | success=false
77 | exitCode=4
78 | echo -e "\033[31m[ERROR]\033[0m: running terraform plan for checking diff failed."
79 | else
80 | echo -e "\033[32m - apply diff check: success\033[0m"
81 | fi
82 | fi
83 | fi
84 | # destroy
85 | echo ""
86 | echo -e " ----> Destroying\n"
87 | terraform -chdir=$f destroy -auto-approve >/dev/null
88 | if [[ $? -ne 0 ]]; then
89 | success=false
90 | if [[ $exitCode -eq 0 ]]; then
91 | exitCode=5
92 | fi
93 | echo -e "\033[31m[ERROR]\033[0m: running terraform destroy failed."
94 | else
95 | echo -e "\033[32m - destroy: success\033[0m"
96 | fi
97 | fi
98 | fi
99 |
100 | version=$(terraform -chdir=$f version)
101 | row=`echo -e "$version" | sed -n '/^$/='`
102 | if [ -n "$row" ]; then
103 | version=`echo -e "$version" | sed -n "1,${row}p"`
104 | fi
105 |
106 | if [[ $exitCode -ne 1 ]]; then
107 | rm -rf $f/.terraform
108 | rm -rf $f/.terraform.lock.hcl
109 | fi
110 |
111 | if [ $# -ge 2 ]; then
112 | echo -e "### Versions\n" >> $terraformVersionFile
113 | echo -e "${version}" >> $terraformVersionFile
114 | fi
115 |
116 | exit $exitCode
--------------------------------------------------------------------------------
/scripts/e2e_check.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "io"
6 | "log"
7 | "net/http"
8 | "os"
9 | "strings"
10 | "time"
11 | )
12 |
13 | var urlPrefix = "https://terraform-fc-test-for-example-module.oss-ap-southeast-1.aliyuncs.com"
14 |
15 | func main() {
16 | ossObjectPath := strings.TrimSpace(os.Args[1])
17 | log.Println("run log path:", ossObjectPath)
18 | runLogFileName := "terraform.run.log"
19 | runResultFileName := "terraform.run.result.log"
20 | runLogUrl := urlPrefix + "/" + ossObjectPath + "/" + runLogFileName
21 | runResultUrl := urlPrefix + "/" + ossObjectPath + "/" + runResultFileName
22 | lastLineNum := 0
23 | deadline := time.Now().Add(time.Duration(24) * time.Hour)
24 | finish := false
25 | exitCode := 0
26 | log.Println(runLogUrl)
27 | errResultMessage := ""
28 | for !time.Now().After(deadline) {
29 | runLogResponse, err := http.Get(runLogUrl)
30 | if err != nil || runLogResponse.StatusCode != 200 {
31 | log.Println("waiting for job running...")
32 | time.Sleep(5 * time.Second)
33 | continue
34 | }
35 | defer runLogResponse.Body.Close()
36 |
37 | s, er := io.ReadAll(runLogResponse.Body)
38 | if er != nil && fmt.Sprint(er) != "EOF" {
39 | log.Println("[ERROR] reading run log response failed:", err)
40 | }
41 | lineNum := len(s)
42 | if runLogResponse.StatusCode == 200 {
43 | if lineNum > lastLineNum {
44 | fmt.Printf("%s", s[lastLineNum:lineNum])
45 | lastLineNum = lineNum
46 | }
47 | }
48 | if finish {
49 | log.Println("run log path:", ossObjectPath)
50 | log.Println("run log url:", runLogUrl)
51 | if strings.Contains(ossObjectPath, "weekly") {
52 | updateTestRecord(ossObjectPath)
53 | exitCode = 0
54 | }
55 | if errResultMessage != "" {
56 | log.Println("[ERROR] run result:", errResultMessage)
57 | }
58 | os.Exit(exitCode)
59 | }
60 | runResultResponse, err := http.Get(runResultUrl)
61 | if err != nil || runResultResponse.StatusCode != 200 {
62 | time.Sleep(5 * time.Second)
63 | continue
64 | }
65 | defer runResultResponse.Body.Close()
66 | runResultContent := make([]byte, 100000)
67 | _, err = runResultResponse.Body.Read(runResultContent)
68 | if err != nil && fmt.Sprint(err) != "EOF" {
69 | log.Println("[ERROR] reading run result response failed:", err)
70 | }
71 | finish = true
72 | if !strings.HasPrefix(string(runResultContent), "PASS") {
73 | errResultMessage = string(runResultContent)
74 | exitCode = 1
75 | }
76 | }
77 | log.Println("[ERROR] Timeout: waiting for job finished timeout after 24 hours.")
78 | }
79 |
80 | func updateTestRecord(ossObjectPath string) {
81 | currentTestRecordFileName := "TestRecord.md"
82 | currentTestRecordFileUrl := urlPrefix + "/" + ossObjectPath + "/" + currentTestRecordFileName
83 | response, err := http.Get(currentTestRecordFileUrl)
84 | if err != nil {
85 | log.Println("[ERROR] failed to get test record from oss")
86 | return
87 | }
88 | defer response.Body.Close()
89 | data, _ := io.ReadAll(response.Body)
90 | if response.StatusCode != 200 || len(data) == 0 {
91 | return
92 | }
93 | currentTestRecord := string(data) + "\n"
94 |
95 | testRecordFileName := "TestRecord.md"
96 | var testRecordFile *os.File
97 | oldTestRecord := ""
98 | if _, err := os.Stat(testRecordFileName); os.IsNotExist(err) {
99 | testRecordFile, err = os.Create(testRecordFileName)
100 | if err != nil {
101 | log.Println("[ERROR] failed to create test record file")
102 | }
103 | } else {
104 | data, err := os.ReadFile(testRecordFileName)
105 | if err != nil {
106 | log.Println("[ERROR] failed to read test record file")
107 | return
108 | }
109 | oldTestRecord = string(data)
110 |
111 | testRecordFile, err = os.OpenFile(testRecordFileName, os.O_TRUNC|os.O_RDWR, 0666)
112 | if err != nil {
113 | log.Println("[ERROR] failed to open test record file")
114 | }
115 | }
116 | defer testRecordFile.Close()
117 |
118 | currentTestRecord += oldTestRecord
119 | testRecordFile.WriteString(currentTestRecord)
120 | }
121 |
--------------------------------------------------------------------------------
/.github/workflows/e2e.yml:
--------------------------------------------------------------------------------
1 | name: E2E Test Check
2 | on:
3 | pull_request:
4 | branches:
5 | - master
6 | - main
7 | types: [ 'opened', 'synchronize' ]
8 |
9 | jobs:
10 | commitlint:
11 | runs-on: ubuntu-latest
12 | steps:
13 | - uses: ahmadnassri/action-commit-lint@v2
14 |
15 | changes-files:
16 | runs-on: ubuntu-latest
17 | outputs:
18 | changed_files_list: ${{ steps.changed-files.outputs.all_changed_files }}
19 | steps:
20 | - uses: actions/checkout@v4
21 | - name: Get changed files
22 | id: changed-files
23 | uses: tj-actions/changed-files@v34
24 | with:
25 | separator: ","
26 |
27 | terraform-fmt:
28 | runs-on: ubuntu-latest
29 | needs: changes-files
30 | if: contains(needs.changes-files.outputs.changed_files_list, '.tf')
31 | steps:
32 | - uses: actions/checkout@v4
33 | - uses: hashicorp/setup-terraform@v3
34 | - name: Terraform fmt
35 | id: fmt
36 | run: terraform fmt -check -recursive
37 |
38 | terraform-validate:
39 | runs-on: ubuntu-latest
40 | needs: changes-files
41 | if: contains(needs.changes-files.outputs.changed_files_list, '.tf')
42 | steps:
43 | - name: checkout
44 | uses: actions/checkout@v3
45 | - uses: hashicorp/setup-terraform@v3
46 | - name: validate-check
47 | run: |
48 | exp="examples"
49 | output_file="combined_output.txt"
50 | if [[ -d "$exp" ]]; then
51 | find $exp -type d -print -mindepth 1 -maxdepth 1 >> $output_file
52 | fi
53 |
54 | exitCode=0
55 | while IFS= read -r line
56 | do
57 | echo "===> Terraform validate checking in $line"
58 | terraform -chdir=$line init -upgrade
59 | terraform -chdir=$line validate
60 | if [[ $? -ne 0 ]]; then
61 | echo -e "\033[31m[ERROR]\033[0m: Some codes contain errors, and please running terraform validate command before pushing."
62 | exitCode=1
63 | fi
64 | done < $output_file
65 | rm $output_file
66 | exit $exitCode
67 |
68 | tflint:
69 | runs-on: ubuntu-latest
70 | needs: changes-files
71 | if: contains(needs.changes-files.outputs.changed_files_list, '.tf')
72 | steps:
73 | - name: checkout
74 | uses: actions/checkout@v3
75 |
76 | - uses: actions/checkout@v4
77 | name: Checkout source code
78 |
79 | - uses: actions/cache@v4
80 | name: Cache plugin dir
81 | with:
82 | path: ~/.tflint.d/plugins
83 | key: ${{ matrix.os }}-tflint-${{ hashFiles('.tflint.hcl') }}
84 |
85 | - uses: terraform-linters/setup-tflint@v4
86 | name: Setup TFLint
87 | with:
88 | tflint_version: v0.52.0
89 |
90 | - name: Init TFLint
91 | run: tflint --init
92 | env:
93 | GITHUB_TOKEN: ${{ github.token }}
94 |
95 | - name: tflint
96 | run: |
97 | tflint --recursive \
98 | --enable-rule=terraform_comment_syntax \
99 | --enable-rule=terraform_deprecated_index \
100 | --enable-rule=terraform_deprecated_interpolation \
101 | --enable-rule=terraform_deprecated_lookup \
102 | --enable-rule=terraform_documented_outputs \
103 | --enable-rule=terraform_documented_variables \
104 | --enable-rule=terraform_typed_variables \
105 | --enable-rule=terraform_unused_declarations \
106 | --enable-rule=terraform_required_version \
107 | --enable-rule=terraform_standard_module_structure \
108 | --disable-rule=terraform_required_providers
109 | if [[ $? -ne 0 ]]; then
110 | exit_code=1
111 | fi
112 |
113 | e2e-check:
114 | needs: [commitlint, terraform-fmt, terraform-validate, tflint]
115 | runs-on: ubuntu-latest
116 | name: 'e2e check'
117 | steps:
118 | - name: checkout
119 | uses: actions/checkout@v3
120 | - name: set id
121 | id: set-job-id
122 | uses: ayachensiyuan/get-action-job-id@v1.6
123 | env:
124 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125 | with:
126 | job-name: 'e2e check'
127 | - name: Get pull request info
128 | run: |
129 | echo "repo name is" ${{github.event.pull_request.head.repo.full_name}}
130 | echo "branch is" ${{github.event.pull_request.head.ref}}
131 | echo "The current job id is ${{ steps.set-job-id.outputs.jobId }}"
132 | - name: e2e test
133 | run: |
134 | objectPath="github-action/${{github.repository}}/e2e/Action-${{github.run_number}}-${{github.run_id}}-${{ steps.set-job-id.outputs.jobId }}"
135 | go run scripts/curl_fc_trigger.go ${{github.event.pull_request.head.ref}} ${{github.event.pull_request.head.repo.full_name}} ${objectPath}
136 | go run scripts/e2e_check.go ${objectPath}
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [2.12.1](https://github.com/alibabacloud-automation/terraform-alicloud-ecs-instance/compare/v2.12.0...v2.12.1) (2025-11-27)
2 |
3 | ## 2.13.0 (unreleased)
4 | ## 2.12.0 (August 8, 2024)
5 |
6 | - Module/alicloud_instance: supported the system_disk_name, system_disk_description, system_disk_performance_level attribute [GH-62](https://github.com/alibabacloud-automation/terraform-alicloud-ecs-instance/pull/62)
7 |
8 |
9 | ## 2.11.0 (May 7, 2024)
10 |
11 | IMPROVEMENTS:
12 |
13 | - resource/alicloud_instance: add hpc_cluster_id; improve examples [GH-58](https://github.com/alibabacloud-automation/terraform-alicloud-ecs-instance/pull/58)
14 |
15 | ## 2.10.0 (July 7, 2022)
16 |
17 | IMPROVEMENTS:
18 |
19 | - Add support for new parameter `operator_type` and `status`. [GH-57](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/57)
20 |
21 | ## 2.9.0 (May 12, 2022)
22 |
23 | IMPROVEMENTS:
24 |
25 | - Improves the module examples/complete [GH-55](https://github.com/alibabacloud-automation/terraform-alicloud-ecs-instance/pull/55)
26 |
27 |
28 | ## 2.8.0 (December 23, 2021)
29 |
30 | IMPROVEMENTS:
31 |
32 | - Removes the provider setting and improves the Readme [GH-53](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/53)
33 | - Modified author contact information [GH-51](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/51)
34 |
35 | ## 2.7.0 (May 18, 2020)
36 |
37 | IMPROVEMENTS:
38 |
39 | - image_ids has wrong type [GH-47](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/47)
40 | - supported auto snapshot policy fields [GH-46](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/46)
41 |
42 | ## 2.6.0 (February 29, 2020)
43 |
44 | BUG FIXES:
45 |
46 | - fix subscription checking and add variable description [GH-45](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/45)
47 |
48 | ## 2.5.1 (February 24, 2020)
49 |
50 | IMPROVEMENTS:
51 |
52 | - add profile for readme and examples [GH-44](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/44)
53 |
54 | ## 2.5.0 (February 20, 2020)
55 |
56 | BUG FIXES:
57 |
58 | - remove internet_max_bandwidth_in default to fix diff bug [GH-43](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/43)
59 |
60 | ## 2.4.0 (February 14, 2020)
61 |
62 | IMPROVEMENTS:
63 |
64 | - improve readme [GH-42](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/42)
65 | - support multi images and remove provider version [GH-41](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/41)
66 |
67 | ## 2.3.0 (January 17, 2020)
68 |
69 | BUG FIXES:
70 |
71 | - fix(ecs): fixed bug where host name must be set. [GH-39](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/39)
72 |
73 | ## 2.2.1 (January 7, 2020)
74 |
75 | BUG FIXES:
76 |
77 | - fix host_name default value when use_num_suffix is false [GH-38](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/38)
78 |
79 | ## 2.2.0 (January 7, 2020)
80 |
81 | IMPROVEMENTS:
82 |
83 | - use_num_suffix applied to host_name [GH-37](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/37)
84 | - change host_name and instance_name suffix using three numbers [GH-36](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/36)
85 |
86 | ## 2.1.0 (January 6, 2020)
87 |
88 | IMPROVEMENTS:
89 |
90 | - compatible the deprecated parameter `group_ids` [GH-35](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/35)
91 | - host_name supports suffix [GH-35](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/35)
92 | - change image regex [GH-35](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/35)
93 |
94 | ## 2.0.0 (December 28, 2019)
95 |
96 | - **Added:** `examples` [GH-24](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/24)
97 | - **Added:** `examples` [GH-28](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/28)
98 |
99 | IMPROVEMENTS:
100 |
101 | - deprecated `instance_name` and add `name` instead [GH-34](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/34)
102 | - improve readme and basic examples [GH-33](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/33)
103 | - improve(ecs): updated README.md and added chinese version. [GH-32](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/32)
104 | - improve(ecs): added submodules and examples. [GH-31](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/31)
105 | - add modules and improve bare-metal [GH-30](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/30)
106 | - improve(ecs): modified the ecs module outputs. [GH-23](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/23)
107 | - improve(ecs): added provider settings. [GH-22](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/pull/22)
108 |
--------------------------------------------------------------------------------
/examples/complete/variables.tf:
--------------------------------------------------------------------------------
1 | #alicloud_kms_key
2 | variable "pending_window_in_days" {
3 | description = "Duration in days after which the key is deleted after destruction of the resource, must be between 7 and 30 days. Defaults to 30 days."
4 | type = string
5 | default = "30"
6 | }
7 |
8 | #alicloud_ram_role
9 | variable "document" {
10 | description = "Authorization strategy of the RAM role."
11 | type = string
12 | default = < 0 ? var.private_ips[count.index] : var.private_ip
9 | instance_name = var.number_of_instances > 1 || var.use_num_suffix ? format("%s%03d", local.name, count.index + 1) : local.name
10 | host_name = var.host_name == "" ? "" : var.number_of_instances > 1 || var.use_num_suffix ? format("%s%03d", var.host_name, count.index + 1) : var.host_name
11 | resource_group_id = var.resource_group_id
12 | description = var.description
13 | internet_charge_type = var.internet_charge_type
14 | password = var.password
15 | kms_encrypted_password = var.kms_encrypted_password
16 | kms_encryption_context = var.kms_encryption_context
17 | system_disk_category = var.system_disk_category
18 | system_disk_size = var.system_disk_size
19 | system_disk_name = local.system_disk_name
20 | system_disk_description = var.system_disk_description
21 | system_disk_performance_level = var.system_disk_performance_level
22 | system_disk_auto_snapshot_policy_id = var.system_disk_auto_snapshot_policy_id
23 | system_disk_encrypted = var.system_disk_encrypted
24 | system_disk_kms_key_id = var.system_disk_kms_key_id
25 | system_disk_encrypt_algorithm = var.system_disk_encrypt_algorithm
26 | system_disk_storage_cluster_id = var.system_disk_storage_cluster_id
27 | dynamic "data_disks" {
28 | for_each = var.data_disks
29 | content {
30 | name = lookup(data_disks.value, "name", var.disk_name)
31 | size = lookup(data_disks.value, "size", var.disk_size)
32 | category = lookup(data_disks.value, "category", var.disk_category)
33 | encrypted = lookup(data_disks.value, "encrypted", null)
34 | snapshot_id = lookup(data_disks.value, "snapshot_id", null)
35 | delete_with_instance = lookup(data_disks.value, "delete_with_instance", null)
36 | description = lookup(data_disks.value, "description", null)
37 | auto_snapshot_policy_id = lookup(data_disks.value, "auto_snapshot_policy_id", null)
38 | kms_key_id = lookup(data_disks.value, "kms_key_id", null)
39 | performance_level = lookup(data_disks.value, "performance_level", null)
40 | device = lookup(data_disks.value, "device", null)
41 | }
42 | }
43 | internet_max_bandwidth_out = var.associate_public_ip_address ? var.internet_max_bandwidth_out : 0
44 | instance_charge_type = var.instance_charge_type
45 | period = lookup(local.subscription, "period", 1)
46 | period_unit = lookup(local.subscription, "period_unit", "Month")
47 | renewal_status = lookup(local.subscription, "renewal_status", null)
48 | auto_renew_period = lookup(local.subscription, "auto_renew_period", null)
49 | include_data_disks = lookup(local.subscription, "include_data_disks", null)
50 | dry_run = var.dry_run
51 | user_data = var.user_data
52 | role_name = var.role_name
53 | key_name = var.key_name
54 | deletion_protection = var.deletion_protection
55 | force_delete = var.force_delete
56 | security_enhancement_strategy = var.security_enhancement_strategy
57 | credit_specification = var.credit_specification != "" ? var.credit_specification : null
58 | spot_strategy = var.spot_strategy
59 | spot_price_limit = var.spot_price_limit
60 | operator_type = var.operator_type
61 | status = var.status
62 | hpc_cluster_id = var.hpc_cluster_id
63 | auto_release_time = var.auto_release_time
64 | dynamic "network_interfaces" {
65 | for_each = length(var.network_interface_ids) > 0 ? (length(var.network_interface_ids) > count.index ? (length(element(var.network_interface_ids, count.index)) > 0 ? [1] : []) : []) : []
66 | content {
67 | network_interface_id = element(var.network_interface_ids, count.index)
68 | }
69 | }
70 | secondary_private_ips = var.secondary_private_ips
71 | secondary_private_ip_address_count = var.secondary_private_ip_address_count
72 | deployment_set_id = var.deployment_set_id
73 | stopped_mode = var.stopped_mode
74 | dynamic "maintenance_time" {
75 | for_each = var.maintenance_time
76 | content {
77 | start_time = lookup(data_disks.value, "start_time", null)
78 | end_time = lookup(data_disks.value, "end_time", null)
79 | }
80 |
81 | }
82 | maintenance_action = var.maintenance_action
83 | maintenance_notify = var.maintenance_notify
84 | spot_duration = var.spot_duration
85 | http_tokens = var.http_tokens
86 | http_endpoint = var.http_endpoint
87 | http_put_response_hop_limit = var.http_put_response_hop_limit
88 | ipv6_addresses = var.ipv6_addresses
89 | ipv6_address_count = var.ipv6_address_count
90 | dedicated_host_id = var.dedicated_host_id
91 | launch_template_name = var.launch_template_name
92 | launch_template_id = var.launch_template_id
93 | launch_template_version = var.launch_template_version
94 | tags = merge(
95 | {
96 | Name = var.number_of_instances > 1 || var.use_num_suffix ? format("%s%03d", local.name, count.index + 1) : local.name
97 | },
98 | var.tags,
99 | )
100 | volume_tags = merge(
101 | {
102 | Name = var.number_of_instances > 1 || var.use_num_suffix ? format("%s%03d", local.name, count.index + 1) : local.name
103 | },
104 | var.volume_tags,
105 | )
106 | }
107 |
--------------------------------------------------------------------------------
/README-CN.md:
--------------------------------------------------------------------------------
1 | terraform-alicloud-ecs-instance
2 | =====================================================================
3 |
4 | 本 Module 用于在阿里云的 VPC 下创建一个[云服务器ECS实例(ECS Instance)](https://www.alibabacloud.com/help/zh/doc-detail/25374.htm).
5 |
6 | 本 Module 支持创建以下资源:
7 |
8 | * [云服务器ECS实例(ECS Instance)](https://www.terraform.io/docs/providers/alicloud/r/instance.html)
9 |
10 | ## 用法
11 |
12 |
17 |
18 | ```hcl
19 | data "alicloud_images" "ubuntu" {
20 | most_recent = true
21 | name_regex = "^ubuntu_18.*64"
22 | }
23 |
24 | module "ecs_cluster" {
25 | source = "alibaba/ecs-instance/alicloud"
26 |
27 | number_of_instances = 5
28 |
29 | name = "my-ecs-cluster"
30 | use_num_suffix = true
31 | image_id = data.alicloud_images.ubuntu.ids.0
32 | instance_type = "ecs.sn1ne.large"
33 | vswitch_id = "vsw-fhuqie"
34 | security_group_ids = ["sg-12345678"]
35 | associate_public_ip_address = true
36 | internet_max_bandwidth_out = 10
37 |
38 | key_name = "for-ecs-cluster"
39 |
40 | system_disk_category = "cloud_ssd"
41 | system_disk_size = 50
42 |
43 | tags = {
44 | Created = "Terraform"
45 | Environment = "dev"
46 | }
47 | }
48 | ```
49 |
50 | ## 示例
51 |
52 | * [ECS 实例完整创建示例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/basic)
53 | * [ECS 实例与磁盘绑定示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/disk-attachment)
54 | * [多台 ECS 实例与多个EIP绑定](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/eip-association)
55 | * [弹性裸金属服务器(神龙)实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/bare-metal)
56 | * [异构计算 FPGA 计算型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/heterogeneous-computing/compute-optimized-type-with-fpga)
57 | * [异构计算 GPU 计算型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/heterogeneous-computing/compute-optimized-type-with-gpu)
58 | * [异构计算 GPU 虚拟化型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/heterogeneous-computing/visualization-compute-optimized-type-with-gpu)
59 | * [超级计算集群 CPU 型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/super-computing-cluster/cpu)
60 | * [x86计算大数据型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/x86-architecture/big-data)
61 | * [x86计算优化计算型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/x86-architecture/compute-optimized)
62 | * [x86计算入门级(共享)型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/x86-architecture/entry-level)
63 | * [x86计算通用型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/x86-architecture/general-purpose)
64 | * [x86计算高主频型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/x86-architecture/high-clock-speed)
65 | * [x86计算本地 SSD 型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/x86-architecture/local-ssd)
66 | * [x86计算内存型实例创建示例](https://github.com/terraform-alicloud-modules/terraform-alicloud-ecs-instance/tree/master/examples/x86-architecture/memory-optimized)
67 |
68 | ## 注意事项
69 | 本Module从版本v2.8.0开始已经移除掉如下的 provider 的显式设置:
70 |
71 | ```hcl
72 | provider "alicloud" {
73 | profile = var.profile != "" ? var.profile : null
74 | shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
75 | region = var.region != "" ? var.region : null
76 | skip_region_validation = var.skip_region_validation
77 | configuration_source = "terraform-alicloud-modules/ecs-instance"
78 | }
79 | ```
80 |
81 | 如果你依然想在Module中使用这个 provider 配置,你可以在调用Module的时候,指定一个特定的版本,比如 2.7.0:
82 |
83 | ```hcl
84 | module "ecs_cluster" {
85 | source = "alibaba/ecs-instance/alicloud"
86 | version = "2.7.0"
87 | region = "cn-beijing"
88 | profile = "Your-Profile-Name"
89 | number_of_instances = 5
90 | name = "my-ecs-cluster"
91 | // ...
92 | }
93 | ```
94 |
95 | 如果你想对正在使用中的Module升级到 2.8.0 或者更高的版本,那么你可以在模板中显式定义一个相同Region的provider:
96 | ```hcl
97 | provider "alicloud" {
98 | region = "cn-beijing"
99 | profile = "Your-Profile-Name"
100 | }
101 | module "ecs_cluster" {
102 | source = "alibaba/ecs-instance/alicloud"
103 | number_of_instances = 5
104 | name = "my-ecs-cluster"
105 | // ...
106 | }
107 | ```
108 | 或者,如果你是多Region部署,你可以利用 `alias` 定义多个 provider,并在Module中显式指定这个provider:
109 |
110 | ```hcl
111 | provider "alicloud" {
112 | region = "cn-beijing"
113 | profile = "Your-Profile-Name"
114 | alias = "bj"
115 | }
116 | module "ecs_cluster" {
117 | source = "alibaba/ecs-instance/alicloud"
118 | providers = {
119 | alicloud = alicloud.bj
120 | }
121 | number_of_instances = 5
122 | name = "my-ecs-cluster"
123 | // ...
124 | }
125 | ```
126 |
127 | 定义完provider之后,运行命令 `terraform init` 和 `terraform apply` 来让这个provider生效即可。
128 |
129 | 更多provider的使用细节,请移步[How to use provider in the module](https://www.terraform.io/docs/language/modules/develop/providers.html#passing-providers-explicitly)
130 |
131 | ## Terraform 版本
132 |
133 | | Name | Version |
134 | |------|---------|
135 | | [terraform](#requirement\_terraform) | >= 0.13.0 |
136 | | [alicloud](#requirement\_alicloud) | >= 1.56.0 |
137 |
138 | 提交问题
139 | ------
140 | 如果在使用该 Terraform Module 的过程中有任何问题,可以直接创建一个 [Provider Issue](https://github.com/terraform-providers/terraform-provider-alicloud/issues/new),我们将根据问题描述提供解决方案。
141 |
142 | **注意:** 不建议在该 Module 仓库中直接提交 Issue。
143 |
144 | 作者
145 | -------
146 | Created and maintained by Alibaba Cloud Terraform Team(terraform@alibabacloud.com)
147 |
148 | 许可
149 | ----
150 | Apache 2 Licensed. See LICENSE for full details.
151 |
152 | 参考
153 | ---------
154 | * [Terraform-Provider-Alicloud Github](https://github.com/terraform-providers/terraform-provider-alicloud)
155 | * [Terraform-Provider-Alicloud Release](https://releases.hashicorp.com/terraform-provider-alicloud/)
156 | * [Terraform-Provider-Alicloud Docs](https://www.terraform.io/docs/providers/alicloud/index.html)
--------------------------------------------------------------------------------
/modules/bare-metal-gpu/variables.tf:
--------------------------------------------------------------------------------
1 | variable "most_recent" {
2 | description = "If more than one result are returned, select the most recent one."
3 | type = bool
4 | default = true
5 | }
6 |
7 | variable "owners" {
8 | description = "Filter results by a specific image owner. Valid items are 'system', 'self', 'others', 'marketplace'."
9 | type = string
10 | default = "system"
11 | }
12 |
13 | variable "image_name_regex" {
14 | description = "A regex string to filter resulting images by name. "
15 | type = string
16 | default = "^ubuntu_18.*64"
17 | }
18 |
19 | # Ecs instance variables
20 | variable "number_of_instances" {
21 | description = "The number of instances to be created."
22 | type = number
23 | default = 1
24 | }
25 |
26 | variable "image_id" {
27 | description = "The image id used to launch one or more ecs instances."
28 | type = string
29 | default = ""
30 | }
31 |
32 | variable "image_ids" {
33 | description = "A list of ecs image IDs to launch one or more ecs instances."
34 | type = list(string)
35 | default = []
36 | }
37 |
38 | variable "instance_type_family" {
39 | description = "The instance type family used to retrieve bare metal CPU instance type. Valid values: [\"ecs.ebmgn6e\", \"ecs.ebmgn6v\", \"ecs.ebmgn6i\", \"ecs.sccgn6ne\", \"ecs.sccgn6\"]."
40 | type = string
41 | default = "ecs.ebmgn6e"
42 | }
43 |
44 | variable "instance_type" {
45 | description = "The instance type used to launch one or more ecs instances."
46 | type = string
47 | default = ""
48 | }
49 |
50 | variable "cpu_core_count" {
51 | description = "core count used to retrieve instance types"
52 | type = number
53 | default = 0
54 | }
55 |
56 | variable "memory_size" {
57 | description = "Memory size used to retrieve instance types."
58 | type = number
59 | default = 0
60 | }
61 |
62 | variable "security_group_ids" {
63 | description = "A list of security group ids to associate with."
64 | type = list(string)
65 | default = []
66 | }
67 |
68 | variable "resource_group_id" {
69 | description = "The Id of resource group which the instance belongs."
70 | type = string
71 | default = ""
72 | }
73 |
74 | variable "internet_charge_type" {
75 | description = "The internet charge type of instance. Choices are 'PayByTraffic' and 'PayByBandwidth'."
76 | type = string
77 | default = "PayByTraffic"
78 | }
79 |
80 | variable "password" {
81 | description = "The password of instance."
82 | type = string
83 | default = ""
84 | }
85 |
86 | variable "kms_encrypted_password" {
87 | description = "An KMS encrypts password used to an instance. It is conflicted with 'password'."
88 | type = string
89 | default = ""
90 | }
91 |
92 | variable "kms_encryption_context" {
93 | description = "An KMS encryption context used to decrypt 'kms_encrypted_password' before creating or updating an instance with 'kms_encrypted_password'"
94 | type = map(string)
95 | default = {}
96 | }
97 |
98 | variable "system_disk_category" {
99 | description = "The system disk category used to launch one or more ecs instances."
100 | type = string
101 | default = "cloud_efficiency"
102 | }
103 |
104 | variable "system_disk_size" {
105 | description = "The system disk size used to launch one or more ecs instances."
106 | type = number
107 | default = 40
108 | }
109 |
110 | variable "system_disk_auto_snapshot_policy_id" {
111 | description = "The ID of the automatic snapshot policy applied to the system disk."
112 | type = string
113 | default = ""
114 | }
115 |
116 |
117 | variable "data_disks" {
118 | description = "Additional data disks to attach to the scaled ECS instance."
119 | type = list(map(string))
120 | default = []
121 | }
122 |
123 | variable "vswitch_id" {
124 | description = "The virtual switch ID to launch in VPC."
125 | type = string
126 | default = ""
127 | }
128 |
129 | variable "vswitch_ids" {
130 | description = "A list of virtual switch IDs to launch in."
131 | type = list(string)
132 | default = []
133 | }
134 |
135 | variable "private_ip" {
136 | description = "Configure Instance private IP address"
137 | type = string
138 | default = ""
139 | }
140 |
141 | variable "private_ips" {
142 | description = "A list to configure Instance private IP address"
143 | type = list(string)
144 | default = []
145 | }
146 |
147 | variable "internet_max_bandwidth_out" {
148 | description = "The maximum internet out bandwidth of instance."
149 | type = number
150 | default = 0
151 | }
152 |
153 | variable "associate_public_ip_address" {
154 | description = "Whether to associate a public ip address with an instance in a VPC."
155 | type = bool
156 | default = false
157 | }
158 |
159 | variable "instance_charge_type" {
160 | description = "The charge type of instance. Choices are 'PostPaid' and 'PrePaid'."
161 | type = string
162 | default = "PostPaid"
163 | }
164 |
165 | variable "dry_run" {
166 | description = "Whether to pre-detection. When it is true, only pre-detection and not actually modify the payment type operation. Default to false."
167 | type = bool
168 | default = false
169 | }
170 |
171 | variable "user_data" {
172 | description = "User data to pass to instance on boot"
173 | type = string
174 | default = ""
175 | }
176 |
177 | variable "role_name" {
178 | description = "Instance RAM role name. The name is provided and maintained by RAM. You can use 'alicloud_ram_role' to create a new one."
179 | type = string
180 | default = ""
181 | }
182 |
183 | variable "key_name" {
184 | description = "The name of SSH key pair that can login ECS instance successfully without password. If it is specified, the password would be invalid."
185 | type = string
186 | default = ""
187 | }
188 |
189 | variable "deletion_protection" {
190 | description = "Whether enable the deletion protection or not. 'true': Enable deletion protection. 'false': Disable deletion protection."
191 | type = bool
192 | default = false
193 | }
194 |
195 | variable "force_delete" {
196 | description = "If it is true, the 'PrePaid' instance will be change to 'PostPaid' and then deleted forcibly. However, because of changing instance charge type has CPU core count quota limitation, so strongly recommand that 'Don't modify instance charge type frequentlly in one month'."
197 | type = bool
198 | default = false
199 | }
200 |
201 | variable "security_enhancement_strategy" {
202 | description = "The security enhancement strategy."
203 | type = string
204 | default = "Active"
205 | }
206 |
207 | variable "subscription" {
208 | description = "A mapping of fields for Prepaid ECS instances created. "
209 | type = map(string)
210 | default = {
211 | period = 1
212 | period_unit = "Month"
213 | renewal_status = "Normal"
214 | auto_renew_period = 1
215 | include_data_disks = true
216 | }
217 | }
218 |
219 | variable "tags" {
220 | description = "A mapping of tags to assign to the resource."
221 | type = map(string)
222 | default = {
223 | Created = "Terraform"
224 | Source = "alibaba/ecs-instance/alicloud//modules/bare-metal-gpu"
225 | }
226 | }
227 |
228 | variable "volume_tags" {
229 | description = "A mapping of tags to assign to the devices created by the instance at launch time."
230 | type = map(string)
231 | default = {}
232 | }
--------------------------------------------------------------------------------