

# アカウントにサードパーティーのプライベート拡張機能を登録する
<a name="registry-register-private-extension"></a>

このトピックでは、アカウントで使用できるように、共有されているサードパーティーのプライベート拡張機能を登録するステップについて説明します。

**注記**  
続行する前に、プライベート拡張を登録するために必要な [IAM アクセス許可](registry-private.md#registry-register-permissions) があることを確認してください。

**共有されているプラ​​イベート拡張機能を登録するには (AWS CLI)**

1. アカウントに登録するプライベート拡張のプロジェクトパッケージを含む Amazon S3 バケットを見つけます。

1. [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/register-type.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/register-type.html) コマンドを使用して、アカウントにプライベート拡張機能を登録します。

   例えば、次のコマンドは、指定した AWS アカウント に `My::Resource::Example` リソースタイプを登録します。

   ```
   aws cloudformation register-type --type RESOURCE \
     --type-name My::Resource::Example \
     --schema-handler-package [s3 object path] --region us-west-2
   ```

   `RegisterType` は非同期オペレーションであり、登録リクエストの進行状況を追跡するために使用できる登録トークンを返します。

   ```
   {
       "RegistrationToken": "f5525280-104e-4d35-bef5-8f1fexample"
   }
   ```

   拡張がその機能の一部として AWS API を呼び出す場合は、これらの AWS API を呼び出すために必要なアクセス許可を含む IAM 実行ロールを作成し、アカウントにその実行ロールをプロビジョニングする必要があります。その後、`--execution-role-arn` オプションを使用してこの実行ロールを指定できます。CloudFormation は、その実行ロールを引き受け、リソースタイプに適切な認証情報を提供します。

   ```
   --execution-role-arn arn:aws:iam::123456789012:role/MyIAMRole
   ```

1. (オプション) 登録トークンを [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-type-registration.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/describe-type-registration.html) コマンドとともに使用して、登録リクエストの進行状況を追跡します。

   CloudFormation が登録リクエストを完了すると、リクエストの進捗ステータスが `COMPLETE` に設定されます。

   次の例では、上記の `describe-type-registration` コマンドによって返された登録トークンを使用して、登録ステータス情報を返します。

   ```
   aws cloudformation describe-type-registration \
     --registration-token f5525280-104e-4d35-bef5-8f1fexample \
     --region us-west-2
   ```

   このコマンドは、以下の出力を返します。

   ```
   {
       "ProgressStatus": "COMPLETE",
       "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Resource-Example",
       "Description": "Deployment is currently in DEPLOY_STAGE of status COMPLETED; ",
       "TypeVersionArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Resource-Example/00000001"
   }
   ```

**重要**  
登録する拡張機能がフックの場合、この次のステップが必要です。`HookInvocationStatus` プロパティには `ENABLED` を指定する必要があります。このオペレーションにより、フックのスキーマ `properties` セクションで定義されているフックのプロパティが有効になります。詳細については、「*CloudFormation フックのユーザーガイド*」の「[フック設定スキーマ構文リファレンス](https://docs.aws.amazon.com/cloudformation-cli/latest/hooks-userguide/hook-configuration-schema.html)」を参照してください。

**フックの設定データを指定するには (AWS CLI)**

1. フックの ARN を取得し、保存します。AWS マネジメントコンソール または AWS CLI を使用してフックの ARN を取得できます。詳細については、「[CloudFormation レジストリで使用可能でアクティブ化された拡張を表示する](registry-view.md)」を参照してください。

   ```
   export HOOK_TYPE_ARN="arn:aws:cloudformation:us-west-2:123456789012:type/hook/Organization-Service-Hook/"
   ```

1. [https://docs.aws.amazon.com/cli/latest/reference/cloudformation/set-type-configuration.html](https://docs.aws.amazon.com/cli/latest/reference/cloudformation/set-type-configuration.html) コマンドを使用して、構成データを指定します。`--configuration` に渡す JSON は、フックの構成スキーマに対して検証する必要があります。フックをアクティブ化するには、`HookConfiguration` セクションで `HookInvocationStatus` プロパティを `ENABLED` に設定する必要があります。

   ```
   aws cloudformation set-type-configuration \
     --configuration "{"CloudFormationConfiguration":{"HookConfiguration":{"HookInvocationStatus": "ENABLED", "FailureMode": "FAIL", "Properties":{}}}}" \
     --type-arn $HOOK_TYPE_ARN --region us-west-2
   ```

   詳細については、「*CloudFormation フックのユーザーガイド*」の「[フック設定スキーマ構文リファレンス](https://docs.aws.amazon.com/cloudformation-cli/latest/hooks-userguide/hook-configuration-schema.html)」を参照してください。