

# AWS CLI を使用した AppRegistry の例
<a name="cli_service-catalog-appregistry_code_examples"></a>

次のコードサンプルは、AppRegistry で AWS Command Line Interface を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。

**Topics**
+ [アクション](#actions)

## アクション
<a name="actions"></a>

### `associate-attribute-group`
<a name="service-catalog-appregistry_AssociateAttributeGroup_cli_topic"></a>

次のコード例は、`associate-attribute-group` を使用する方法を示しています。

**AWS CLI**  
**属性グループを関連付けるには**  
次の `associate-attribute-group` の例では、AWS アカウント内の特定の属性グループを AWS アカウント内の特定の属性グループに関連付けます。  

```
aws servicecatalog-appregistry associate-attribute-group \
    --application "ExampleApplication" \
    --attribute-group "ExampleAttributeGroup"
```
出力:  

```
{
    "applicationArn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
    "attributeGroupArn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl"
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Associating and disassociating attribute groups](https://docs.aws.amazon.com/servicecatalog/latest/arguide/associate-attr-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[AssociateAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/associate-attribute-group.html)」を参照してください。

### `create-application`
<a name="service-catalog-appregistry_CreateApplication_cli_topic"></a>

次のコード例は、`create-application` を使用する方法を示しています。

**AWS CLI**  
**アプリケーションを作成するには**  
次の `create-application` の例では、AWS アカウントに新しいアプリケーションを作成します。  

```
aws servicecatalog-appregistry create-application \
    --name "ExampleApplication"
```
出力:  

```
{
    "application": {
        "id": "0ars38r6btoohvpvd9gqrptt9l",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
        "name": "ExampleApplication",
        "creationTime": "2023-02-28T21:10:10.820000+00:00",
        "lastUpdateTime": "2023-02-28T21:10:10.820000+00:00",
        "tags": {}
    }
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Creating applications](https://docs.aws.amazon.com/servicecatalog/latest/arguide/create-apps.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/create-application.html)」を参照してください。

### `create-attribute-group`
<a name="service-catalog-appregistry_CreateAttributeGroup_cli_topic"></a>

次のコード例は、`create-attribute-group` を使用する方法を示しています。

**AWS CLI**  
**属性グループを作成するには**  
次の `create-attribute-group` の例では、AWS アカウントに新しい属性グループを作成します。  

```
aws servicecatalog-appregistry create-attribute-group \
    --name "ExampleAttributeGroup" \
    --attributes '{"SomeKey1":"SomeValue1","SomeKey2":"SomeValue2"}'
```
出力:  

```
{
    "attributeGroup": {
        "id": "01sj5xdwhbw54kejwnt09fnpcl",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
        "name": "ExampleAttributeGroup",
        "creationTime": "2023-02-28T20:38:01.389000+00:00",
        "lastUpdateTime": "2023-02-28T20:38:01.389000+00:00",
        "tags": {}
    }
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Creating attribute groups](https://docs.aws.amazon.com/servicecatalog/latest/arguide/create-attr-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/create-attribute-group.html)」を参照してください。

### `delete-application`
<a name="service-catalog-appregistry_DeleteApplication_cli_topic"></a>

次のコード例は、`delete-application` を使用する方法を示しています。

**AWS CLI**  
**アプリケーションを削除するには**  
次の `delete-application` の例では、AWS アカウント内の特定のアプリケーションを削除します。  

```
aws servicecatalog-appregistry delete-application \
    --application "ExampleApplication3"
```
出力:  

```
{
    "application": {
        "id": "055gw7aynr1i5mbv7kjwzx5945",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/055gw7aynr1i5mbv7kjwzx5945",
        "name": "ExampleApplication3",
        "creationTime": "2023-02-28T22:06:28.228000+00:00",
        "lastUpdateTime": "2023-02-28T22:06:28.228000+00:00"
    }
}
```
詳細については、「AWS Service Catalog AppRegistry 管理者ガイド」の「[Deleting applications](https://docs.aws.amazon.com/servicecatalog/latest/arguide/delete-app-details.html)」を参照してください。**  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/delete-application.html)」を参照してください。

### `delete-attribute-group`
<a name="service-catalog-appregistry_DeleteAttributeGroup_cli_topic"></a>

次のコード例は、`delete-attribute-group` を使用する方法を示しています。

**AWS CLI**  
**例 8: 属性グループを削除するには**  
次の `delete-attribute-group` の例では、AWS アカウント内の特定の属性グループを削除します。  

```
aws servicecatalog-appregistry delete-attribute-group \
    --attribute-group "ExampleAttributeGroup3"
```
出力:  

```
{
    "attributeGroup": {
        "id": "011ge6y3emyjijt8dw8jn6r0hv",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/011ge6y3emyjijt8dw8jn6r0hv",
        "name": "ExampleAttributeGroup3",
        "creationTime": "2023-02-28T22:05:35.224000+00:00",
        "lastUpdateTime": "2023-02-28T22:05:35.224000+00:00"
    }
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Deleting attribute groups](https://docs.aws.amazon.com/servicecatalog/latest/arguide/delete-attr-group.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/delete-attribute-group.html)」を参照してください。

### `get-application`
<a name="service-catalog-appregistry_GetApplication_cli_topic"></a>

次のコード例は、`get-application` を使用する方法を示しています。

**AWS CLI**  
**アプリケーションを取得するには**  
次の `get-application` の例では、AWS アカウント内の特定のアプリケーションに関するメタデータ情報を取得します。  

```
aws servicecatalog-appregistry get-application \
    --application "ExampleApplication"
```
出力:  

```
{
    "id": "0ars38r6btoohvpvd9gqrptt9l",
    "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
    "name": "ExampleApplication",
    "creationTime": "2023-02-28T21:10:10.820000+00:00",
    "lastUpdateTime": "2023-02-28T21:10:10.820000+00:00",
    "associatedResourceCount": 0,
    "tags": {
        "aws:servicecatalog:applicationName": "ExampleApplication"
    },
    "integrations": {
        "resourceGroup": {
            "state": "CREATE_COMPLETE",
            "arn": "arn:aws:resource-groups:us-west-2:813737243517:group/AWS_AppRegistry_Application-ExampleApplication"
        }
    }
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Using Application details](https://docs.aws.amazon.com/servicecatalog/latest/arguide/access-app-details.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/get-application.html)」を参照してください。

### `get-attribute-group`
<a name="service-catalog-appregistry_GetAttributeGroup_cli_topic"></a>

次のコード例は、`get-attribute-group` を使用する方法を示しています。

**AWS CLI**  
**属性グループを取得するには**  
次の `get-attribute-group` の例では、AWS アカウント内の特定の属性グループを取得します。  

```
aws servicecatalog-appregistry get-attribute-group \
    --attribute-group "ExampleAttributeGroup"
```
出力:  

```
{
    "id": "01sj5xdwhbw54kejwnt09fnpcl",
    "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
    "name": "ExampleAttributeGroup",
    "attributes": "{\"SomeKey1\":\"SomeValue1\",\"SomeKey2\":\"SomeValue2\"}",
    "creationTime": "2023-02-28T20:38:01.389000+00:00",
    "lastUpdateTime": "2023-02-28T20:38:01.389000+00:00",
    "tags": {
        "aws:servicecatalog:attributeGroupName": "ExampleAttributeGroup"
    }
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[属性グループのメタデータの管理](https://docs.aws.amazon.com/servicecatalog/latest/arguide/manage-metatdata.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/get-attribute-group.html)」を参照してください。

### `list-applications`
<a name="service-catalog-appregistry_ListApplications_cli_topic"></a>

次のコード例は、`list-applications` を使用する方法を示しています。

**AWS CLI**  
**アプリケーションを一覧表示するには**  
次の `list-applications` の例では、AWS アカウント内のすべてのアプリケーションのリストを取得します。  

```
aws servicecatalog-appregistry list-applications
```
出力:  

```
{
    "applications": [
        {
            "id": "03axw94pjfj3uan00tcgbrxnkw",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/03axw94pjfj3uan00tcgbrxnkw",
            "name": "ExampleApplication2",
            "creationTime": "2023-02-28T21:59:34.094000+00:00",
            "lastUpdateTime": "2023-02-28T21:59:34.094000+00:00"
        },
        {
            "id": "055gw7aynr1i5mbv7kjwzx5945",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/055gw7aynr1i5mbv7kjwzx5945",
            "name": "ExampleApplication3",
            "creationTime": "2023-02-28T22:06:28.228000+00:00",
            "lastUpdateTime": "2023-02-28T22:06:28.228000+00:00"
        },
        {
            "id": "0ars38r6btoohvpvd9gqrptt9l",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
            "name": "ExampleApplication",
            "description": "This is an example application",
            "creationTime": "2023-02-28T21:10:10.820000+00:00",
            "lastUpdateTime": "2023-02-28T21:24:19.729000+00:00"
        }
    ]
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Viewing Application details](https://docs.aws.amazon.com/servicecatalog/latest/arguide/view-app-details.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListApplications](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-applications.html)」を参照してください。

### `list-associated-attribute-groups`
<a name="service-catalog-appregistry_ListAssociatedAttributeGroups_cli_topic"></a>

次のコード例は、`list-associated-attribute-groups` を使用する方法を示しています。

**AWS CLI**  
**関連付けられた属性グループを一覧表示するには**  
次の `list-associated-attribute-groups` の例では、AWS アカウント内の特定のアプリケーションに関連付けられている AWS アカウント内のすべての属性グループのリストを取得します。  

```
aws servicecatalog-appregistry list-associated-attribute-groups \
    --application "ExampleApplication"
```
出力:  

```
{
    "attributeGroups": [
        "01sj5xdwhbw54kejwnt09fnpcl"
    ]
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Associating and disassociating attribute groups](https://https://docs.aws.amazon.com/servicecatalog/latest/arguide/associate-attr-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListAssociatedAttributeGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-associated-attribute-groups.html)」を参照してください。

### `list-attribute-groups-for-application`
<a name="service-catalog-appregistry_ListAttributeGroupsForApplication_cli_topic"></a>

次のコード例は、`list-attribute-groups-for-application` を使用する方法を示しています。

**AWS CLI**  
**アプリケーションの属性グループを一覧表示するには**  
次の `list-attribute-groups-for-application` の例では、AWS アカウント内の特定のアプリケーションに関連付けられている AWS アカウント内のすべての属性グループの詳細を一覧表示します。  

```
aws servicecatalog-appregistry list-attribute-groups-for-application \
    --application "ExampleApplication"
```
出力:  

```
{
    "attributeGroupsDetails": [
        {
            "id": "01sj5xdwhbw54kejwnt09fnpcl",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
            "name": "ExampleAttributeGroup"
        }
    ]
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Viewing attribute group details](https://servicecatalog/latest/arguide/view-attr-group.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListAttributeGroupsForApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-attribute-groups-for-application.html)」を参照してください。

### `list-attribute-groups`
<a name="service-catalog-appregistry_ListAttributeGroups_cli_topic"></a>

次のコード例は、`list-attribute-groups` を使用する方法を示しています。

**AWS CLI**  
**属性グループを一覧表示するには**  
次の `list-attribute-groups` の例では、AWS アカウント内のすべての属性グループのリストを取得します。  

```
aws servicecatalog-appregistry list-attribute-groups
```
出力:  

```
{
    "attributeGroups": [
        {
            "id": "011ge6y3emyjijt8dw8jn6r0hv",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/011ge6y3emyjijt8dw8jn6r0hv",
            "name": "ExampleAttributeGroup3",
            "creationTime": "2023-02-28T22:05:35.224000+00:00",
            "lastUpdateTime": "2023-02-28T22:05:35.224000+00:00"
        },
        {
            "id": "01sj5xdwhbw54kejwnt09fnpcl",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
            "name": "ExampleAttributeGroup",
            "description": "This is an example attribute group",
            "creationTime": "2023-02-28T20:38:01.389000+00:00",
            "lastUpdateTime": "2023-02-28T21:02:04.559000+00:00"
        },
        {
            "id": "03n1yffgq6d18vwrzxf0c70nm3",
            "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/03n1yffgq6d18vwrzxf0c70nm3",
            "name": "ExampleAttributeGroup2",
            "creationTime": "2023-02-28T21:57:30.687000+00:00",
            "lastUpdateTime": "2023-02-28T21:57:30.687000+00:00"
        }
    ]
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Viewing attribute group details](https://docs.aws.amazon.com/servicecatalog/latest/arguide/view-attr-group.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListAttributeGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/list-attribute-groups.html)」を参照してください。

### `update-application`
<a name="service-catalog-appregistry_UpdateApplication_cli_topic"></a>

次のコード例は、`update-application` を使用する方法を示しています。

**AWS CLI**  
**アプリケーションを更新するには**  
次の `update-application` の例では、AWS アカウント内の特定のアプリケーションを更新して説明を含めるようにします。  

```
aws servicecatalog-appregistry update-application \
    --application "ExampleApplication" \
    --description "This is an example application"
```
出力:  

```
{
    "application": {
        "id": "0ars38r6btoohvpvd9gqrptt9l",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/applications/0ars38r6btoohvpvd9gqrptt9l",
        "name": "ExampleApplication",
        "description": "This is an example application",
        "creationTime": "2023-02-28T21:10:10.820000+00:00",
        "lastUpdateTime": "2023-02-28T21:24:19.729000+00:00",
        "tags": {
            "aws:servicecatalog:applicationName": "ExampleApplication"
        }
    }
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Editing applications](https://docs.aws.amazon.com/servicecatalog/latest/arguide/edit-apps.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[UpdateApplication](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/update-application.html)」を参照してください。

### `update-attribute-group`
<a name="service-catalog-appregistry_UpdateAttributeGroup_cli_topic"></a>

次のコード例は、`update-attribute-group` を使用する方法を示しています。

**AWS CLI**  
**属性グループを更新するには**  
次の `update-attribute-group` の例では、AWS アカウント内の特定の属性グループを更新して、説明を含めるようにします。  

```
aws servicecatalog-appregistry update-attribute-group \
    --attribute-group "ExampleAttributeGroup" \
    --description "This is an example attribute group"
```
出力:  

```
{
    "attributeGroup": {
        "id": "01sj5xdwhbw54kejwnt09fnpcl",
        "arn": "arn:aws:servicecatalog:us-west-2:813737243517:/attribute-groups/01sj5xdwhbw54kejwnt09fnpcl",
        "name": "ExampleAttributeGroup",
        "description": "This is an example attribute group",
        "creationTime": "2023-02-28T20:38:01.389000+00:00",
        "lastUpdateTime": "2023-02-28T21:02:04.559000+00:00",
        "tags": {
            "aws:servicecatalog:attributeGroupName": "ExampleAttributeGroup"
        }
    }
}
```
詳細については、「*AWS Service Catalog AppRegistry 管理者ガイド*」の「[Editing attribute groups](https://docs.aws.amazon.com/servicecatalog/latest/arguide/edit-attr-group.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[UpdateAttributeGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/servicecatalog-appregistry/update-attribute-group.html)」を参照してください。