글로벌 변수는 다른 여러 리소스 생성 시에 자주 참조되는 값들을 모아 놓은 곳입니다. 아래의 예시는 주관적인 관점에서 모아놓은 예시이므로, 필요에 따라 추가하시면 편리하게 사용하실 수 있습니다.
추후에 사용할 때 변수들을 하나씩 넣으셔도 됩니다.
글로벌 변수 정의
먼저, var_global.tf에는 아래의 내용을 포함합니다.
Account ID
VPC(Amazon Virtual Private Cloud)
IAM(AWS Identity and Access Management)
WAF(AWS Web Application Firewall)
KMS(Amazon Key Management Service)
terraform/variables/var_global.tf
# Atlantis uservariable"atlantis_user"{ description = "The username that will be triggering atlantis commands. This will be used to name the session when assuming a role. More information - https://github.com/runatlantis/atlantis#assume-role-session-names"
default="atlantis_user"}# Account IDs# Add all account ID to here variable"account_id"{default={prod="xxxxxxxxxx" }}# Remote State that will be used when creating other resources# You can add any resource here, if you want to refer from othersvariable"remote_state"{default={# VPCvpc={dayonedapne2={region="ap-northeast-2"bucket="dayone-prod-apnortheast2-tfstate"key="dayone/terraform/vpc/dayoned_apnortheast2/terraform.tfstate" }dayonepapne2={region="ap-northeast-2"bucket="dayone-prod-apnortheast2-tfstate"key="dayone/terraform/vpc/dayonep_apnortheast2/terraform.tfstate" } }# WAF ACLwaf_web_acl_global={prod={region=""bucket=""key="" } }# AWS IAMiam={prod={region="ap-northeast-2"bucket="dayone-prod-apnortheast2-tfstate"key="dayone/terraform/iam/dayone-prod/terraform.tfstate" } }# AWS KMSkms={prod={apne2={region=""bucket=""key="" } } } }}