Skip to content

Terraform module which creates classic load balance application architecture on Alibaba Cloud.

License

Notifications You must be signed in to change notification settings

alibabacloud-automation/terraform-alicloud-classic-load-balance

Repository files navigation

Alicloud Classic Load Balance Architecture Terraform Module terraform-alicloud-classic-load-balance

A terraform module to provide classic load balance architecture in alibaba cloud.

image

These types of the module resource are supported:


Usage

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

  1. Adding a module resource to your template, e.g. main.tf

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

    • ALICLOUD_ACCESS_KEY
    • ALICLOUD_SECRET_KEY

Conditional creation

This example supports using existing VPC and VSwitches to create ECS and RDS instances conditionally.

Using existing vpc and vswitches for the cluster.

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"
}

Checking

Open Web browser and input the web_url(<public_ip/welcome.html>), you can get the follow result:

image

Notes

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

Terraform versions

Name Version
terraform >= 0.12.0
alicloud >= 1.56.0

Authors

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

License

Mozilla Public License 2.0. See LICENSE for full details.

Reference

About

Terraform module which creates classic load balance application architecture on Alibaba Cloud.

Resources

License

Stars

Watchers

Forks

Packages