(Optional) 멀티 VPC 구성
Production 환경 구성
Production 환경은 위의 파일 세팅과 동일하게 진행하여 생성하시면 됩니다.
backend.tf
와terraform.tfvars
에 있는 값만 Production에 맞게 변경해주시면 됩니다.
🚀 운영환경용 폴더 생성
앞에서 생성한
devartd_apnortheast2
폴더를 통째로 복사합니다. 그리고,.terraform
에 상태값이 저장되기 때문에, 삭제하고 다시
$ cp -R devartd_apnortheast2 devartp_apnortheast2
$ cd devartp_apnortheast2
$ rm -rf .terraform*
🚀 변수값 변경
backend.tf
에서 저장될 버킷 이름을 변경합니다. 다만, 본 실습에서는 같은 계정으로 진행하므로 변경은 생략합니다.
terraform {
required_version = ">= 1.5.7"
backend "s3" {
bucket = "devart-preprod-apnortheast2-tfstate"
key = "devart/terraform/vpc/devartp_apnortheast2/terraform.tfstate"
region = "ap-northeast-2"
encrypt = true
dynamodb_table = "terraform-lock"
}
}
terraform.tfvars
에 실제 변수값을 변경합니다.
aws_region = "ap-northeast-2"
cidr_numeral = "11"
# Please change "devart" to what you want to use
# d after name indicates develop. This means that devartd_apnortheast2 VPC is for development environment VPC in Seoul Region.
vpc_name = "devartp_apnortheast2"
# Billing tag in this VPC
billing_tag = "prod"
# Availability Zone list
availability_zones = ["ap-northeast-2a", "ap-northeast-2c"]
# In Seoul Region, some resources are not supported in ap-northeast-2b
availability_zones_without_b = ["ap-northeast-2a", "ap-northeast-2c"]
# shard_id will be used later when creating other resources.
# With shard_id, you could distinguish which environment the resource belongs to
shard_id = "devartpapne2"
shard_short_id = "devart01p"
# d means develop
env_suffix = "p"
# VPC Peering Connection Variables
# vpc_peer_connection_id_devartp_apne2 = "pcx-"
# devartp_destination_cidr_block = "10.20.0.0/16"
리소스 생성
Terraform plan / apply 를 통해서 리소스를 생성합니다. 과정은 위와 동일하므로 생략합니다.
만약, account가 다른 경우에는 해당 Account로 assume을 다시 하셔야 합니다.
Last updated
Was this helpful?