Terraform Code๋ฅผ Moduleํ ํ์ฌ ๋ชจ๋ ์ฌ์ฉ์๊ฐ ์ ์ฒด ์ฝ๋๋ฅผ ๋ชจ๋ฅด๋๋ผ๋, ๋ณ์๊ฐ ๋ณ๊ฒฝ์ ํตํด ์ํ๋ ์ธ์คํด์ค๋ฅผ ์์ฑํ๊ณ ํ ๋ผํผ์ผ๋ก ๊ด๋ฆฌ๊ฐ ๊ฐ๋ฅํฉ๋๋ค. ํฅํ์ Moduleํ์ ์ถ๊ฐ๋ก ๋ค์ํ ์๋น์ค ์์ฑ ์ฝ๋๋ฅผ ์ถ๊ฐ๋ก ์์ฑ์ด ๊ฐ๋ฅํ๊ฒ ํ๋๋ฐ ๊ธฐ๋ฐ์ด ๋ ์์๊ฒ ํฉ๋๋ค.
HOL์ ํตํด์ Module์ ์ฝ๋๋ฅผ ์ดํดํ๊ณ ์์ ํ์ฌ ์ํ๋ ์ํคํ ์ณ๋ฅผ ๋ฐฐํฌ๋ฅผ ํ ์ ์์ต๋๋ค.
Terraform์ ์ค์น๊ฐ ๋์ด ์์ด์ผ ํฉ๋๋ค
Terraform ์ค์น๋ ์ฌ๊ธฐ๋ฅผ ๋ฐ๋ผ์ ์ค์นํด ์ฃผ์ธ์
VPC, vSwitch, ECS, Security Group, RDS, SLB์ ๋ํ Terraform Code๋ฅผ ์ฌ์ฉ์ ํฉ๋๋ค.
Terraform์์ ์ ๊ณตํ๋ Alibaba Cloud Provider๋ ์ฒจ๋ถํ ๋งํฌ๋ฅผ ํตํด์ ๋ ์์ธํ๊ฒ ๋ณด์ค ์ ์์ต๋๋ค
https://registry.terraform.io/providers/aliyun/alicloud/latest/docs
์ถ๊ฐ๋ก Terraform HCL ์ธ์ด์์ ์ ๊ณตํ๋ ๋ค์ํ ํจ์๋ฅผ ์ฌ์ฉ์ ํฉ๋๋ค.
for, count, Local, lookup ๋ฑ์ ์ฌ์ฉํ์ฌ ๊ฒ์ ๋ฐ ๋ณ์ ์ ๋ฌ ์ฉ๋๋ฅผ ์ํด์ ์ฌ์ฉ์ ํฉ๋๋ค.
Terraform์ ๊ฒฝ์ฐ ํด๋ ๋จ์๊ฐ ํ๋์ Module๋ก ์ธ์์ ํ๊ณ ๊ด๋ฆฌ๋ฅผ ํฉ๋๋ค. ๊ฐ ์๋น์ค ๋ณ๋ก ํ๋์ ํด๋๋ก ์์ฑ์ ํ๊ณ Code ์ ์ฅ์ ํ ์๋ ์์ผ๋, ์ถํ์ ํธ๋ฌ๋ธ์ํ ๋ฐ ๊ด๋ฆฌ์ ์ด๋ ค์์ด ์์ต๋๋ค.
ํ์ฌ ํ ์คํธ ํ๊ฒฝ์์๋ ์๋์ ๊ฐ์ด ํด๋๋ฅผ ๋๋์ด ๋จ์ต๋๋ค.
- 01.code : ๋ฉ์ธ ํด๋
ใด main_code.tf : main terraform ํ์ผ
ใด config.tf : terraform ์ ์ ๊ณ์ ์ ๋ณด ํ์ผ(์ค์ฌ์ฉ์์ ํ๊ฒฝ๋ณ์ ์ถ์ฒ)
ใด output.tf : terraform output ํ์ผ
- 02.test_code : ํ
์คํธ์ฉ ํด๋
ใด main_code.tf : ์์ฑ ํ
์คํธ์ฉ ๋ชจ๋ ๋ณ์ ๊ธฐ์
๋ tf ํ์ผ (ํ
์คํธ์ฉ)
ใด config.tf : terraform ์ ์ ๊ณ์ ์ ๋ณด ํ์ผ(์ค์ฌ์ฉ์์ ํ๊ฒฝ๋ณ์ ์ถ์ฒ)
ใด output.tf : terraform output ํ์ผ
- modules : terraform code ์ ์ฅ ํด๋
ใด ecs : ecs ์์ฑ code ์ ์ฅ ํด๋
ใด rds : rds ์์ฑ code ์ ์ฅ ํด๋
ใด sg : sg ์์ฑ code ์ ์ฅ ํด๋
ใด slb : slb ์์ฑ code ์ ์ฅ ํด๋
ใด vpc : vpc ์์ฑ code ์ ์ฅ ํด๋
dev ํด๋๋ ์ํ๋ ์๋น์ค๋ฅผ ์์ฑํ๊ธฐ ์ํ ๋ณ์๋ฅผ ์ ์ฅํ๊ณ ์์ต๋๋ค. modules ํด๋๋ module์์ ์ฌ์ฉํ๋ ๊ฐ ์๋น์ค ์์ฑ ์ฝ๋๋ฅผ ์ ์ฅํ๊ณ ์์ต๋๋ค.
Terraform code์์ ์ ๊ณตํ๋ Local ๋ณ์๋ฅผ ์ด์ฉํ๋ฉด ์ฌ๋ฌ๋ฒ ์ฌ์ฉํ๋ ๋ณ์๋ฅผ ํ๋ฒ๋ง ์ ์๋ฅผ ํ์ฌ ์ฌ์ฉ์ ํ ์์์ต๋๋ค. ์ง๊ธ๊ณผ ๊ฐ์ด ๋ชจ๋ํ๋ฅผ ํ code์์๋ ๋ ์ ์ฉํ๊ฒ ์ฐ์ ๋๋ค.
์ธ์คํด์ค๋ฅผ ์์ฑ์ ํ ๋, ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉ์ ํ๊ฒ๋๋ region, zone, subnet์ ๋ํ ์ ๋ณด๋ฅผ locals๋ก ์ฒ๋ฆฌํ์ต๋๋ค.
locals {
region = "Your Region"
azs = ["Your Zone A", "Your Zone B"]
public_subnets = ["Your public subnet A","Your public subnet B"]
private_subnets = ["Your Private subnet A","Your Private subnet B"]
database_subnets = ["Your DB subnet A","Your DB subnet B"]
}
์ธํ๋ผ์ ๊ธฐ๋ณธ์ด ๋๋ VPC ์์ฑ์ ํ๋ ๊ตฌ๋ฌธ์ ๋๋ค.
-
๋ชจ๋ ๋ณ์ Code
- vpc ์์ฑ ํ์ผ์ ์ํ Module ์ฝ๋์ ๋๋ค.
module "dev_vpc" { # source๋ variables.tf, main.tf, outputs.tf ํ์ผ์ด ์์นํ ๋๋ ํฐ๋ฆฌ ๊ฒฝ๋ก๋ฅผ ๋ฃ์ด์ค๋ค. source = "../modules/vpc" # VPC์ด๋ฆ์ ๋ฃ์ด์ค๋ค. ์ด ๊ฐ์ VPC module์ด ์์ฑํ๋ ๋ชจ๋ ๋ฆฌ์์ค ์ด๋ฆ์ prefix๊ฐ ๋๋ค name = "Your VPC Name" # VPC์ CIDR block์ ์ ์ํ๋ค. ์์ ์ ์ํ subnet๋ฅผ ํฌํจํ๋ ๋์ญ๋๋ฅผ ๊ธฐ์ ํฉ๋๋ค. cidr = "Your VPC CIDR" # VPC๊ฐ ์ฌ์ฉํ AZ๋ฅผ ์ ์ํ๋ค. azs = local.azs # VPC์ Public Subnet CIDR block์ ์ ์ํ๋ค. (Public ๋ง๊ณ ๋ค๋ฅธ ์ด๋ฆ์ผ๋ก๋ ๊ฐ๋ฅ.) public_subnets = local.public_subnets # VPC์ Private Subnet CIDR block์ ์ ์ํ๋ค. private_subnets = local.private_subnets # VPC์ Private DB Subnet CIDR block์ ์ ์ํ๋ค. (RDS๋ฅผ ์ฌ์ฉํ์ง ์์ผ๋ฉด ์ด ๋ผ์ธ์ ํ์์๋ค.) database_subnets = local.database_subnets # VPC module์ด ์์ฑํ๋ ๋ชจ๋ ๋ฆฌ์์ค์ ๊ธฐ๋ณธ์ผ๋ก ์ ๋ ฅ๋ Tag๋ฅผ ์ ์ํ๋ค. tags = { "TerraformManaged" = "true" } }
- source : ์ฝ๋๊ฐ ์ ์ฅ๋์ด์๋ ํด๋์ ๊ฒฝ๋ก๋ฅผ ์ง์
- name : vpc, vswitch์ ์ด๋ฆ์ ๊ธฐ์
- cidr : ์ํ๋ vpc์ cidr ๊ธฐ์
- azs : ์ํ๋ zone์ ["",""] ํํ๋ก ๊ธฐ์ (locals ๋ณ์๋ฅผ ์ฌ์ฉ)
- public_subnets : ์ํ๋ public subnet์ ["",""] ํํ๋ก ๊ธฐ์ (locals ๋ณ์๋ฅผ ์ฌ์ฉ)
- private_subnets : ์ํ๋ private subnet์ ["",""] ํํ๋ก ๊ธฐ์ (locals ๋ณ์๋ฅผ ์ฌ์ฉ)
- database_subnets : ์ํ๋ database subnet์ ["",""] ํํ๋ก ๊ธฐ์ (locals ๋ณ์๋ฅผ ์ฌ์ฉ)
- tags : tag๋ฅผ ์ด์ฉํด์ ๊ด๋ฆฌํ ๊ฒฝ์ฐ ๊ธฐ์ "key" = "value" ํํ๋ก ๊ธฐ์
-
์ธ์คํด์ค ์์ฑ ๋ชจ๋ํ ์ฝ๋
VPC ์์ฑ code ์ฐธ๊ณ : modules/vpc ํด๋ ์ฐธ๊ณ
ECS์ ์์ฑ ์ ์ ECS๊ฐ ์ฌ์ฉํด์ผ๋๋ ๋ณด์๊ทธ๋ฃน์ ์์ฑ์ ํฉ๋๋ค. ํด๋น ๊ฐ์ด๋์์๋ public์ฉ, was์ฉ์ผ๋ก 2๊ฐ๋ฅผ ๋์ผํ zone A์ ์์ฑํ ์์ ์ ๋๋ค.
- dev-public-sg ๋ณด์์ ์ฑ ๋ด์ฉ
- 80,443 port : 0.0.0.0/0
- 21, 22 port : "Your Public IP"
- ICMP : 172.16.0.0/16 (VPC Network)
- dev-was-sg ๋ณด์์ ์ฑ ๋ด์ฉ
-
80 port : 172.16.0.0/24, 172.16.100.0/24 (public subnet)
-
21, 22 port : 172.16.0.0/24, 172.16.100.0/24 (public subnet)
-
ICMP : 172.16.0.0/16 (VPC Network)
-
๋ชจ๋ ๋ณ์ Code
-
๋ณด์๊ทธ๋ฃน ์์ฑ์ ํ์ํ ๋ณ์ ๊ฐ๋ค์ ๊ธฐ์ ํฉ๋๋ค.
-
๋ณด์๊ทธ๋ฃน ์ ์ฑ ์ ํ์ํ ๋ด์ฉ์ด ๋ชจ๋ ์์ ๊ฒฝ์ฐ : ์ฒซ๋ฒ์งธ ์ฝ๋
-
๋ณด์๊ทธ๋ฃน ์ ์ฑ ์ port๋ฅผ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ : ๋๋ฒ์งธ ์ฝ๋
ingress_ports ๋ณ์์ ์ ์ํ port๊ฐ ์ ์ฉ๋ฉ๋๋ค.
- ๋ณด์๊ทธ๋ฃน ์ ์ฑ ์ cidr์ ์ง์ ํ์ง ์์ ๊ฒฝ์ฐ : ์ธ๋ฒ์งธ ์ฝ๋
vpc_cidr ๋ณ์์ ์ ์ํ cidr์ด ์ ์ฉ๋ฉ๋๋ค.
-
module "public_sg" { source = "../modules/sg" // ๋์ -sg ๊ฐ ์๋์ผ๋ก ๋ถ์ต๋๋ค. sg_name = "Your public SG Name" vpc_id = module.dev_vpc.vpc_id vpc_cidr = [module.dev_vpc.vpc_cidr_block] ingress_ports = [80,443] # Port ์ ์๊ฐ ์์ ๊ฒฝ์ฐ, [22,3389]๋ฅผ ๊ธฐ๋ณธ์ผ๋ก ํ ๋น # 3๊ฐ์ ํญ๋ชฉ ์ค ์ฌ์ฉํ๊ณ ์ ํ๋ ๋ฐฉ์ ์ด์ธ๋ ๊ผญ ์ญ์ ๋ฅผ ํด์ผํฉ๋๋ค. ingress_with_cidr_blocks_and_ports = [ { # ๋ชจ๋ ๋ด์ฉ (port, protocol, priority,cidr)์ด ์์๊ฒฝ์ฐ, ํด๋น ๋ด์ฉ์ผ๋ก ํ ๋น ports = "21,22" protocol = "tcp" priority = 1 cidr_blocks = "Your IP/32" }, { # port์ ์ ์๊ฐ ์์ ๊ฒฝ์ฐ, ingress_ports์์ ์ ์ํ port๋ฅผ ๊ธฐ์ค์ผ๋ก ํ ๋น # protocole ์ ์๊ฐ ์์ ๊ฒฝ์ฐ, ๊ธฐ๋ณธ๊ฐ์ธ TCP๋ก ํ ๋น protocol = "tcp" description = "ingress for tcp" cidr_blocks = "0.0.0.0/0" }, { # cidr์ด ์ ์๊ฐ ์์ ๊ฒฝ์ฐ vpc_cidr์์ ์ ์ํ cidr์ ๊ธฐ์ค์ผ๋ก ํ ๋น protocol = "icmp" priority = 2 description = "ingress for icmp" } ] } module "was_sg" { source = "../modules/sg" // ๋์ -sg ๊ฐ ์๋์ผ๋ก ๋ถ์ต๋๋ค. sg_name = "Your WAS SG Name" vpc_id = module.dev_vpc.vpc_id vpc_cidr = [module.dev_vpc.vpc_cidr_block] ingress_ports = [80] # Port ์ ์๊ฐ ์์ ๊ฒฝ์ฐ, [22,3389]๋ฅผ ๊ธฐ๋ณธ์ผ๋ก ํ ๋น # 3๊ฐ์ ํญ๋ชฉ ์ค ์ฌ์ฉํ๊ณ ์ ํ๋ ๋ฐฉ์ ์ด์ธ๋ ๊ผญ ์ญ์ ๋ฅผ ํด์ผํฉ๋๋ค. ingress_with_cidr_blocks_and_ports = [ { # ๋ชจ๋ ๋ด์ฉ (port, protocol, priority,cidr)์ด ์์๊ฒฝ์ฐ, ํด๋น ๋ด์ฉ์ผ๋ก ํ ๋น ports = "21,22" protocol = "tcp" priority = 1 cidr_blocks = module.dev_vpc.public_cidr }, { # port์ ์ ์๊ฐ ์์ ๊ฒฝ์ฐ, ingress_ports์์ ์ ์ํ port๋ฅผ ๊ธฐ์ค์ผ๋ก ํ ๋น # protocole ์ ์๊ฐ ์์ ๊ฒฝ์ฐ, ๊ธฐ๋ณธ๊ฐ์ธ TCP๋ก ํ ๋น protocol = "tcp" description = "ingress for tcp" cidr_blocks = module.dev_vpc.public_cidr #vpc ์์ฑํ ๋ public cidr์ ์ํ ๊ฒฝ์ฐ ๋ชจ๋๋ก ์์ ๊ฐ๋ฅ }, { # cidr์ด ์ ์๊ฐ ์์ ๊ฒฝ์ฐ vpc_cidr์์ ์ ์ํ cidr์ ๊ธฐ์ค์ผ๋ก ํ ๋น protocol = "icmp" priority = 2 description = "ingress for icmp" } ] }
- sg_name : ๋ณด์๊ทธ๋ฃน์ ์ด๋ฆ ๊ธฐ์
- vpc_id : vpc ์์ฑ ์ ์๊ธฐ๋ id๋ฅผ ์๋์ผ๋ก ๊ฐ์ ธ์ด (vpc ๋ชจ๋์์ ๋ฏธ๋ฆฌ output์ผ๋ก ์ ๋ณด๋ฅผ ๋ฐ์์ด)
- vpc_cidr : vpc ์์ฑ ํ cidr ์ ๋ณด๋ฅผ ์๋์ผ๋ก ๊ฐ์ ธ์ด (vpc ๋ชจ๋์์ ๋ฏธ๋ฆฌ output์ผ๋ก ์ ๋ณด๋ฅผ ๋ฐ์์ด)
- ingress_ports : ์ํ๋ port ๋ฒํธ๋ฅผ [21,22] ์ฒ๋ผ ๊ธฐ์ ์๋ ๋ณ์๊ฐ์์ port์ ์ ์๊ฐ ์์ ๊ฒฝ์ฐ, ํด๋น ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ ์ฑ ์ค์
- ingress_with_cidr_blocks_and_ports : ๋ณด์๊ทธ๋ฃน์ ์ ์ฉํ ๋ด์ฉ์ ๊ธฐ์
- ports : ์ํ๋ port๋ฅผ ๊ธฐ์ . ๋จ, 2๊ฐ ์ด์์ผ ๊ฒฝ์ฐ "21","22" ํํ๋ก ๊ธฐ์ (ํ์ o) ๋จ, ๋ฏธ๊ธฐ์ ์ ingress_ports์ ๊ธฐ์ ํ port๋ก ๋์ฒด
- protocol : TCP, UDP๋ฅผ ์ ํ ํ ๊ธฐ์ . ๋จ, ๋ฏธ ๊ธฐ์ ์ ๊ธฐ๋ณธ๊ฐ์ธ TCP๋ก ์ค์ (ํ์ x)
- priority : ์ฐ์ ์์๋ฅผ ๊ธฐ์ . ๊ธฐ๋ณธ๊ฐ "1" (ํ์ x)
- cidr_blocks : ํ์ฉ์ ํ๊ณ ์ ํ๋ cidr ๊ธฐ์ . 2๊ฐ ์ด์์ผ ๊ฒฝ์ฐ "1.1.1.1","2.2.2.2" ํํ๋ก ๊ธฐ์ (ํ์ o) ๋จ, ๋ฏธ๊ธฐ์ ์ vpc_cidr ๊ฐ์ผ๋ก ๋์ฒด. ์ธ๋ถ public IP ๊ฒฝ์ฐ ํ์๋ก ๊ธฐ์
- description : ์ค๋ช ์ ๊ธฐ์
-
๋ณด์๊ทธ๋ฃน ์์ฑ code ์ฐธ๊ณ : modules/sg ํด๋ ์ฐธ๊ณ
ECS ์ธ์คํด์ค๋ฅผ ์์ฑ์ ํฉ๋๋ค. ํด๋น ๊ฐ์ด๋์์๋ web์ฉ ECS 2EA, was์ฉ ECS 2EA๋ฅผ ์์ฑ์ ํฉ๋๋ค. web์ฉ์ ๊ฒฝ์ฐ EIP๋ฅผ ์ฐ๊ฒฐ์ ํฉ๋๋ค.
-
Public : 2 EA (๊ณต์ธ๋ง) + EIP
-
WAS : 2 EA (์ฌ์ค๋ง)
-
๋ชจ๋ ๋ณ์ Code
- ecs Module์ ecs ์ฉ๋์ ๋ง๊ฒ ๊ธฐ์ ๋ฐ ๋ณ์๋ฅผ ์ ๋ ฅ์ ํฉ๋๋ค. ECS ์์ฑ์ฝ๋๋ฅผ ์ด์ฉํด์ ์์ฑ์ ํ๋ฏ๋ก ์ฉ๋ ๋ณ๋ก ๊ฐ๊ฐ ์๋์ ๊ฐ์ด ์ฌ์ฉ์ ํด์ผํฉ๋๋ค.
module "web_instances" { source = "../modules/ecs" # ๊ธฐ๋ณธ type ์ ํ์ฉ Region ์ ํ azs = local.azs[0] # ECS Count ์ ํ ecs_count = "2" # ECS Name ์ ๋ ฅ - name-01, name-02 ์์ผ๋ก ๋ค์ด๋ฐ์ด ๋ฉ๋๋ค. ecs_name = "Your Web Server Name" # PW ์ ๋ ฅ ecs_password = "Your Password" # ECS Image ์ ํ (^centos_7์ ๊ฒฝ์ฐ Centos 7 ๋ฒ์ ์ค ์ต์จ์ผ๋ก ์ ๋ฌ) ecs_image = "Your OS Image" # ECS type ecs_type = "Your ECS Type" # EIP ์๋ ์ ํ (ํ์ํ์ง ์์ ๊ฒฝ์ฐ 0 ์ด๋ "" ์ ๋ ฅ) eip_count = "2" # System disk size ์ ํ (๊ธฐ๋ณธ๊ฐ window - 40GB, linux - 20GB) disk_size = "40" # vswitch ์ ๋ณด (vpc ์์ฑ ์ map์์ ๋ฑ๋กํ ๋ฆฌ์ ์์ผ๋ก 0,1) ecs_vswitch_id = lookup(module.dev_vpc.public_info_map, local.azs[0]) # SG ์ ๋ณด ecs_sg_id = module.public_sg.sg_id } module "was_instances" { source = "../modules/ecs" # ๊ธฐ๋ณธ type ์ ํ์ฉ Region ์ ํ azs = local.azs[0] # ECS Count ์ ํ ecs_count = "2" # ECS Name ์ ๋ ฅ - name-01, name-02 ์์ผ๋ก ๋ค์ด๋ฐ์ด ๋ฉ๋๋ค. ecs_name = "Your Was Server Name" # PW ์ ๋ ฅ ecs_password = "Your Password" # ECS Image ์ ํ (^centos_7์ ๊ฒฝ์ฐ Centos 7 ๋ฒ์ ์ค ์ต์จ์ผ๋ก ์ ๋ฌ) ecs_image = "Your OS Image" # ECS type (์ : ecs.n4.large) ecs_type = "Your ECS Type" # EIP ์๋ ์ ํ (ํ์ํ์ง ์์ ๊ฒฝ์ฐ ์ญ์ ) # eip_count = "" # System disk size ์ ํ (๊ธฐ๋ณธ๊ฐ window - 40GB, linux - 20GB) disk_size = "40" # vswitch ์ ๋ณด (vpc ์์ฑ ์ map์์ ๋ฑ๋กํ ๋ฆฌ์ ์์ผ๋ก 0,1) ecs_vswitch_id = lookup(module.dev_vpc.public_info_map, local.azs[0]) # SG ์ ๋ณด ecs_sg_id = module.was_sg.sg_id }
- azs : local์ ๊ธฐ์ ํ ๋ด์ฉ ์ค ๋ฆฌ์ ์ ์ ํ. ์ฒซ๋ฒ์งธ ๋ผ๋ฉด [0], ๋๋ฒ์งธ ๊ฐ์ด๋ฉด [1] ์์ผ๋ก ๊ธฐ์
- ecs_count : ๋์ผํ ์ฉ๋์ ecs์ ์๋์ ์ ํ
- ecs_name : ecs์ ์ด๋ฆ์ ๊ธฐ์ . ์๋์ด 2๊ฐ์ผ ๊ฒฝ์ฐ "name-01", "name-02" ์์ผ๋ก ์๋ฒ์ด ๊ธฐ์
- ecs_password : ecs์ ์ํธ ๊ธฐ์
- ecs_image : ecs์ ์ด๋ฏธ์ง๋ฅผ ๊ธฐ์ . ์ด๋ฏธ์ง๋ฅผ ์๋ค๋ฉด ์ง์ ๊ธฐ์ ํด๋ ๋ฌด๊ด
- ecs_type : ecs์ ์คํ์ ๊ธฐ์ . ๋ฌธ์์์ ์ํ๋ ํ์ ์ ์ ํ ํ ๊ธฐ์
- eip_count : ecs์ eip๋ฅผ ์ฐ๋ํ๊ณ ์ ํ๋ค๋ฉด ๊ธฐ์ . ๋จ ํ์ ์๋ค๋ฉด "" ์ผ๋ก ๊ธฐ์
- disk_size : system disk๊ฐ ์ฌ์ฉํ ์ฉ๋์ ๊ธฐ์ . ์ถํ์ ๋ฐ์ดํ ๋์คํฌ๋ ์ถ๊ฐ ์์
- ecs_vswitch_id : ์ฌ์ฉํ๊ณ ์ ํ๋ vswitch์ ๋ฆฌ์ ์ ๋ณ๊ฒฝ. local.azs[0] or "cn-shanghai-a"
- ecs_sg_id : ๋ฏธ๋ฆฌ ์์ฑํ ์ฉ๋์ ๋ณด์๊ทธ๋ฃน์ ์ ํ. was_sg - ์ด๋ฆ์ ๋ณด์๊ทธ๋ฃน ์ด๋ฆ์ผ๋ก ๋ณ๊ฒฝ
ECS ์์ฑ code ์ฐธ๊ณ : modules/ecs ํด๋ ์ฐธ๊ณ
SLB ์ธ์คํด์ค๋ฅผ ์์ฑ์ ํฉ๋๋ค.
-
Product ์๋น์ค๋ฅผ ์ํ SLB ์์ฑ๊ณผ Internal SLB ์์ฑ์ ํฉ๋๋ค. ์์ฑ ํ SLB์ Listener๋ฅผ ๊ตฌ์ฑ์ ํ๊ธฐ ์ํ ๋ณ์๋ ๋ฑ๋ก์ ํ๋ฉด ๋ชจ๋ ๊ตฌ์ฑ์ด ๊ฐ๋ฅํฉ๋๋ค.
-
๋ชจ๋ ๋ณ์ Code
module "dev_public_slb" { source = "../modules/slb" ##### # SLB instance ##### name = "Your public slb Name" internet_charge_type = "PayByTraffic" # ๊ธฐ๋ณธ๊ฐ PaybyTraffic address_type = "internet" # [internet, intranet] ์ค ์ ํ vswitch_id = lookup(module.dev_vpc.public_info_map, "cn-shanghai-a") # internet์ผ ๊ฒฝ์ฐ ๋ฌด์ specification = "slb.s1.small" # ๊ธฐ๋ณธ๊ฐ:"slb.s1.small" ๋๋จธ์ง ์ ํ "slb.s2.small", "slb.s2.medium", "slb.s3.small", "slb.s3.medium", "slb.s3.large" and "slb.s4.large" master_zone_id = local.azs[0] slave_zone_id = local.azs[1] ######################## #attach virtual servers# ######################## servers_of_virtual_server_group = [ { # ์ฌ๋ฌ๋ ๋ฃ์ ๊ฒฝ์ฐ, "i-asd,i-asd" server_ids = lookup(module.web_instances, "ecs_ids") port = "80" type = "ecs" # ๊ธฐ๋ณธ๊ฐ ecs, ์์ ์ด๋ ๋ฌด๊ด weight = 100 # ๊ธฐ๋ณธ๊ฐ 100, ์์ ์ด๋ ๋ฌด๊ด } ] ########## # Liteners ์ํ๋๊ฑธ ์ผ์ผ์ด ๊ธฐ์ ์ด ํ์ ########## listeners = [ { backend_port = "80" frontend_port = "80" # protocol์ ์ํ๋ ๊ฑธ๋ก ๋ณ๊ฒฝ L4 - TCP UDP, L7 - HTTP HTTPS protocol = "http" bandwidth = "-1" scheduler = "wrr" healthy_threshold = "4" gzip = "false" health_check_type = "tcp" } ] // health_check will apply to all of listeners if health checking is not set in the listeners health_check = { health_check = "on" health_check_type = "tcp" healthy_threshold = "3" unhealthy_threshold = "2" health_check_timeout = "5" health_check_interval = "2" health_check_connect_port = "80" health_check_uri = "/" health_check_http_code = "http_2xx" } // advanced_setting will apply to all of listeners if some fields are not set in the listeners advanced_setting = { # TCP์ ๊ฒฝ์ฐ sticky session setting, "on", "server" #sticky_session = "on" #sticky_session_type = "server" # http์ ๊ฒฝ์ฐ sticky session setting, "on", "insert" #sticky_session = "on" #sticky_session_type = "insert" #cookie_timeout = "86400" gzip = "false" #retrive_slb_ip = "true" #retrive_slb_id = "false" #retrive_slb_proto = "true" persistence_timeout = "5" } // x_forwarded_for will apply to all of listeners if it is not set in the listeners x_forwarded_for = { retrive_slb_ip = "true" retrive_slb_id = "false" retrive_slb_proto = "true" } ssl_certificates = { #tls_cipher_policy = "tls_cipher_policy_1_0" } } module "dev_internal_slb" { source = "../modules/slb" ##### # SLB instance ##### name = "Your internal slb Name" internet_charge_type = "PayByTraffic" # ๊ธฐ๋ณธ๊ฐ PaybyTraffic address_type = "intranet" # [internet, intranet] ์ค ์ ํ vswitch_id = lookup(module.dev_vpc.public_info_map, "cn-shanghai-a") # internet์ผ ๊ฒฝ์ฐ ๋ฌด์ specification = "slb.s1.small" # ๊ธฐ๋ณธ๊ฐ:"slb.s1.small" ๋๋จธ์ง ์ ํ "slb.s2.small", "slb.s2.medium", "slb.s3.small", "slb.s3.medium", "slb.s3.large" and "slb.s4.large" master_zone_id = local.azs[0] slave_zone_id = local.azs[1] ######################## #attach virtual servers# ######################## servers_of_virtual_server_group = [ { # ์ฌ๋ฌ๋ ๋ฃ์ ๊ฒฝ์ฐ, "i-asd,i-asd" server_ids = lookup(module.was_instances, "ecs_ids") port = "1234" type = "ecs" # ๊ธฐ๋ณธ๊ฐ ecs, ์์ ์ด๋ ๋ฌด๊ด weight = 100 # ๊ธฐ๋ณธ๊ฐ 100, ์์ ์ด๋ ๋ฌด๊ด } ] ########## # Liteners ์ํ๋๊ฑธ ์ผ์ผ์ด ๊ธฐ์ ์ด ํ์ ########## listeners = [ { backend_port = "1234" frontend_port = "1234" # protocol์ ์ํ๋ ๊ฑธ๋ก ๋ณ๊ฒฝ L4 - TCP UDP, L7 - HTTP HTTPS protocol = "tcp" scheduler = "wrr" healthy_threshold = "4" gzip = "false" health_check_type = "tcp" } ] // health_check will apply to all of listeners if health checking is not set in the listeners health_check = { health_check = "on" health_check_type = "tcp" healthy_threshold = "3" unhealthy_threshold = "2" health_check_timeout = "5" health_check_interval = "2" health_check_connect_port = "80" health_check_uri = "/" health_check_http_code = "http_2xx" } // advanced_setting will apply to all of listeners if some fields are not set in the listeners advanced_setting = { # TCP์ ๊ฒฝ์ฐ sticky session setting, "on", "server" #sticky_session = "on" #sticky_session_type = "server" # http์ ๊ฒฝ์ฐ sticky session setting, "on", "insert" #sticky_session = "on" #sticky_session_type = "insert" #cookie_timeout = "86400" gzip = "false" #retrive_slb_ip = "true" #retrive_slb_id = "false" #retrive_slb_proto = "true" persistence_timeout = "5" } // x_forwarded_for will apply to all of listeners if it is not set in the listeners x_forwarded_for = { retrive_slb_ip = "true" retrive_slb_id = "false" retrive_slb_proto = "true" } ssl_certificates = { #tls_cipher_policy = "tls_cipher_policy_1_0" } }
- name : slb์ ์ฌ์ฉํ ์ด๋ฆ ๊ธฐ์
- internet_charge_type : ๊ธฐ๋ณธ๊ฐ์ธ pay-by-traffic, ๋ณ๊ฒฝ์ด ํ์ํ ๊ฒฝ์ฐ๋ง ๋ณ๊ฒฝ
- address_type : ์ธ๋ถ, ๋ด๋ถ์ฉ ์ค ์ ํ
- vswitch_id : ๋ด๋ถ์ฉ์ผ๋๋ง ๊ธฐ์
- specification : slb์ ์คํ์ ๊ธฐ์
- master_zone_id : ๋ฉ์ธ slb zone์ ๊ธฐ์
- slave_zone_id : ์คํ ๋ฐ์ด slb zone์ ๊ธฐ์
- listeners : slb์ ๋ฆฌ์ค๋ ์์ฑ ๋ณ์ ๊ธฐ์
- backend_port : ์๋ฒ์ ์ฐ๊ฒฐ๋ port ๊ธฐ์
- frontend_port : ์ธ๋ถ์์ ์ ์ํ port ๊ธฐ์
- protocol : tcp, ump, http, https ์ค ์ ํ
- scheduler : ์ธ์ ๋ถ๊ธฐ์ ๋ํ ์ต์ ์ ํ "wrr"์ ๊ฒฝ์ฐ round-robin
- healthy_threshold : ์ํ ํ์ธ์ ๋ํ ๋น๋ ๊ธฐ์
- gzip : gzip ํ์ฑํ์ ๋ํ ์ต์ ๊ธฐ์
- health_check_type : ์ํ ํ์ธ ์ ์ฒดํฌํ ํ์ ์ ํ. tcp - tcp, http - http ๋ก ์ค์ (๋ด์ฉํ๋ฒ๋ ํ์ธ)
- health_check : ํฌ์ค์ฒดํฌ ๋ณ์ ๊ธฐ์
- health_check : ์ฌ์ฉ์ฌ๋ถ ๊ธฐ์ . ์ฌ์ฉ ํ์ง์์ ๊ฒฝ์ฐ "false"
- health_check_type : tcp or http ์ค ๊ธฐ์
- healthy_threshold : ์ ์์ฌ๋ถ์ ๋ํ ํ์ ๊ธฐ์
- unhealthy_threshold : ๋น์ ์ฅ์ฌ๋ถ์ ๋ํ ํ์ ๊ธฐ์
- health_check_timeout : ํฌ์ค์ฒดํฌ ํ์์์ ์๊ฐ ๊ธฐ์
- health_check_interval : ํฌ์ค์ฒดํฌ ์ธํฐ๋ฒ ๊ธฐ์
- health_check_connect_port : ํฌ์ค์ฒดํฌ์ฉ ํฌํธ ๊ธฐ์
- health_check_uri : ๊ธฐ๋ณธ๊ฐ "/" ๋ก ์ค์ . ๋จ, ์ํ๋ ํน๋ณํ ๊ฒฝ๋ก๊ฐ ์์ ๊ฒฝ์ฐ ๊ธฐ์
- health_check_http_code : ํฌ์ค์ฒดํฌ ํ์ด์ง ์ฝ๋ ๊ธฐ์
- advanced_setting : ๊ณ ๊ธ ๊ธฐ๋ฅ์ ๋ํ ๋ณ์ ๊ธฐ์
- sticky_session : sticky session ์ฌ์ฉ ์ฌ๋ถ ๊ธฐ์
- sticky_session_type : sticky_session ํ์ ๊ธฐ์
- gzip : gzip ์ฌ์ฉ ์ฌ๋ถ ์ ํ
- persistence_timeout : ๋ช์ด๋์ ์ ์ง๋ฅผ ํ ์ง์ ๋ํ ์ค์ ๊ธฐ์
-
x_forwarded_for : x_forwarded_for ๊ธฐ๋ฅ ์ค์ ๋ณ์ ๊ธฐ์
- retrive_slb_ip : x_forwarded_for ๊ด๋ จ๋ ๊ธฐ๋ฅ ์ฌ์ฉ์ฌ๋ถ ๊ธฐ์
- retrive_slb_id : x_forwarded_for ๊ด๋ จ๋ ๊ธฐ๋ฅ ์ฌ์ฉ์ฌ๋ถ ๊ธฐ์
- retrive_slb_proto : x_forwarded_for ๊ด๋ จ๋ ๊ธฐ๋ฅ ์ฌ์ฉ์ฌ๋ถ ๊ธฐ์
-
ssl_certificates : ์ธ์ฆ์ ์ฌ์ฉ๊ด๋ จ ๋ณ์ ๊ธฐ์
- tls_cipher_policy : ๊ธฐ์กด์ ๋ฑ๋กํ ์ธ์ฆ์ ์์ ๊ฒฝ์ฐ ์ ํ
SLB ์์ฑ code ์ฐธ๊ณ : modules/slb ํด๋ ์ฐธ๊ณ
ํด๋น ๊ฐ์ด๋์์๋ DB๋ฅผ ๊ด๋ฆฌํ Database๋ก ์ฌ์ฉํ๋ ค๊ณ ํฉ๋๋ค. Alibaba Clooud๊ฐ ์ ๊ณตํ๋ ๊ด๋ฆฌํ Database์ค Mysql์ ์ฌ์ฉ์ ํฉ๋๋ค. ๋จ, ํด๋น ์ธ์คํด์ค ์์ฑ ๋ชจ๋ํ ์ฝ๋์๋ ์ค์ง MySQL๋ง ์์ฑ์ด ๊ฐ๋ฅํฉ๋๋ค. RDS ์์ฑ ๋ฐ ๋ฐฑ์ ์ ์ฑ ๊น์ง ์ ์ฉ์ด ๊ฐ๋ฅํ๋ฉฐ, ๋ฐฑ์ ์ ์ฑ ์ ์ต์ ์ ๋๋ค.
-
๋ชจ๋ ๋ณ์ Code
module "mysql" { source = "../modules/rds/" region = local.region ################# # Rds Instance ################# engine = "MySQL" engine_version = "8.0" instance_type = "rds.mysql.s2.large" instance_storage = 20 instance_charge_type = "Postpaid" instance_name = "dev-rds" security_group_ids = [] vswitch_id = lookup(module.dev_vpc.public_info_map, local.azs[0]) security_ips = local.private_subnets master_zone = local.azs[0] slave_zone = "auto" tags = { created = "Terraform" } ################# # Rds Backup policy ################# preferred_backup_period = ["Monday", "Wednesday"] # UTC ์ํฅ์ผ๋ก ์ค์ ์๊ฐ์์ +9:00์ด ์ ์ฉ๋ฐ์ต๋๋ค. // 00:00Z-01:00Z 01:00Z-02:00Z 02:00Z-03:00Z 03:00Z-04:00Z 04:00Z-05:00Z 05:00Z-06:00Z 06:00Z-07:00Z 07:00Z-08:00Z 08:00Z-09:00Z 09:00Z-10:00Z 10:00Z-11:00Z 11:00Z-12:00Z 12:00Z-13:00Z 13:00Z-14:00Z 14:00Z-15:00Z 15:00Z-16:00Z 16:00Z-17:00Z 17:00Z-18:00Z 18:00Z-19:00Z 19:00Z-20:00Z 20:00Z-21:00Z 21:00Z-22:00Z 22:00Z-23:00Z 23:00Z-24:00Z preferred_backup_time = "15:00Z-16:00Z" # ํ๊ตญ์๊ฐ 00:00-01:00 ์์ backup_retention_period = 7 log_backup_retention_period = 7 #enable_backup_log = ture ################# # Rds public endpoint Connection ################# #allocate_public_connection = false #port = 13306 # default 3306 #connection_prefix = "dev-rds-demo" ################# # Rds Database account ################# type = "Normal" privilege = "ReadWrite" #default ReadOnly account_name = "megazone" password = "test123!@#" ################# # Rds Database ################# databases = [ { name = "dbuserv1" character_set = "utf8" description = "db1" }, { name = "dbuserv2" character_set = "utf8" description = "db2" } ] }
- engine : DB ์์ง ๊ธฐ์
- engine_version : DB ๋ฒ์ ๊ธฐ์
- instance_type : DB ์คํ ๊ธฐ์
- instance_storage : DB ์ ์ฅ์ ์ฉ๋ ๊ธฐ์
- instance_charge_type : ๊ฐ๊ฒฉ ์ ์ฑ ์ ๋ํ ๋ด์ฉ ๊ธฐ์
- instance_name : DB ์ด๋ฆ ๊ธฐ์
- security_group_ids : DB์์ ์ฌ์ฉํ ๋ณด์๊ทธ๋ฃน ๋ฑ๋ก (ํ์ x)
- vswitch_id : DB์์ ์ฌ์ฉํ vswitch๋ฅผ local.azs[0]๋ก ์ ํ
- security_ips : DB์ ์ ์์ด ๊ฐ๋ฅํ ๋คํธ์ํฌ ์ค์ . local."subnet" ์ผ๋ก ์ ํ
- master_zone : ๋ง์คํฐ zone ์ ํ
- slave_zone : ์คํ ๋ฐ์ด zone ์ ํ ์ํ๋ zone์ด ๋ฐ๋ก์์ ๊ฒฝ์ฐ, "auto"์ฌ์ฉ๊ฐ๋ฅ
- ๋ฐฑ์
์ฌ๋ถ ์ค์
- preferred_backup_period : ๋ฐฑ์ ๋ ์ง๋ฅผ ["",""] ํํ๋ก ๊ธฐ์
- preferred_backup_time : ๋ฐฑ์ ์๊ฐ์ UTC ๊ธฐ์ค์ผ๋ก ๊ธฐ์ (ex :15:00z-16:00z์ผ ๊ฒฝ์ฐ ํ๊ตญ์๊ฐ 00:00-01:00)
- backup_retention_period : ๋ฐฑ์ ์ ์ง ๊ธฐ๊ฐ ์ค์
- log_backup_retention_period : ๋ก๊ทธ ๋ฐฑ์ ๊ธฐ๊ฐ ์ค์
- enable_backup_log : ๋ฐฑ์ ๋ก๊ทธ ํ์ฑํ ์ฌ๋ถ ๊ธฐ์
- ์ธ๋ถ ์ ์ ์ฌ๋ถ ์ค์
- allocate_public_connection : public endpoint ์ฌ์ฉ์ฌ๋ถ ๊ธฐ์
- port : ์ธ๋ถ์์ ์ ์ํ ํฌํธ ๊ธฐ์ . ๊ธฐ๋ณธ๊ฐ์ DB engine๊ณผ ๋์ผ
- connection_prefix : ์ฐ๊ฒฐ์ ์ํ prefix ๊ธฐ์
- DB ๊ณ์ ์ค์
- type : ๊ณ์ ์ ํ ์ค์
- privilege : ๊ถํ ์ค์
- account_name : ๊ณ์ ์ด๋ฆ ๊ธฐ์
- password : ์ํธ ๊ธฐ์
- database ์์ฑ ์ค์
- name : database ์ด๋ฆ ๊ธฐ์
- character_set : ์ฌ์ฉํ character_set ์ ํ
- description : ์ค๋ช ๊ธฐ์
RDS ์์ฑ code ์ฐธ๊ณ : modules/rds ํด๋ ์ฐธ๊ณ
STEP 1์์ Module์ ์ด์ฉํด์ ๋ฐฐํฌํ ์๋น์ค๋ฅผ ํ๋์ฉ ํ์ธ์ ํ๋ฉฐ, ์ํ๋๋ฐ๋ก ์๋น์ค๊ฐ ๊ตฌ์ฑ์ด๋์๋์ง ํ์ธ์ ํฉ๋๋ค.
Terraform Module์ ์คํ์ ํ๋ ค๋ฉด modules๊ณผ test code๋ฅผ ๋ค์ด์ ๋ฐ์์ผํฉ๋๋ค. linux์ ๊ฒฝ์ฐ ์๋์ ๊ฐ์ด ๋ค์ด๋ก๋ ํ ์ฌ์ฉ์ ํฉ๋๋ค.
wget https://github.com/seodea/terraform-alicloud-module/archive/refs/heads/main.zip
unzip main.zip
cd terraform-alicloud-module-main/02.test_code/
ํด๋น ํด๋์ ์๋ main_code.tf์๋ ๋ฐ๋ก ์ฌ์ฉ์ด ๊ฐ๋ฅํ๊ฒ ๋ณ์๊ฐ์ด ๊ธฐ์ ์ด ๋์ด์์ต๋๋ค. ๋ง์ฝ, ์์ ์ด ํ์ํ์ ๋ถ๋ถ์ด ์์ผ๋ฉด ์ต์ํ์ผ๋ก ์์ ์ผ๋ก ๋ฐ๋ก ์ฌ์ฉ์ด ๊ฐ๋ฅํฉ๋๋ค.
- terraform plan์ ์งํํฉ๋๋ค.
[root@sdh-tf-vm dev]# terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
module.was_instances.data.alicloud_instance_types.default: Refreshing state...
module.web_instances.data.alicloud_instance_types.default: Refreshing state...
module.web_instances.data.alicloud_images.images: Refreshing state...
module.was_instances.data.alicloud_images.images: Refreshing state...
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# module.dev_internal_slb.alicloud_slb.slb_instance will be created
+ resource "alicloud_slb" "slb_instance" {
+ address = (known after apply)
+ address_type = "intranet"
+ delete_protection = "off"
+ id = (known after apply)
+ instance_charge_type = "PostPaid"
+ internet = (known after apply)
+ master_zone_id = "cn-shanghai-a"
+ name = "internal-slb"
+ resource_group_id = (known after apply)
+ slave_zone_id = "cn-shanghai-b"
+ specification = "slb.s1.small"
+ vswitch_id = (known after apply)
}
# module.dev_internal_slb.alicloud_slb_listener.this[0] will be created
+ resource "alicloud_slb_listener" "this" {
+ acl_status = "off"
+ backend_port = 1234
+ delete_protection_validation = false
...
Plan: 42 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
์ด์์ด ์์ ๊ฒฝ์ฐ, ์์ฑ์ด๋ ๋ณ๊ฒฝ์ด ๋๋ ๋ด์ฉ์ ๋ํด์ ๋์ด์ด ๋ฉ๋๋ค.
VPC, vSwitch, ECS, SG, SLB, RDS๋ฅผ ๋ชจ๋ ์์ฑ์ ํ๋๋ฐ ์ด 42๊ฐ๊ฐ ์ถ๊ฐ๊ฐ ๋๋ค๋ ๋ด์ฉ์ ๋๋ค.
- terraform apply
์๋น์ค ์์ฑ์ ํ๊ธฐ์ํด์๋ terraform apply๋ฅผ ์งํํด์ผ ํฉ๋๋ค. "yes"๋ฅผ ๊ธฐ์ ์ ํ๋ฉด ์ค์น๊ฐ ์งํ๋ฉ๋๋ค.
...
Plan: 42 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
- ์๋ฃ
์ ์์ ์ผ๋ก ์ค์น๊ฐ ๋๋๋ฉด, output.tf์ ๊ธฐ์ ํ ๋ด์ฉ์ด ์ถ๋ ฅ์ด๋๋ฉด์ ํ์ธ์ด ๊ฐ๋ฅํฉ๋๋ค. output.tf ํ์ผ์ ๋ณด๋ค ์์ธํ ๋ด์ฉ์ ๊ธฐ์ ์ ํ๋ฉด console์ ์ ์์ ํ์ง ์๋๋ผ๋ ๋ฐ๋ก ์ ์์ด ๊ฐ๋ฅํฉ๋๋ค.
...
module.mysql.alicloud_db_account_privilege.this[0]: Creating...
module.mysql.alicloud_db_backup_policy.this: Creation complete after 4s [id=rm-6nn14hi97t3q6uy41]
module.mysql.alicloud_db_account_privilege.this[0]: Creation complete after 2s [id=rm-6nn14hi97t3q6uy41:megazone:ReadWrite]
Apply complete! Resources: 42 added, 0 changed, 0 destroyed.
Outputs:
db_info = {
"dev_rds_info" = {
"dev-rds" = "rm-6nn14hi97t3q6uy41"
}
}
public_sg_info = {
"sg_id" = "sg-uf60ox6w6y6nu1tawwby"
}
vpc_info = {
"database_cidr" = "172.16.2.0/24,172.16.102.0/24"
"database_subnet_names" = "tf-dev-private-VS-cn-shanghai-a,tf-dev-private-VS-cn-shanghai-b"
"db_info_map" = {
"cn-shanghai-a" = "vsw-uf6djygf20uom2e2p3bpe"
"cn-shanghai-b" = "vsw-uf600qsqqhgjsh92id2pu"
}
"private_cidr" = "172.16.1.0/24,172.16.101.0/24"
"private_info_map" = {
"cn-shanghai-a" = "vsw-uf6aef4bgrt8inqll6p84"
"cn-shanghai-b" = "vsw-uf6x9bzs0umxwb2cml6am"
}
"public_cidr" = "172.16.0.0/24,172.16.100.0/24"
"public_info_map" = {
"cn-shanghai-a" = "vsw-uf6povif61u381tbhqtk9"
"cn-shanghai-b" = "vsw-uf6fyue70yoi1oyj149al"
}
"vpc_cidr_block" = "172.16.0.0/16"
"vpc_id" = "vpc-uf64u85w98gbz19sqecyc"
}
was_instances = {
"ecs_ids" = "i-uf68dmrj7zr0of8lkv3d,i-uf65dnhz2h1irgcsbhll"
"eip_addresses" = ""
"hostname_list" = "was-01,was-02"
}
was_sg_info = {
"sg_id" = "sg-uf6alfqlbdk6ixvbi47y"
}
web_instances = {
"ecs_ids" = "i-uf636kjjx58o39mzyp83,i-uf6i1r3ycwoiabd94bbp"
"eip_addresses" = "106.14.251.20,106.14.240.47"
"hostname_list" = "web-01,web-02"
}
๋ชจ๋ ์ ์์ ์ผ๋ก ์ค์น๊ฐ ๋์์ต๋๋ค.
END