終止支援通知:將於 2026 年 10 月 7 日 AWS 結束對 的支援 AWS Proton。2026 年 10 月 7 日之後,您將無法再存取 AWS Proton 主控台或 AWS Proton 資源。您部署的基礎設施將保持不變。如需詳細資訊,請參閱AWS Proton 服務棄用和遷移指南。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
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 }