本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Terraform 基礎設施即程式碼 (IaC) 檔案參數詳細資訊和範例
您可以在範本套件的variable.tf
檔案中包含 Terraform 輸入變數。您也可以建立結構描述來建立 AWS Proton 受管變數。.tf files
從結構描述檔案 AWS Proton 建立變數。如需詳細資訊,請參閱Terraform IaC 檔案。
若要在基礎設施中參考結構描述定義的 AWS Proton 變數.tf files
,您可以使用 Terraform IaC 資料表的參數和命名 AWS Proton 空間中顯示的命名空間。 IaC 例如,您可以使用 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 }