

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# CloudFormation StackSets の設定パッケージを設定する
<a name="cfcn-byo-cfn-stacksets"></a>

このセクションでは、 CloudFormation StackSets の設定パッケージを設定する方法について説明します。このプロセスの 2 つの主要部分は、(1) マニフェストファイルの準備、(2) フォルダ構造の更新です。

## ステップ 1: 既存のマニフェストファイルを編集する
<a name="cfcn-byo-cfn-stacksets-step-1"></a>

以前に編集したマニフェストファイルに新しい CloudFormation StackSets 情報を追加します。

次のスニペットには、確認のため、SCP または RCP 用の設定パッケージをセットアップするために前述したものと同じカスタマイズされたマニフェストファイルが含まれています。このファイルをさらに編集して、リソースの詳細を含めることができるようになりました。

```
---
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}}
```

次の例は、マニフェストファイルに複数の 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: フォルダ構造を更新する
<a name="cfct-byo-cfn-stacksets-step-2"></a>

フォルダ構造を更新するときは、マニフェストファイルにあるすべてのサポート CloudFormation テンプレートファイルと SCP または RCP ポリシーファイルを含めることができます。ファイルパスがマニフェストファイルで指定したものと一致していることを確認します。
+ *テンプレート*ファイルには、OUs とアカウントにデプロイされる AWS リソースが含まれています。
+ *policy* ファイルには、テンプレートファイルで使用される入力パラメータが含まれます。

次の例は、[ステップ 1](#cfcn-byo-cfn-stacksets-step-1) で作成したサンプルマニフェストファイルのフォルダ構造を示しています。

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