A terraform module to provide classic load balance architecture in alibaba cloud.
These types of the module resource are supported:
- VPC
- Subnet
- Load Balancer
- ECS Instance
- Security Group
- RDS Instance
- RDS Account
- RDS Database
- OSS Bucket
You can use this in your terraform template with the following steps.
-
Adding a module resource to your template, e.g. main.tf
module "classic-load-balance" { source = "aliyun/classic-load-balance/alicloud" vpc_name = "my-new-vpc" vswitch_cidrs = ["10.1.2.0/24", "10.1.3.0/24"] system_category = "cloud_ssd" system_size = "100" slb_max_bandwidth = "50" } output "web_url" { value = module.classic-load-balance.web_url }
-
Setting
access_key
andsecret_key
values through environment variables:- ALICLOUD_ACCESS_KEY
- ALICLOUD_SECRET_KEY
This example supports using existing VPC and VSwitches to create ECS and RDS instances conditionally.
You can specify the following user-defined arguments:
- vpc_id: A existing vpc ID
- vswitch_ids: List of IDs for several existing vswitches
Note: At present, not all availability zone supports launching RDS instance. If you want to using existing vswitches, you must ensure the specified vswitches can creating RDS instance.
module "classic-load-balance" {
source = "terraform-alicloud-classic-load-balance"
vpc_id = "vpc-abc12345"
vswitch_cidrs = ["vsw-abc12345", "vsw-abc54321"]
system_category = "cloud_ssd"
system_size = "100"
slb_max_bandwidth = "50"
}
Open Web browser and input the web_url
(<public_ip/welcome.html>), you can get the follow result:
From the version v2.7.0, the module has removed the following provider
setting:
provider "alicloud" {
version = ">=1.56.0"
region = var.region != "" ? var.region : null
configuration_source = "terraform-alicloud-modules/classic-load-balance"
}
If you still want to use the provider
setting to apply this module, you can specify a supported version, like 2.6.1:
module "classic-load-balance" {
source = "aliyun/classic-load-balance/alicloud"
version = "2.6.1"
region = "cn-beijing"
vpc_name = "my-new-vpc"
system_category = "cloud_ssd"
// ...
}
If you want to upgrade the module to 2.7.0 or higher in-place, you can define a provider which same region with previous region:
provider "alicloud" {
region = "cn-beijing"
}
module "classic-load-balance" {
source = "aliyun/classic-load-balance/alicloud"
vpc_name = "my-new-vpc"
system_category = "cloud_ssd"
// ...
}
or specify an alias provider with a defined region to the module using providers
:
provider "alicloud" {
region = "cn-beijing"
alias = "bj"
}
module "classic-load-balance" {
source = "aliyun/classic-load-balance/alicloud"
providers = {
alicloud = alicloud.bj
}
vpc_name = "my-new-vpc"
system_category = "cloud_ssd"
// ...
}
and then run terraform init
and terraform apply
to make the defined provider effect to the existing module state.
More details see How to use provider in the module
Name | Version |
---|---|
terraform | >= 0.12.0 |
alicloud | >= 1.56.0 |
Created and maintained by Alibaba Cloud Terraform Team(terraform@alibabacloud.com)
Mozilla Public License 2.0. See LICENSE for full details.