Skip to content

Commit c117932

Browse files
committed
Module: add outputs.tf; example/complete: improve the examples
1 parent 1093cb2 commit c117932

File tree

5 files changed

+24
-36
lines changed

5 files changed

+24
-36
lines changed

examples/complete/main.tf

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,34 @@ data "alicloud_images" "default" {
66
}
77

88
data "alicloud_instance_types" "default" {
9-
availability_zone = data.alicloud_zones.default.zones.0.id
9+
availability_zone = data.alicloud_zones.default.zones[0].id
1010
}
1111

1212
module "vpc" {
13-
source = "alibaba/vpc/alicloud"
13+
source = "alibaba/vpc/alicloud"
14+
version = "~>1.11.0"
15+
1416
create = true
1517
vpc_cidr = "172.16.0.0/16"
1618
vswitch_cidrs = ["172.16.0.0/21"]
17-
availability_zones = [data.alicloud_zones.default.zones.0.id]
19+
availability_zones = [data.alicloud_zones.default.zones[0].id]
1820
}
1921

2022
module "security_group" {
21-
source = "alibaba/security-group/alicloud"
23+
source = "alibaba/security-group/alicloud"
24+
version = "~>2.4.0"
25+
2226
vpc_id = module.vpc.this_vpc_id
2327
}
2428

2529
module "ecs-instance" {
26-
source = "alibaba/ecs-instance/alicloud"
30+
source = "alibaba/ecs-instance/alicloud"
31+
version = "~>2.12.0"
2732

2833
number_of_instances = 1
2934

30-
instance_type = data.alicloud_instance_types.default.instance_types.0.id
31-
image_id = data.alicloud_images.default.images.0.id
35+
instance_type = data.alicloud_instance_types.default.instance_types[0].id
36+
image_id = data.alicloud_images.default.images[0].id
3237
vswitch_ids = [module.vpc.this_vswitch_ids[0]]
3338
security_group_ids = [module.security_group.this_security_group_id]
3439
associate_public_ip_address = false
@@ -47,9 +52,9 @@ resource "alicloud_nat_gateway" "this" {
4752
}
4853

4954
module "eip" {
50-
source = "terraform-alicloud-modules/eip/alicloud"
55+
source = "terraform-alicloud-modules/eip/alicloud"
56+
version = "~>2.1.0"
5157

52-
create = true
5358
number_of_eips = 1
5459
bandwidth = var.eip_bandwidth
5560
internet_charge_type = "PayByTraffic"
@@ -75,4 +80,4 @@ module "complete" {
7580
internal_ip = module.ecs-instance.this_private_ip[0]
7681
entries = var.entries
7782

78-
}
83+
}

examples/complete/versions.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 0.13"
3+
}

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
locals {
2-
dnat_table_id = var.dnat_table_id != "" ? var.dnat_table_id : var.nat_gateway_id != "" ? concat(data.alicloud_nat_gateways.this.gateways.*.dnat_table_id, [""])[0] : ""
2+
dnat_table_id = var.dnat_table_id != "" ? var.dnat_table_id : var.nat_gateway_id != "" ? concat(data.alicloud_nat_gateways.this.gateways[*].dnat_table_id, [""])[0] : ""
33
}
44

55
data "alicloud_nat_gateways" "this" {
@@ -15,6 +15,6 @@ resource "alicloud_forward_entry" "this" {
1515
external_ip = lookup(var.entries[count.index], "external_ip", var.external_ip)
1616
external_port = lookup(var.entries[count.index], "external_port", "any")
1717
internal_ip = lookup(var.entries[count.index], "internal_ip", var.internal_ip)
18-
// Default to external_port
18+
# Default to external_port
1919
internal_port = lookup(var.entries[count.index], "internal_port", lookup(var.entries[count.index], "external_port", "any"))
2020
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "this_forward_entry_id" {
2+
description = "The ID of the forward entrys"
3+
value = alicloud_forward_entry.this[*].id
4+
}

variables.tf

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
1-
#################
2-
# Provider
3-
#################
4-
variable "region" {
5-
description = "(Deprecated from version 1.1.0) The region used to launch this module resources."
6-
type = string
7-
default = ""
8-
}
9-
10-
variable "profile" {
11-
description = "(Deprecated from version 1.1.0) The profile name as set in the shared credentials file. If not set, it will be sourced from the ALICLOUD_PROFILE environment variable."
12-
type = string
13-
default = ""
14-
}
15-
variable "shared_credentials_file" {
16-
description = "(Deprecated from version 1.1.0) This is the path to the shared credentials file. If this is not set and a profile is specified, $HOME/.aliyun/config.json will be used."
17-
type = string
18-
default = ""
19-
}
201

21-
variable "skip_region_validation" {
22-
description = "(Deprecated from version 1.1.0) Skip static validation of region ID. Used by users of alternative AlibabaCloud-like APIs or users w/ access to regions that are not public (yet)."
23-
type = bool
24-
default = false
25-
}
262

273
#################
284
# Dnat Entries

0 commit comments

Comments
 (0)