Terraform module which creates EIPs and associate them with other resources on Alibaba Cloud
terraform-alicloud-eip
English | 简体ä¸ć–‡
Terraform module can create EIP instances on Alibaba Cloud and associate them with other resources, like ECS Instance, SLB, Nat Gateway and Network Interface.
These types of resources are supported:
For Terraform 0.13.
module "eip" {
source = "terraform-alicloud-modules/eip/alicloud"
number_of_eips = 5
name = "my-eip"
description = "An EIP associated with ECS instance."
bandwidth = 5
internet_charge_type = "PayByTraffic"
instance_charge_type = "PostPaid"
period = 1
resource_group_id = "eip-12345678"
tags = {
Env = "Private"
Location = "foo"
}
}NOTE: There is no need to specify number_of_eips.
module "eip" {
source = "terraform-alicloud-modules/eip/alicloud"
name = "ecs-eip"
description = "An EIP associated with ECS instance."
bandwidth = 5
internet_charge_type = "PayByTraffic"
instance_charge_type = "PostPaid"
period = 1
resource_group_id = "eip-12345678"
// Associate with ecs and slb
instances = [
{
instance_ids = ["i-g2q7r8g32h", "i-bcuie3h3oixxxx", "i-bceier3"]
instance_type = "EcsInstance"
private_ips = ["172.16.0.1", "172.16.0.2", "172.16.0.3"]
},
{
instance_ids = ["slb-45678", "slb-gg8uer3"]
instance_type = "SlbInstance"
private_ips = []
}
]
}NOTE: There is no need to specify number_of_eips.
// Create several ECS instances
module "ecs" {
source = "alibaba/ecs-instance/alicloud"
version = "~> 2.0"
number_of_instances = 3
name = "my-ecs-cluster"
use_num_suffix = true
# omitted...
}
module "eip" {
source = "terraform-alicloud-modules/eip/alicloud"
name = "ecs-eip"
description = "An EIP associated with ECS instance."
bandwidth = 5
internet_charge_type = "PayByTraffic"
instance_charge_type = "PostPaid"
period = 1
resource_group_id = "eip-12345678"
# The number of instances created by other modules
instances = [
{
instance_ids = module.ecs.this_instance_id
instance_type = "EcsInstance"
private_ips = []
}
]
}This Module provides a variety of templates for creating EIP instances and associate them with other resource instances to meet different usage scenarios, like:
From the version v1.2.0, the module has removed the following provider setting:
provider "alicloud" {
profile = var.profile != "" ? var.profile : null
shared_credentials_file = var.shared_credentials_file != "" ? var.shared_credentials_file : null
region = var.region != "" ? var.region : null
skip_region_validation = var.skip_region_validation
configuration_source = "terraform-alicloud-modules/eip"
}If you still want to use the provider setting to apply this module, you can specify a supported version, like 1.1.0:
module "eip" {
source = "terraform-alicloud-modules/eip/alicloud"
version = "1.1.0"
region = "cn-hangzhou"
profile = "Your-Profile-Name"
create = true
name = "ecs-eip"
description = "An EIP associated with ECS instance."
bandwidth = 5
// ...
}If you want to upgrade the module to 1.2.0 or higher in-place, you can define a provider which same region with previous region:
provider "alicloud" {
region = "cn-hangzhou"
profile = "Your-Profile-Name"
}
module "eip" {
source = "terraform-alicloud-modules/eip/alicloud"
create = true
name = "ecs-eip"
description = "An EIP associated with ECS instance."
bandwidth = 5
// ...
}or specify an alias provider with a defined region to the module using providers:
provider "alicloud" {
region = "cn-hangzhou"
profile = "Your-Profile-Name"
alias = "hz"
}
module "eip" {
source = "terraform-alicloud-modules/eip/alicloud"
providers = {
alicloud = alicloud.hz
}
create = true
name = "ecs-eip"
description = "An EIP associated with ECS instance."
bandwidth = 5
// ...
}and then run terraform init and terraform apply to make the defined provider effect to the existing module state.
More details see How to use provider in the module
| Name | Version |
|---|---|
| terraform | >= 0.13.0 |
| alicloud | >= 1.56.0 |
If you have any problems when using this module, please opening a provider issue and let us know.
Note: There does not recommend to open an issue on this repo.
Created and maintained by Alibaba Cloud Terraform Team([email protected]).
Apache 2 Licensed. See LICENSE for full details.