

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

# Image Builder AWS RAM リソースのリソース共有を作成する
<a name="manage-shared-resources-share"></a>

Image Builder コンポーネント、イメージ、またはレシピを共有するには、 AWS Resource Access Manager リソース共有に追加する必要があります。リソース共有では、共有対象のリソースと、共有先のコンシューマーを指定します。

リソースを共有するには、以下のオプションを使用できます。

## オプション 1: RAM リソース共有を作成する
<a name="share-opt1-create-resource-share"></a>

RAM リソース共有を作成する時、所有しているコンポーネント、イメージ、またはレシピを 1 つのステップで共有できます。次のいずれかの方法を使用して、リソース共有を作成してください:
+ 

**コンソール**  
 AWS RAM コンソールを使用してリソース共有を作成するには、「 *AWS RAM ユーザーガイド*」の[「所有する AWS リソースの共有](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing.html#working-with-sharing-create)」を参照してください。
+ 

**AWS CLI**  
 AWS RAM コマンドラインインターフェイスを使用してリソース共有を作成するには、 で **[create-resource-share](https://docs.aws.amazon.com/cli/latest/reference/ram/create-resource-share.html)** コマンドを実行します AWS CLI。

## オプション 2: リソースポリシーを適用して既存のリソース共有に昇格する
<a name="share-opt2-promote-resource-share"></a>

リソースを共有するための 2 番目のオプションには、両方の AWS CLI でコマンドを実行する 2 つのステップがあります。最初のステップでは、 の Image Builder コマンド AWS CLI を使用して、リソースベースのポリシーを共有リソースに適用します。2 番目のステップでは、 の **[promote-resource-share-created-from-policy](https://docs.aws.amazon.com/cli/latest/reference/ram/promote-resource-share-created-from-policy.html)** AWS RAM コマンドを使用してリソースを RAM リソース共有に昇格し AWS CLI 、リソースを共有したすべてのプリンシパルに表示されるようにします。

1. 

**リソースポリシーを適用する**

   リソースポリシーを正常に適用するには、共有しているアカウントに、基礎的なリソースにアクセスする権限があることを確認する必要があります。

   該当するコマンドのリソースタイプに合ったタブを選択します。

------
#### [ Image ]

   リソースポリシーをイメージに適用して、他のユーザーがレシピのベースイメージとして使用できるようにすることができます。

   で **[put-image-policy](https://docs.aws.amazon.com/cli/latest/reference//imagebuilder/put-image-policy.html)** Image Builder コマンドを実行して AWS CLI、イメージを共有する AWS プリンシパルを識別します。

   ```
   aws imagebuilder put-image-policy --image-arn arn:aws:imagebuilder:us-west-2:123456789012:image/my-example-image/2019.12.03/1 --policy '{ "Version": "2012-10-17",		 	 	  "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": ["imagebuilder:GetImage", "imagebuilder:ListImages"], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:image/my-example-image/2019.12.03/1" ] } ] }'
   ```

------
#### [ Component ]

   クロスアカウント共有を有効にするには、リソースポリシーを適用して、コンポーネントをビルトまたはテストします。このコマンドは、他のアカウントにレシピ内のあなたのコンポーネントを使用する権限を付与します。リソースポリシーを正常に適用するには、共有しているアカウントに、プライベートリポジトリでホストされているファイルなど、共有コンポーネントによって参照されるリソースにアクセスする権限があることを確認する必要があります。

   で **[put-component-policy](https://docs.aws.amazon.com/cli/latest/reference//imagebuilder/put-component-policy.html)** Image Builder コマンドを実行して AWS CLI、コンポーネントを共有する AWS プリンシパルを識別します。

   ```
   aws imagebuilder put-component-policy --component-arn arn:aws:imagebuilder:us-west-2:123456789012:component/my-example-component/2019.12.03/1 --policy '{ "Version": "2012-10-17",		 	 	  "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetComponent", "imagebuilder:ListComponents" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:component/my-example-component/2019.12.03/1" ] } ] }'
   ```

------
#### [ Image recipe ]

   リソースポリシーをイメージレシピに適用して、クロスアカウント共有を有効にできます。このコマンドは、レシピを使用して自分のアカウントにイメージを作成する権限を他のアカウントに与えます。リソースポリシーを正常に適用するには、共有しているアカウントに、ベースイメージや選択したコンポーネントなど、レシピが参照するリソースにアクセスする権限があることを確認する必要があります。

   で **[put-image-recipe-policy](https://docs.aws.amazon.com/cli/latest/reference//imagebuilder/put-image-recipe-policy.html)** Image Builder コマンドを実行して AWS CLI、イメージを共有する AWS プリンシパルを識別します。

   ```
   aws imagebuilder put-image-recipe-policy --image-recipe-arn arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/my-example-image-recipe/2019.12.03 --policy '{ "Version": "2012-10-17",		 	 	  "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetImageRecipe", "imagebuilder:ListImageRecipes" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/my-example-image-recipe/2019.12.03" ] } ] }'
   ```

------
#### [ Container recipe ]

   リソースポリシーをコンテナレシピに適用して、クロスアカウント共有を有効にできます。このコマンドは、レシピを使用して自分のアカウントにイメージを作成する権限を他のアカウントに与えます。リソースポリシーを正常に適用するには、共有しているアカウントに、ベースイメージや選択したコンポーネントなど、レシピが参照するリソースにアクセスする権限があることを確認する必要があります。

   で **[put-container-recipe-policy](https://docs.aws.amazon.com/cli/latest/reference//imagebuilder/put-container-recipe-policy.html)** Image Builder コマンドを実行して AWS CLI、イメージを共有する AWS プリンシパルを識別します。

   ```
   aws imagebuilder put-container-recipe-policy --container-recipe-arn arn:aws:imagebuilder:us-west-2:123456789012:container-recipe/my-example-container-recipe/2021.12.03 --policy '{ "Version": "2012-10-17",		 	 	  "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "123456789012" ] }, "Action": [ "imagebuilder:GetContainerRecipe", "imagebuilder:ListContainerRecipes" ], "Resource": [ "arn:aws:imagebuilder:us-west-2:123456789012:container-recipe/my-example-container-recipe/2021.12.03" ] } ] }'
   ```

------
**注記**  
リソースの共有と共有解除に関する正しいポリシーを設定するには、`imagebuilder:put*` リソース所有者に権限が必要です。

1. 

**RAM リソース共有として昇格する**

   リソースを共有したすべてのプリンシパルがリソースを表示できるようにするには、 で **[promote-resource-share-created-from-policy](https://docs.aws.amazon.com/cli/latest/reference/ram/promote-resource-share-created-from-policy.html)** AWS RAM コマンドを実行します AWS CLI。