AWS CLI를 사용한 VPC Lattice 예제 - AWS Command Line Interface

이 문서는 AWS CLI의 버전 1에만 해당합니다. AWS CLI의 버전 2와 관련된 문서는 버전 2 사용 설명서를 참조하세요.

AWS CLI를 사용한 VPC Lattice 예제

다음 코드 예제에서는 VPC Lattice에서 AWS Command Line Interface를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여 줍니다.

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예제에는 컨텍스트에서 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있는 전체 소스 코드에 대한 링크가 포함되어 있습니다.

주제

작업

다음 코드 예제에서는 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 사용 설명서의 리스너를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 CreateListener를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스 연결 관리를 참조하세요.

다음 코드 예제에서는 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 연결 관리를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스 네트워크를 참조하세요.

다음 코드 예제에서는 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 내 서비스를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 CreateService를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 대상 그룹을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 CreateTargetGroup을 참조하세요.

다음 코드 예제에서는 delete-auth-policy 코드를 사용하는 방법을 보여 줍니다.

AWS CLI

인증 정책을 삭제하는 방법

다음 delete-auth-policy 예제에서는 지정한 서비스에 대한 인증 정책을 삭제합니다.

aws vpc-lattice delete-auth-policy \ --resource-identifier svc-0285b53b2eEXAMPLE

이 명령은 출력을 생성하지 않습니다.

자세한 정보는 Amazon VPC Lattice 사용 설명서의 인증 정책을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 DeleteAuthPolicy 섹션을 참조하세요.

다음 코드 예제에서는 delete-listener 코드를 사용하는 방법을 보여 줍니다.

AWS CLI

리스너를 삭제하는 방법

다음 delete-listener 예제에서는 지정된 리스너를 삭제합니다.

aws vpc-lattice delete-listener \ --listener-identifier listener-07cc7fb0abEXAMPLE \ --service-identifier svc-0285b53b2eEXAMPLE

이 명령은 출력을 생성하지 않습니다.

자세한 내용은 Amazon VPC 사용 설명서의 리스너를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 DeleteListener 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스 연결 관리를 참조하세요.

다음 코드 예제에서는 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 연결 관리를 참조하세요.

다음 코드 예제에서는 delete-service-network 코드를 사용하는 방법을 보여 줍니다.

AWS CLI

서비스 네트워크를 삭제하는 방법

다음 delete-service-network 예제에서는 지정된 서비스 네트워크를 삭제합니다.

aws vpc-lattice delete-service-network \ --service-network-identifier sn-080ec7dc93EXAMPLE

이 명령은 출력을 생성하지 않습니다.

자세한 정보는 Amazon VPC Lattice 사용 설명서의 서비스 네트워크를 참조하세요.

다음 코드 예제에서는 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 내 서비스를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 DeleteService를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 대상 그룹을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 DeleteVocabulary를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 대상 등록을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 DeregisterTargets 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 인증 정책을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 GetAuthPolicy 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 라우팅 정의를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 GetListener 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스 연결 관리를 참조하세요.

다음 코드 예제에서는 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 연결 관리를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스 네트워크를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 GetServiceNetwork 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 GetService 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 대상 그룹을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 GetTargetGroup 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 라우팅 정의를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 ListListeners 섹션을 참조하세요.

다음 코드 예제에서는 list-service-network-service-associations 코드를 사용하는 방법을 보여 줍니다.

AWS CLI

서비스 연결을 나열하는 방법

다음 list-service-network-service-associations 예제에서는 지정된 서비스 네트워크에 대한 서비스 연결을 나열합니다. --query 옵션은 출력 범위를 서비스 연결의 IDs로 지정합니다.

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

출력:

[ "snsa-031fabb4d8EXAMPLE", "snsa-0e16955a8cEXAMPLE" ]

자세한 내용은 Amazon VPC Lattice 사용 설명서의 서비스 연결 관리를 참조하세요.

다음 코드 예제에서는 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 연결 관리를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스 네트워크를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 서비스를 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 ListServices를 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 대상 그룹을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조ListTargetGroups 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 대상 그룹을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 ListTargets 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 인증 정책을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 PutAuthPolicy 섹션을 참조하세요.

다음 코드 예제에서는 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 사용 설명서의 대상 등록을 참조하세요.

  • API 세부 정보는 AWS CLI 명령 참조의 RegisterTargets 섹션을 참조하세요.