

# VPC Lattice examples using AWS CLI
<a name="cli_vpc-lattice_code_examples"></a>

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

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

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

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

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

### `create-listener`
<a name="vpc-lattice_CreateListener_cli_topic"></a>

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

**AWS CLI**  
**リスナーを作成するには**  
次の `create-listener` の例では、トラフィックを指定された VPC Lattice ターゲットグループに転送するデフォルトルールを持つ HTTPS リスナーを作成します。  

```
aws vpc-lattice create-listener \
    --name my-service-listener \
    --protocol HTTPS \
    --port 443 \
    --service-identifier svc-0285b53b2eEXAMPLE \
    --default-action file://listener-config.json
```
`listener-config.json` の内容:  

```
{
    "forward": {
        "targetGroups": [
            {
                "targetGroupIdentifier": "tg-0eaa4b9ab4EXAMPLE"
            }
        ]
    }
}
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE/listener/listener-07cc7fb0abEXAMPLE",
    "defaultAction": {
        "forward": {
            "targetGroups": [
                {
                    "targetGroupIdentifier": "tg-0eaa4b9ab4EXAMPLE",
                    "weight": 100
                }
            ]
        }
    },
    "id": "listener-07cc7fb0abEXAMPLE",
    "name": "my-service-listener",
    "port": 443,
    "protocol": "HTTPS",
    "serviceArn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE",
    "serviceId": "svc-0285b53b2eEXAMPLE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[リスナー](https://docs.aws.amazon.com/vpc-lattice/latest/ug/listeners.html)」を参照してください。  
+  API の詳細については、AWS CLI コマンドリファレンスの「[CreateListener](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-listener.html)」を参照してください。**

### `create-resource-configuration`
<a name="vpc-lattice_CreateResourceConfiguration_cli_topic"></a>

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

**AWS CLI**  
**リソース構成を作成するには**  
次の `create-resource-configuration` の例では、単一の IPv4 アドレスを指定するリソース設定を作成します。  

```
aws vpc-lattice create-resource-configuration \
    --name my-resource-config \
    --type SINGLE \
    --resource-gateway-identifier rgw-0bba03f3d56060135 \
    --resource-configuration-definition 'ipResource={ipAddress=10.0.14.85}'
```
出力:  

```
{
    "allowAssociationToShareableServiceNetwork": true,
    "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourceconfiguration/rcfg-07129f3acded87625",
    "id": "rcfg-07129f3acded87625",
    "name": "my-resource-config",
    "portRanges": [
        "1-65535"
    ],
    "protocol": "TCP",
    "resourceConfigurationDefinition": {
        "ipResource": {
            "ipAddress": "10.0.14.85"
        }
    },
    "resourceGatewayId": "rgw-0bba03f3d56060135",
    "status": "ACTIVE",
    "type": "SINGLE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource configurations for VPC resources](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-configuration.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateResourceConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-resource-configuration.html)」を参照してください。

### `create-resource-gateway`
<a name="vpc-lattice_CreateResourceGateway_cli_topic"></a>

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

**AWS CLI**  
**リソースゲートウェイを作成するには**  
次の `create-resource-gateway` の例では、指定されたサブネットのリソースゲートウェイを作成します。  

```
aws vpc-lattice create-resource-gateway \
    --name my-resource-gateway \
    --vpc-identifier vpc-0bf4c2739bc05a69 \
    --subnet-ids subnet-08e8943905b63a683
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourcegateway/rgw-0bba03f3d56060135",
    "id": "rgw-0bba03f3d56060135",
    "ipAddressType": "IPV4",
    "name": "my-resource-gateway",
    "securityGroupIds": [
        "sg-087ffd596c5fe962c"
    ],
    "status": "ACTIVE",
    "subnetIds": [
        "subnet-08e8943905b63a683"
    ],
    "vpcIdentifier": "vpc-0bf4c2739bc05a694"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource gateways in VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-gateway.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateResourceGateway](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-resource-gateway.html)」を参照してください。

### `create-service-network-service-association`
<a name="vpc-lattice_CreateServiceNetworkServiceAssociation_cli_topic"></a>

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

**AWS CLI**  
**サービスの関連付けを作成するには**  
次の `create-service-network-service-association` の例では、指定されたサービスと指定されたサービスネットワークを関連付けます。  

```
aws vpc-lattice create-service-network-service-association \
    --service-identifier svc-0285b53b2eEXAMPLE \
    --service-network-identifier sn-080ec7dc93EXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetworkserviceassociation/snsa-0e16955a8cEXAMPLE",
    "createdBy": "123456789012",
    "dnsEntry": {
        "domainName": "my-lattice-service-0285b53b2eEXAMPLE.7d67968.vpc-lattice-svcs.us-east-2.on.aws",
        "hostedZoneId": "Z09127221KTH2CEXAMPLE"
    },
    "id": "snsa-0e16955a8cEXAMPLE",
    "status": "CREATE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービス関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-service-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateServiceNetworkServiceAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-service-network-service-association.html)」を参照してください。

### `create-service-network-vpc-association`
<a name="vpc-lattice_CreateServiceNetworkVpcAssociation_cli_topic"></a>

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

**AWS CLI**  
**VPC の関連付けを作成するには**  
次の `create-service-network-vpc-association` の例では、指定された vpc を指定されたサービスネットワークに関連付けます。指定されたセキュリティグループは、VPC 内のどのリソースがサービスネットワークとそのサービスにアクセスできるかを制御します。  

```
aws vpc-lattice create-service-network-vpc-association \
    --vpc-identifier vpc-0a1b2c3d4eEXAMPLE \
    --service-network-identifier sn-080ec7dc93EXAMPLE \
    --security-group-ids sg-0aee16bc6cEXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetworkvpcassociation/snva-0821fc8631EXAMPLE",
    "createdBy": "123456789012",
    "id": "snva-0821fc8631EXAMPLE",
    "securityGroupIds": [
        "sg-0aee16bc6cEXAMPLE"
    ],
    "status": "CREATE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[VPC の関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-vpc-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateServiceNetworkVpcAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-service-network-vpc-association.html)」を参照してください。

### `create-service-network`
<a name="vpc-lattice_CreateServiceNetwork_cli_topic"></a>

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

**AWS CLI**  
**サービスネットワークを作成するには**  
次の `create-service-network` の例では、指定された名前のサービスネットワークを作成します。  

```
aws vpc-lattice create-service-network \
    --name my-service-network
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetwork/sn-080ec7dc93EXAMPLE",
    "authType": "NONE",
    "id": "sn-080ec7dc93EXAMPLE",
    "name": "my-service-network"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービスネットワーク](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-networks.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateServiceNetwork](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-service-network.html)」を参照してください。

### `create-service`
<a name="vpc-lattice_CreateService_cli_topic"></a>

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

**AWS CLI**  
**サービスを作成するには**  
次の `create-service` の例では、指定された名前のサービスを作成します。  

```
aws vpc-lattice create-service \
    --name my-lattice-service
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE",
    "authType": "NONE",
    "dnsEntry": {
        "domainName": "my-lattice-service-0285b53b2eEXAMPLE.1a2b3c4.vpc-lattice-svcs.us-east-2.on.aws",
        "hostedZoneId": "Z09127221KTH2CEXAMPLE"
    },
    "id": "svc-0285b53b2eEXAMPLE",
    "name": "my-lattice-service",
    "status": "CREATE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[VPC Lattice のサービス](https://docs.aws.amazon.com/vpc-lattice/latest/ug/services.html)」を参照してください。  
+  API の詳細については、AWS CLI コマンドリファレンスの「[CreateService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-service.html)」を参照してください。**

### `create-target-group`
<a name="vpc-lattice_CreateTargetGroup_cli_topic"></a>

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

**AWS CLI**  
**例 1: INSTANCE タイプのターゲットグループを作成するには**  
次の `create-target-group` の例では、指定された名前、タイプ、および設定を持つターゲットグループを作成します。  

```
aws vpc-lattice create-target-group \
    --name my-lattice-target-group-instance \
    --type INSTANCE \
    --config file://tg-config.json
```
`tg-config.json` の内容:  

```
{
    "port": 443,
    "protocol": "HTTPS",
    "protocolVersion": "HTTP1",
    "vpcIdentifier": "vpc-f1663d9868EXAMPLE"
}
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-0eaa4b9ab4EXAMPLE",
    "config": {
        "healthCheck": {
            "enabled": true,
            "healthCheckIntervalSeconds": 30,
            "healthCheckTimeoutSeconds": 5,
            "healthyThresholdCount": 5,
            "matcher": {
                "httpCode": "200"
            },
            "path": "/",
            "protocol": "HTTPS",
            "protocolVersion": "HTTP1",
            "unhealthyThresholdCount": 2
        },
        "port": 443,
        "protocol": "HTTPS",
        "protocolVersion": "HTTP1",
        "vpcIdentifier": "vpc-f1663d9868EXAMPLE"
    },
    "id": "tg-0eaa4b9ab4EXAMPLE",
    "name": "my-lattice-target-group-instance",
    "status": "CREATE_IN_PROGRESS",
    "type": "INSTANCE"
}
```
**例 2: IP タイプのターゲットグループを作成するには**  
次の `create-target-group` の例では、指定された名前、タイプ、および設定を持つターゲットグループを作成します。  

```
aws vpc-lattice create-target-group \
    --name my-lattice-target-group-ip \
    --type IP \
    --config file://tg-config.json
```
`tg-config.json` の内容:  

```
{
    "ipAddressType": "IPV4",
    "port": 443,
    "protocol": "HTTPS",
    "protocolVersion": "HTTP1",
    "vpcIdentifier": "vpc-f1663d9868EXAMPLE"
}
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-0eaa4b9ab4EXAMPLE",
    "config": {
        "healthCheck": {
            "enabled": true,
            "healthCheckIntervalSeconds": 30,
            "healthCheckTimeoutSeconds": 5,
            "healthyThresholdCount": 5,
            "matcher": {
                "httpCode": "200"
            },
            "path": "/",
            "protocol": "HTTPS",
            "protocolVersion": "HTTP1",
            "unhealthyThresholdCount": 2
        },
        "ipAddressType": "IPV4",
        "port": 443,
        "protocol": "HTTPS",
        "protocolVersion": "HTTP1",
        "vpcIdentifier": "vpc-f1663d9868EXAMPLE"
    },
    "id": "tg-0eaa4b9ab4EXAMPLE",
    "name": "my-lattice-target-group-ip",
    "status": "CREATE_IN_PROGRESS",
    "type": "IP"
}
```
**例 3: LAMBDA タイプのターゲットグループを作成するには**  
次の `create-target-group` の例では、指定された名前、タイプ、および設定を持つターゲットグループを作成します。  

```
aws vpc-lattice create-target-group \
    --name my-lattice-target-group-lambda \
    --type LAMBDA
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-0eaa4b9ab4EXAMPLE",
    "id": "tg-0eaa4b9ab4EXAMPLE",
    "name": "my-lattice-target-group-lambda",
    "status": "CREATE_IN_PROGRESS",
    "type": "LAMBDA"
}
```
**例 4: ALB タイプのターゲットグループを作成するには**  
次の `create-target-group` の例では、指定された名前、タイプ、および設定を持つターゲットグループを作成します。  

```
aws vpc-lattice create-target-group \
    --name my-lattice-target-group-alb \
    --type ALB \
    --config file://tg-config.json
```
`tg-config.json` の内容:  

```
{
    "port": 443,
    "protocol": "HTTPS",
    "protocolVersion": "HTTP1",
    "vpcIdentifier": "vpc-f1663d9868EXAMPLE"
}
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-0eaa4b9ab4EXAMPLE",
    "config": {
        "port": 443,
        "protocol": "HTTPS",
        "protocolVersion": "HTTP1",
        "vpcIdentifier": "vpc-f1663d9868EXAMPLE"
    },
    "id": "tg-0eaa4b9ab4EXAMPLE",
    "name": "my-lattice-target-group-alb",
    "status": "CREATE_IN_PROGRESS",
    "type": "ALB"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ターゲットグループ](https://docs.aws.amazon.com/vpc-lattice/latest/ug/target-groups.html)」を参照してください。  
+  API の詳細については、AWS CLI コマンドリファレンスの「[CreateTargetGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/create-target-group.html)」を参照してください。**

### `delete-auth-policy`
<a name="vpc-lattice_DeleteAuthPolicy_cli_topic"></a>

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

**AWS CLI**  
**認証ポリシーを削除するには**  
以下の `delete-auth-policy` の例では、指定されたサービスのポリシーを削除します。  

```
aws vpc-lattice delete-auth-policy \
    --resource-identifier svc-0285b53b2eEXAMPLE
```
このコマンドでは何も出力されません。  
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[認証ポリシー](https://docs.aws.amazon.com/vpc-lattice/latest/ug/auth-policies.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteAuthPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-auth-policy.html)」を参照してください。

### `delete-listener`
<a name="vpc-lattice_DeleteListener_cli_topic"></a>

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

**AWS CLI**  
**リスナーを削除するには**  
以下の `delete-listener` 例は、指定されたリスナーを削除します。  

```
aws vpc-lattice delete-listener \
    --listener-identifier listener-07cc7fb0abEXAMPLE \
    --service-identifier svc-0285b53b2eEXAMPLE
```
このコマンドでは何も出力されません。  
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[リスナー](https://docs.aws.amazon.com/vpc-lattice/latest/ug/listeners.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteListener](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-listener.html)」を参照してください。

### `delete-resource-configuration`
<a name="vpc-lattice_DeleteResourceConfiguration_cli_topic"></a>

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

**AWS CLI**  
**リソース構成を削除するには**  
次の `delete-resource-configuration` の例では、指定されたリソース構成を削除します。  

```
aws vpc-lattice delete-resource-configuration \
    --resource-configuration-identifier rcfg-07129f3acded87625
```
このコマンドでは何も出力されません。  
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource gateways in VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-configuration.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteResourceConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-resource-configuration.html)」を参照してください。

### `delete-resource-gateway`
<a name="vpc-lattice_DeleteResourceGateway_cli_topic"></a>

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

**AWS CLI**  
**リソースゲートウェイを削除するには**  
次の `delete-resource-gateway` の例では、指定されたリソースゲートウェイを削除します。  

```
aws vpc-lattice delete-resource-gateway \
    --resource-gateway-identifier rgw-0bba03f3d56060135
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourcegateway/rgw-0bba03f3d56060135",
    "id": "rgw-0bba03f3d56060135",
    "name": "my-resource-gateway",
    "status": "DELETE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource gateways in VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-gateway.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteResourceGateway](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-resource-gateway.html)」を参照してください。

### `delete-service-network-service-association`
<a name="vpc-lattice_DeleteServiceNetworkServiceAssociation_cli_topic"></a>

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

**AWS CLI**  
**サービスの関連付けを削除するには**  
次の `delete-service-network-service-association` の例では、指定されたサービス関連付けの関連付けを解除します。  

```
aws vpc-lattice delete-service-network-service-association \
    --service-network-service-association-identifier snsa-031fabb4d8EXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetworkserviceassociation/snsa-031fabb4d8EXAMPLE",
    "id": "snsa-031fabb4d8EXAMPLE",
    "status": "DELETE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービス関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-service-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteServiceNetworkServiceAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-service-network-service-association.html)」を参照してください。

### `delete-service-network-vpc-association`
<a name="vpc-lattice_DeleteServiceNetworkVpcAssociation_cli_topic"></a>

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

**AWS CLI**  
**VPC の関連付けを削除するには**  
次の `delete-service-network-vpc-association` の例では、指定された VPC 関連付けの関連付けを解除します。  

```
aws vpc-lattice delete-service-network-vpc-association \
    --service-network-vpc-association-identifier snva-0821fc8631EXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetworkvpcassociation/snva-0821fc8631EXAMPLE",
    "id": "snva-0821fc8631EXAMPLE",
    "status": "DELETE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[VPC の関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-vpc-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteServiceNetworkVpcAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-service-network-vpc-association.html)」を参照してください。

### `delete-service-network`
<a name="vpc-lattice_DeleteServiceNetwork_cli_topic"></a>

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

**AWS CLI**  
**サービスネットワークを削除するには**  
以下の `delete-service-network` の例では、指定されたサービスネットワークを削除します。  

```
aws vpc-lattice delete-service-network \
    --service-network-identifier sn-080ec7dc93EXAMPLE
```
このコマンドでは何も出力されません。  
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービスネットワーク](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-networks.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteServiceNetwork](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-service-network.html)」を参照してください。

### `delete-service`
<a name="vpc-lattice_DeleteService_cli_topic"></a>

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

**AWS CLI**  
**サービスを削除する方法**  
次の `delete-service` の例では、指定されたサービスを削除します。  

```
aws vpc-lattice delete-service \
    --service-identifier svc-0285b53b2eEXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-west-2:123456789012:service/svc-0285b53b2eEXAMPLE",
    "id": "svc-0285b53b2eEXAMPLE",
    "name": "my-lattice-service",
    "status": "DELETE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[VPC Lattice のサービス](https://docs.aws.amazon.com/vpc-lattice/latest/ug/services.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-service.html)」を参照してください。

### `delete-target-group`
<a name="vpc-lattice_DeleteTargetGroup_cli_topic"></a>

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

**AWS CLI**  
**ターゲットグループを削除するには**  
次の `delete-target-group` の例は、指定されたターゲットグループを削除します。  

```
aws vpc-lattice delete-target-group \
    --target-group-identifier tg-0eaa4b9ab4EXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-0eaa4b9ab4EXAMPLE",
    "id": "tg-0eaa4b9ab4EXAMPLE",
    "status": "DELETE_IN_PROGRESS"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ターゲットグループ](https://docs.aws.amazon.com/vpc-lattice/latest/ug/target-groups.html)」を参照してください。  
+  API の詳細については、AWS CLI コマンドリファレンスの「[DeleteTargetGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/delete-target-group.html)」を参照してください。**

### `deregister-targets`
<a name="vpc-lattice_DeregisterTargets_cli_topic"></a>

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

**AWS CLI**  
**ターゲットの登録を解除するには**  
次の `deregister-targets` の例では、指定されたターゲットグループを指定されたターゲットグループから削除します。  

```
aws vpc-lattice deregister-targets \
    --targets i-07dd579bc5EXAMPLE \
    --target-group-identifier tg-0eaa4b9ab4EXAMPLE
```
出力:  

```
{
    "successful": [
        {
            "id": "i-07dd579bc5EXAMPLE",
            "port": 443
        }
    ],
    "unsuccessful": []
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ターゲットの登録](https://docs.aws.amazon.com/vpc-lattice/latest/ug/register-targets.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeregisterTargets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/deregister-targets.html)」を参照してください。

### `get-auth-policy`
<a name="vpc-lattice_GetAuthPolicy_cli_topic"></a>

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

**AWS CLI**  
**認証ポリシーに関する情報を取得するには**  
以下の `get-auth-policy` の例では、指定されたサービスの認証ポリシーに関する情報を取得します。  

```
aws vpc-lattice get-auth-policy \
    --resource-identifier svc-0285b53b2eEXAMPLE
```
出力:  

```
{
    "createdAt": "2023-06-07T03:51:20.266Z",
    "lastUpdatedAt": "2023-06-07T04:39:27.082Z",
    "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789012:role/my-clients\"},\"Action\":\"vpc-lattice-svcs:Invoke\",\"Resource\":\"arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE\"}]}",
    "state": "Active"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[認証ポリシー](https://docs.aws.amazon.com/vpc-lattice/latest/ug/auth-policies.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetAuthPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-auth-policy.html)」を参照してください。

### `get-listener`
<a name="vpc-lattice_GetListener_cli_topic"></a>

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

**AWS CLI**  
**サービスリスナーに関する情報を取得するには**  
以下の `get-listener` の例では、指定されたサービスの指定されたリスナーに関する情報を取得します。  

```
aws vpc-lattice get-listener \
    --listener-identifier listener-0ccf55918cEXAMPLE \
    --service-identifier svc-0285b53b2eEXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE/listener/listener-0ccf55918cEXAMPLE",
    "createdAt": "2023-05-07T05:08:45.192Z",
    "defaultAction": {
        "forward": {
            "targetGroups": [
                {
                    "targetGroupIdentifier": "tg-0ff213abb6EXAMPLE",
                    "weight": 1
                }
            ]
        }
    },
    "id": "listener-0ccf55918cEXAMPLE",
    "lastUpdatedAt": "2023-05-07T05:08:45.192Z",
    "name": "http-80",
    "port": 80,
    "protocol": "HTTP",
    "serviceArn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE",
    "serviceId": "svc-0285b53b2eEXAMPLE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ルーティングを定義する](https://docs.aws.amazon.com/vpc-lattice/latest/ug/services.html#define-routing)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetListener](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-listener.html)」を参照してください。

### `get-resource-configuration`
<a name="vpc-lattice_GetResourceConfiguration_cli_topic"></a>

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

**AWS CLI**  
**リソース構成に関する情報を取得するには**  
次の `get-resource-configuration` の例では、指定されたリソース構成に関する情報を取得します。  

```
aws vpc-lattice get-resource-configuration \
    --resource-configuration-identifier rcfg-07129f3acded87625
```
出力:  

```
{
    "allowAssociationToShareableServiceNetwork": true,
    "amazonManaged": false,
    "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourceconfiguration/rcfg-07129f3acded87625",
    "createdAt": "2025-02-01T00:57:35.871000+00:00",
    "id": "rcfg-07129f3acded87625",
    "lastUpdatedAt": "2025-02-01T00:57:46.874000+00:00",
    "name": "my-resource-config",
    "portRanges": [
        "1-65535"
    ],
    "protocol": "TCP",
    "resourceConfigurationDefinition": {
        "ipResource": {
            "ipAddress": "10.0.14.85"
        }
    },
    "resourceGatewayId": "rgw-0bba03f3d56060135",
    "status": "ACTIVE",
    "type": "SINGLE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource gateways in VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-configuration.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetResourceConfiguration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-resource-configuration.html)」を参照してください。

### `get-resource-gateway`
<a name="vpc-lattice_GetResourceGateway_cli_topic"></a>

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

**AWS CLI**  
**リソースゲートウェイに関する情報を取得するには**  
次の `get-resource-gateway` の例では、指定されたリソースゲートウェイに関する情報を取得します。  

```
aws vpc-lattice get-resource-gateway \
    --resource-gateway-identifier rgw-0bba03f3d56060135
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourcegateway/rgw-0bba03f3d56060135",
    "createdAt": "2025-02-01T00:57:33.241000+00:00",
    "id": "rgw-0bba03f3d56060135",
    "ipAddressType": "IPV4",
    "lastUpdatedAt": "2025-02-01T00:57:44.351000+00:00",
    "name": "my-resource-gateway",
    "securityGroupIds": [
        "sg-087ffd596c5fe962c"
    ],
    "status": "ACTIVE",
    "subnetIds": [
        "subnet-08e8943905b63a683"
    ],
    "vpcId": "vpc-0bf4c2739bc05a694"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource gateways in VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-gateway.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetResourceGateway](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-resource-gateway.html)」を参照してください。

### `get-service-network-service-association`
<a name="vpc-lattice_GetServiceNetworkServiceAssociation_cli_topic"></a>

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

**AWS CLI**  
**サービス関連付けに関する情報を取得するには**  
次の `get-service-network-service-association` の例では、指定されたサービス関連付けに関する情報を取得します。  

```
aws vpc-lattice get-service-network-service-association \
    --service-network-service-association-identifier snsa-031fabb4d8EXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetworkserviceassociation/snsa-031fabb4d8EXAMPLE",
    "createdAt": "2023-05-05T21:48:16.076Z",
    "createdBy": "123456789012",
    "dnsEntry": {
        "domainName": "my-lattice-service-0285b53b2eEXAMPLE.7d67968.vpc-lattice-svcs.us-east-2.on.aws",
        "hostedZoneId": "Z09127221KTH2CEXAMPLE"
    },
    "id": "snsa-031fabb4d8EXAMPLE",
    "serviceArn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE",
    "serviceId": "svc-0285b53b2eEXAMPLE",
    "serviceName": "my-lattice-service",
    "serviceNetworkArn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetwork/sn-080ec7dc93EXAMPLE",
    "serviceNetworkId": "sn-080ec7dc93EXAMPLE",
    "serviceNetworkName": "my-service-network",
    "status": "ACTIVE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービス関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-service-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetServiceNetworkServiceAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-service-network-service-association.html)」を参照してください。

### `get-service-network-vpc-association`
<a name="vpc-lattice_GetServiceNetworkVpcAssociation_cli_topic"></a>

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

**AWS CLI**  
**VPC 関連付けに関する情報を取得するには**  
次の `get-service-network-vpc-association` の例では、指定された VPC 関連付けに関する情報を取得します。  

```
aws vpc-lattice get-service-network-vpc-association \
    --service-network-vpc-association-identifier snva-0821fc8631EXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetworkvpcassociation/snva-0821fc8631EXAMPLE",
    "createdAt": "2023-06-06T23:41:08.421Z",
    "createdBy": "123456789012",
    "id": "snva-0c5dcb60d6EXAMPLE",
    "lastUpdatedAt": "2023-06-06T23:41:08.421Z",
    "securityGroupIds": [
        "sg-0aee16bc6cEXAMPLE"
    ],
    "serviceNetworkArn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetwork/sn-080ec7dc93EXAMPLE",
    "serviceNetworkId": "sn-080ec7dc93EXAMPLE",
    "serviceNetworkName": "my-service-network",
    "status": "ACTIVE",
    "vpcId": "vpc-0a1b2c3d4eEXAMPLE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[VPC の関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-vpc-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetServiceNetworkVpcAssociation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-service-network-vpc-association.html)」を参照してください。

### `get-service-network`
<a name="vpc-lattice_GetServiceNetwork_cli_topic"></a>

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

**AWS CLI**  
**サービスネットワークに関する情報を取得するには**  
次の `get-service-network` の例では、指定されたサービスネットワークに関する情報を取得します。  

```
aws vpc-lattice get-service-network \
    --service-network-identifier sn-080ec7dc93EXAMPLE
```
出力:  

```
{
   "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetwork/sn-080ec7dc93EXAMPLE",
   "authType": "AWS_IAM",
   "createdAt": "2023-05-05T15:26:08.417Z",
   "id": "sn-080ec7dc93EXAMPLE",
   "lastUpdatedAt": "2023-05-05T15:26:08.417Z",
   "name": "my-service-network",
   "numberOfAssociatedServices": 2,
   "numberOfAssociatedVPCs": 3
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービスネットワーク](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-networks.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetServiceNetwork](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-service-network.html)」を参照してください。

### `get-service`
<a name="vpc-lattice_GetService_cli_topic"></a>

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

**AWS CLI**  
**サービスに関する情報を取得するには**  
次の `get-service` の例では、指定されたサービスに関する情報を取得します。  

```
aws vpc-lattice get-service \
    --service-identifier svc-0285b53b2eEXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE",
    "authType": "AWS_IAM",
    "createdAt": "2023-05-05T21:35:29.339Z",
    "dnsEntry": {
        "domainName": "my-lattice-service-0285b53b2eEXAMPLE.7d67968.vpc-lattice-svcs.us-east-2.on.aws",
        "hostedZoneId": "Z09127221KTH2CFUOHIZH"
    },
    "id": "svc-0285b53b2eEXAMPLE",
    "lastUpdatedAt": "2023-05-05T21:35:29.339Z",
    "name": "my-lattice-service",
    "status": "ACTIVE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービス](https://docs.aws.amazon.com/vpc-lattice/latest/ug/services.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetService](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-service.html)」を参照してください。

### `get-target-group`
<a name="vpc-lattice_GetTargetGroup_cli_topic"></a>

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

**AWS CLI**  
**ターゲットグループに関する情報を取得するには**  
次の `get-target-group` の例では、ターゲットタイプが `INSTANCE` の指定されたターゲットグループに関する情報を取得します。  

```
aws vpc-lattice get-target-group \
    --target-group-identifier tg-0eaa4b9ab4EXAMPLE
```
出力:  

```
{
    "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-0eaa4b9ab4EXAMPLE",
    "config": {
        "healthCheck": {
            "enabled": true,
            "healthCheckIntervalSeconds": 30,
            "healthCheckTimeoutSeconds": 5,
            "healthyThresholdCount": 5,
            "matcher": {
                "httpCode": "200"
            },
            "path": "/",
            "protocol": "HTTPS",
            "protocolVersion": "HTTP1",
            "unhealthyThresholdCount": 2
        },
        "port": 443,
        "protocol": "HTTPS",
        "protocolVersion": "HTTP1",
        "vpcIdentifier": "vpc-f1663d9868EXAMPLE"
    },
    "createdAt": "2023-05-06T04:41:04.122Z",
    "id": "tg-0eaa4b9ab4EXAMPLE",
    "lastUpdatedAt": "2023-05-06T04:41:04.122Z",
    "name": "my-target-group",
    "serviceArns": [
        "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE"
    ],
    "status": "ACTIVE",
    "type": "INSTANCE"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ターゲットグループ](https://docs.aws.amazon.com/vpc-lattice/latest/ug/target-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetTargetGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/get-target-group.html)」を参照してください。

### `list-listeners`
<a name="vpc-lattice_ListListeners_cli_topic"></a>

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

**AWS CLI**  
**サービスリスナーを一覧表示するには**  
次の `list-listeners` 例では、指定されたサービスのリスナーを一覧表示します。  

```
aws vpc-lattice list-listeners \
    --service-identifier svc-0285b53b2eEXAMPLE
```
出力:  

```
{
    "items": [
        {
            "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE/listener/listener-0ccf55918cEXAMPLE",
            "createdAt": "2023-05-07T05:08:45.192Z",
            "id": "listener-0ccf55918cEXAMPLE",
            "lastUpdatedAt": "2023-05-07T05:08:45.192Z",
            "name": "http-80",
            "port": 80,
            "protocol": "HTTP"
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ルーティングを定義する](https://docs.aws.amazon.com/vpc-lattice/latest/ug/services.html#define-routing)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListListeners](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-listeners.html)」を参照してください。

### `list-resource-configurations`
<a name="vpc-lattice_ListResourceConfigurations_cli_topic"></a>

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

**AWS CLI**  
**リソース構成を一覧表示するには**  
次の `list-resource-configurations` の例では、リソース構成を一覧表示します。  

```
aws vpc-lattice list-resource-configurations
```
出力:  

```
{
    "items": [
        {
            "amazonManaged": false,
            "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourceconfiguration/rcfg-07129f3acded87625",
            "createdAt": "2025-02-01T00:57:35.871000+00:00",
            "id": "rcfg-07129f3acded87625",
            "lastUpdatedAt": "2025-02-01T00:57:46.874000+00:00",
            "name": "my-resource-config",
            "resourceGatewayId": "rgw-0bba03f3d56060135",
            "status": "ACTIVE",
            "type": "SINGLE"
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource configurations](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-configuration.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListResourceConfigurations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-resource-configurations.html)」を参照してください。

### `list-resource-endpoint-associations`
<a name="vpc-lattice_ListResourceEndpointAssociations_cli_topic"></a>

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

**AWS CLI**  
**VPC エンドポイントの関連付けを一覧表示するには**  
次の `list-resource-endpoint-associations` の例では、指定されたリソース構成に関連付けられている VPC エンドポイントを一覧表示します。  

```
aws vpc-lattice list-resource-endpoint-associations \
    --resource-configuration-identifier rcfg-07129f3acded87625
```
出力:  

```
{
    "items": [
        {
            "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourceendpointassociation/rea-0956a7435baf89326",
            "createdAt": "2025-02-01T00:57:38.998000+00:00",
            "id": "rea-0956a7435baf89326",
            "resourceConfigurationArn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourceconfiguration/rcfg-07129f3acded87625",
            "resourceConfigurationId": "rcfg-07129f3acded87625",
            "vpcEndpointId": "vpce-019b90d6f16d4f958",
            "vpcEndpointOwner": "123456789012"
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Manage associations for a VPC Lattice resource configuration](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-configuration-associations.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListResourceEndpointAssociations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-resource-endpoint-associations.html)」を参照してください。

### `list-resource-gateways`
<a name="vpc-lattice_ListResourceGateways_cli_topic"></a>

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

**AWS CLI**  
**リソースゲートウェイを一覧表示するには**  
次の `list-resource-gateways` の例では、リソースゲートウェイを一覧表示します。  

```
aws vpc-lattice list-resource-gateways
```
出力:  

```
{
    "items": [
        {
            "arn": "arn:aws:vpc-lattice:us-east-1:123456789012:resourcegateway/rgw-0bba03f3d56060135",
            "createdAt": "2025-02-01T00:57:33.241000+00:00",
            "id": "rgw-0bba03f3d56060135",
            "ipAddressType": "IPV4",
            "lastUpdatedAt": "2025-02-01T00:57:44.351000+00:00",
            "name": "my-resource-gateway",
            "seurityGroupIds": [
                "sg-087ffd596c5fe962c"
            ],
            "status": "ACTIVE",
            "subnetIds": [
                "subnet-08e8943905b63a683"
            ],
            "vpcIdentifier": "vpc-0bf4c2739bc05a694"
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Resource gateways in VPC Lattice](https://docs.aws.amazon.com/vpc-lattice/latest/ug/resource-gateway.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListResourceGateways](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-resource-gateways.html)」を参照してください。

### `list-service-network-service-associations`
<a name="vpc-lattice_ListServiceNetworkServiceAssociations_cli_topic"></a>

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

**AWS CLI**  
**サービス関連付けを一覧表示するには**  
次の `list-service-network-service-associations` の例では、指定されたサービスネットワークのサービス関連付けを一覧表示します。`--query` オプションは、出力をサービス関連付け ID にスコープします。  

```
aws vpc-lattice list-service-network-service-associations \
    --service-network-identifier sn-080ec7dc93EXAMPLE \
    --query items[*].id
```
出力:  

```
[
    "snsa-031fabb4d8EXAMPLE",
    "snsa-0e16955a8cEXAMPLE"
]
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービス関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-service-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListServiceNetworkServiceAssociations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-service-network-service-associations.html)」を参照してください。

### `list-service-network-vpc-associations`
<a name="vpc-lattice_ListServiceNetworkVpcAssociations_cli_topic"></a>

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

**AWS CLI**  
**VPC の関連付けを一覧表示するには**  
次の `list-service-network-vpc-associations` の例では、指定されたサービスネットワークの VPC 関連付けを一覧表示します。`--query` オプションは、出力を VPC 関連付けの ID にスコープします。  

```
aws vpc-lattice list-service-network-vpc-associations \
    --service-network-identifier sn-080ec7dc93EXAMPLE \
    --query items[*].id
```
出力:  

```
[
    "snva-0821fc8631EXAMPLE",
    "snva-0c5dcb60d6EXAMPLE"
]
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[VPC の関連付けの管理](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-vpc-associations)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListServiceNetworkVpcAssociations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-service-network-vpc-associations.html)」を参照してください。

### `list-service-network-vpc-endpoint-associations`
<a name="vpc-lattice_ListServiceNetworkVpcEndpointAssociations_cli_topic"></a>

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

**AWS CLI**  
**VPC エンドポイントの関連付けを一覧表示するには**  
次の `list-service-network-vpc-endpoint-associations` の例では、指定されたサービスネットワークに関連付けられた VPC エンドポイントを一覧表示します。  

```
aws vpc-lattice list-service-network-vpc-endpoint-associations \
    --service-network-identifier sn-0808d1748faee0c1e
```
出力:  

```
{
    "items": [
        {
            "createdAt": "2025-02-01T01:21:36.667000+00:00",
            "serviceNetworkArn": "arn:aws:vpc-lattice:us-east-1:123456789012:servicenetwork/sn-0808d1748faee0c1e",
            "state": "ACTIVE",
            "vpcEndpointId": "vpce-0cc199f605eaeace7",
            "vpcEndpointOwnerId": "123456789012"
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[Manage the associations for a VPC Lattice service network](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListServiceNetworkVpcEndpointAssociations](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-service-network-vpc-endpoint-associations.html)」を参照してください。

### `list-service-networks`
<a name="vpc-lattice_ListServiceNetworks_cli_topic"></a>

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

**AWS CLI**  
**サービスネットワークを一覧表示するには**  
次の `list-service-networks` の例では、呼び出し元のアカウントを所有または共有しているサービスネットワークを一覧表示します。`--query` オプションは、結果をサービスネットワークの Amazon リソースネーム (ARN) にスコープします。  

```
aws vpc-lattice list-service-networks \
    --query items[*].arn
```
出力:  

```
[
    "arn:aws:vpc-lattice:us-east-2:123456789012:servicenetwork/sn-080ec7dc93EXAMPLE",
    "arn:aws:vpc-lattice:us-east-2:111122223333:servicenetwork/sn-0ec4d436cfEXAMPLE"
]
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービスネットワーク](https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-networks.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListServiceNetworks](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-service-networks.html)」を参照してください。

### `list-services`
<a name="vpc-lattice_ListServices_cli_topic"></a>

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

**AWS CLI**  
**サービスを一覧表示するには**  
次の `list-services` の例では、呼び出し元のアカウントを所有または共有しているサービスを一覧表示します。`--query` オプションは、結果をサービスの Amazon リソースネーム (ARN) にスコープします。  

```
aws vpc-lattice list-services \
    --query items[*].arn
```
出力:  

```
[
    "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE",
    "arn:aws:vpc-lattice:us-east-2:111122223333:service/svc-0b8ac96550EXAMPLE"
]
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[サービス](https://docs.aws.amazon.com/vpc-lattice/latest/ug/services.html)」を参照してください。  
+  API の詳細については、AWS CLI コマンドリファレンスの「[ListServices](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-services.html)」を参照してください。**

### `list-target-groups`
<a name="vpc-lattice_ListTargetGroups_cli_topic"></a>

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

**AWS CLI**  
**ターゲットグループを一覧表示するには**  
次の `list-target-groups` の例では、ターゲットタイプが `LAMBDA` のターゲットグループを一覧表示します。  

```
aws vpc-lattice list-target-groups \
    --target-group-type LAMBDA
```
出力:  

```
{
    "items": [
        {
            "arn": "arn:aws:vpc-lattice:us-east-2:123456789012:targetgroup/tg-045c1b7d9dEXAMPLE",
            "createdAt": "2023-05-06T05:22:16.637Z",
            "id": "tg-045c1b7d9dEXAMPLE",
            "lastUpdatedAt": "2023-05-06T05:22:16.637Z",
            "name": "my-target-group-lam",
            "serviceArns": [
                "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE"
            ],
            "status": "ACTIVE",
            "type": "LAMBDA"
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ターゲットグループ](https://docs.aws.amazon.com/vpc-lattice/latest/ug/target-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListTargetGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-target-groups.html)」を参照してください。

### `list-targets`
<a name="vpc-lattice_ListTargets_cli_topic"></a>

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

**AWS CLI**  
**ターゲットグループのターゲットを一覧表示するには**  
次の `list-targets` の例は、指定されたターゲットグループのターゲットを表示します。  

```
aws vpc-lattice list-targets \
    --target-group-identifier tg-0eaa4b9ab4EXAMPLE
```
出力:  

```
{
    "items": [
        {
            "id": "i-07dd579bc5EXAMPLE",
            "port": 443,
            "status": "HEALTHY"
        },
        {
            "id": "i-047b3c9078EXAMPLE",
            "port": 443,
            "reasonCode": "HealthCheckFailed",
            "status": "UNHEALTHY"
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ターゲットグループ](https://docs.aws.amazon.com/vpc-lattice/latest/ug/target-groups.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListTargets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/list-targets.html)」を参照してください。

### `put-auth-policy`
<a name="vpc-lattice_PutAuthPolicy_cli_topic"></a>

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

**AWS CLI**  
**サービスの認証ポリシーを作成するには**  
次の `put-auth-policy` の例では、指定された IAM ロールを使用する認証されたプリンシパルからのリクエストへのアクセスを許可します。リソースは、ポリシーがアタッチされているサービスの ARN です。  

```
aws vpc-lattice put-auth-policy \
    --resource-identifier svc-0285b53b2eEXAMPLE \
    --policy file://auth-policy.json
```
`auth-policy.json` の内容:  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::123456789012:role/my-clients"
            },
            "Action": "vpc-lattice-svcs:Invoke",
            "Resource": "arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE"
        }
    ]
}
```
出力:  

```
{
    "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789012:role/my-clients\"},\"Action\":\"vpc-lattice-svcs:Invoke\",\"Resource\":\"arn:aws:vpc-lattice:us-east-2:123456789012:service/svc-0285b53b2eEXAMPLE\"}]}",
    "state": "Active"
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[認証ポリシー](https://docs.aws.amazon.com/vpc-lattice/latest/ug/auth-policies.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[PutAuthPolicy](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/put-auth-policy.html)」を参照してください。

### `register-targets`
<a name="vpc-lattice_RegisterTargets_cli_topic"></a>

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

**AWS CLI**  
**ターゲットを登録するには**  
次の `register-targets` の例では、指定されたターゲットグループに指定されたターゲットを登録します。  

```
aws vpc-lattice register-targets \
    --targets id=i-047b3c9078EXAMPLE id=i-07dd579bc5EXAMPLE \
    --target-group-identifier tg-0eaa4b9ab4EXAMPLE
```
出力:  

```
{
    "successful": [
        {
            "id": "i-07dd579bc5EXAMPLE",
            "port": 443
        }
    ],
    "unsuccessful": [
        {
            "failureCode": "UnsupportedTarget",
            "failureMessage": "Instance targets must be in the same VPC as their target group",
            "id": "i-047b3c9078EXAMPLE",
            "port": 443
        }
    ]
}
```
詳細については、「*Amazon VPC Lattice ユーザーガイド*」の「[ターゲットの登録](https://docs.aws.amazon.com/vpc-lattice/latest/ug/register-targets.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[RegisterTargets](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/vpc-lattice/register-targets.html)」を参照してください。