为以下各项设置配置包 AWS CloudFormation StackSets - AWS Control Tower

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

为以下各项设置配置包 AWS CloudFormation StackSets

本节介绍如何为设置配置包 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 策略文件。验证文件路径是否与清单文件中提供的路径相匹配。

  • 模板文件包含要部署的 AWS 资源 OUs 和帐户。

  • policy 文件包含模板文件中使用的输入参数。

以下示例显示了在步骤 1 中创建的示例清单文件的文件夹结构。

- manifest.yaml - policies/ - block-s3-public.json - templates/ - transit-gateway.template