終止支援通知:將於 2026 年 10 月 7 日 AWS 結束對 的支援 AWS Proton。2026 年 10 月 7 日之後,您將無法再存取 AWS Proton 主控台或 AWS Proton 資源。您部署的基礎設施將保持不變。如需詳細資訊,請參閱AWS Proton 服務棄用和遷移指南。
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Service CloudFormation IaC 檔案參數詳細資訊和範例
您可以在服務和管道基礎設施中將參數定義為程式碼 (IaC) 檔案並加以參考。如需參數、參數類型、參數命名空間,以及如何在 IaC 檔案中使用參數的 AWS Proton 詳細說明,請參閱 AWS Proton 參數。
定義服務參數
您可以定義服務 IaC 檔案的輸入和輸出參數。
讀取服務 IaC 檔案中的參數值
您可以讀取與服務 IaC 檔案中其他資源相關的參數。您可以在參數命名空間中參考參數的名稱來讀取 AWS Proton 參數值。
-
輸入參數 – 參考 讀取服務執行個體輸入值
service_instance.inputs.。input-name -
資源參數 – 透過參考
service.name、service_instance.name和 等名稱讀取 AWS Proton 資源參數environment.name。 -
輸出參數 – 透過參考
environment.outputs.或 讀取其他資源的輸出output-nameservice_instance.components.default.outputs.。output-name
具有參數的服務 IaC 檔案範例
下列範例是來自服務 CloudFormation IaC 檔案的程式碼片段。environment.outputs. 命名空間是指來自環境 IaC 檔案的輸出。service_instance.inputs. 命名空間是指服務執行個體輸入參數。service_instance.name 屬性是指 AWS Proton 資源參數。
Resources: StoreServiceInstanceInputValue: Type: AWS::SSM::Parameter Properties: Type: String Value: "{{ service.name }} {{ service_instance.name }} {{ service_instance.inputs.my_sample_service_instance_required_input }} {{ service_instance.inputs.my_sample_service_instance_optional_input }} {{ environment.outputs.MySampleInputValue }} {{ environment.outputs.MyOtherSampleInputValue }}" # resource parameter references # input parameter references # output references to an environment infrastructure as code file Outputs: MyServiceInstanceParameter: # output definition Value: !Ref StoreServiceInstanceInputValue MyServiceInstanceRequiredInputValue: # output definition Value: "{{ service_instance.inputs.my_sample_service_instance_required_input }}" # input parameter reference MyServiceInstanceOptionalInputValue: # output definition Value: "{{ service_instance.inputs.my_sample_service_instance_optional_input }}" # input parameter reference MyServiceInstancesEnvironmentSampleOutputValue: # output definition Value: "{{ environment.outputs.MySampleInputValue }}" # output reference to an environment IaC file MyServiceInstancesEnvironmentOtherSampleOutputValue: # output definition Value: "{{ environment.outputs.MyOtherSampleInputValue }}" # output reference to an environment IaC file