Terraform 코드형 인프라(IaC) 파일 파라미터 세부 정보 및 예제 - AWS Proton

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

Terraform 코드형 인프라(IaC) 파일 파라미터 세부 정보 및 예제

템플릿 번들의 variable.tf 파일에 Terraform 입력 변수를 포함할 수 있습니다. 스키마를 만들어 AWS Proton 관리 변수를 만들 수도 있습니다. AWS Proton 스키마 .tf files 파일에서 변수를 생성합니다. 자세한 설명은 Terraform IaC 파일 섹션을 참조하세요.

인프라에서 스키마 정의 AWS Proton 변수를 참조하려면 .tf files Terraform IAc의 매개 변수 및 AWS Proton 네임스페이스 표에 나와 있는 네임스페이스를 사용합니다. 예를 들어 var.environment.inputs.vpc_cidr를 사용할 수 있습니다. 따옴표 안에 이러한 변수를 대괄호로 묶고 첫 번째 중괄호 앞에 달러 기호를 추가합니다(예: “${var.environment.inputs.vpc_cidr}”).

다음 예제는 네임스페이스를 사용하여 환경에 매개 변수를 포함하는 방법을 보여줍니다. AWS Proton .tf file

terraform { required_providers { aws = { source = "hashicorp/aws" version = "~> 3.0" } } // This tells terraform to store the state file in s3 at the location // s3://terraform-state-bucket/tf-os-sample/terraform.tfstate backend "s3" { bucket = "terraform-state-bucket" key = "tf-os-sample/terraform.tfstate" region = "us-east-1" } } // Configure the AWS Provider provider "aws" { region = "us-east-1" default_tags { tags = var.proton_tags } } resource "aws_ssm_parameter" "my_ssm_parameter" { name = "my_ssm_parameter" type = "String" // Use the Proton environment.inputs. namespace value = var.environment.inputs.ssm_parameter_value }