本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
本節說明如何設定 AWS CloudFormation StackSets 的組態套件。此程序的兩個主要部分是:(1) 準備資訊清單檔案,以及 (2) 更新資料夾結構。
步驟 1:編輯現有的資訊清單檔案
將新的 AWS CloudFormation StackSets 資訊新增至您先前編輯的資訊清單檔案。
僅供檢閱,下列程式碼片段包含與先前顯示相同的自訂資訊清單檔案,用於設定 SCPs或 RCPs 的組態套件。現在您可以進一步編輯此檔案,以包含資源的詳細資訊。
--- region: us-east-1 version: 2021-03-15 resources: - name: block-s3-public-access description: To S3 buckets to have public access resource_file: policies/block-s3-public.json deploy_method:
scp | rcp
#Apply to the following OU(s) deployment_targets: organizational_units: #array of strings - OUName1 - OUName2
下列程式碼片段顯示已編輯的範例資訊清單檔案,其中包含resources
詳細資訊。的順序會resources
決定建立resources
相依性的執行順序。您可以根據您的業務需求編輯下列範例資訊清單檔案。
--- region:
your-home-region
version: 2021-03-15 …truncated… resources: - name: stackset-1 resource_file: templates/create-ssm-parameter-keys-1.template parameters: - parameter_key: parameter-1 parameter_value: value-1 deploy_method: stack_set deployment_targets: accounts: # array of strings, [0-9]{12} - account number or account name - 123456789123 organizational_units: #array of strings, ou ids, ou-xxxx - OuName1 - OUName2 export_outputs: - name: /org/member/test-ssm/app-id value: $[output_ApplicationId] regions: -region-name
- name: stackset-2 resource_file: s3://bucket-name/key-name parameters: - parameter_key: parameter-1 parameter_value: value-1 deploy_method: stack_set deployment_targets: accounts: # array of strings, [0-9]{12} - account number or account name - 123456789123 organizational_units: #array of strings - OuName1 - OUName2 regions: -region-name
下列範例顯示您可以在資訊清單檔案中新增多個 AWS CloudFormation 資源。
--- region: us-east-1 version: 2021-03-15 resources: - name: block-s3-public-access description: To S3 buckets to have public access resource_file: policies/block-s3-public.json deploy_method:
scp | rcp
#Apply to the following OU(s) deployment_targets: organizational_units: #array of strings - Custom - Sandbox - name: transit-network resource_file: templates/transit-gateway.template parameter_file: parameters/transit-gateway.json deploy_method: stack_set deployment_targets: accounts: # array of strings, [0-9]{12} - Prod - 123456789123 #Network organizational_units: #array of strings - Custom export_outputs: - name: /org/network/transit-gateway-id value: $[output_TransitGatewayID] regions: - us-east-1
步驟 2:更新資料夾結構
當您更新資料夾結構時,您可以包含資訊清單檔案中的所有支援 AWS CloudFormation 範本檔案和 SCP 或 RCP 政策檔案。確認檔案路徑符合資訊清單檔案中提供的內容。
-
範本檔案包含要在 OUs 和帳戶中部署 AWS 的資源。
-
政策檔案包含範本檔案中使用的輸入參數。
下列範例顯示步驟 1 中建立的範例資訊清單檔案的資料夾結構。
- manifest.yaml
- policies/
- block-s3-public.json
- templates/
- transit-gateway.template