Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
を使用した API Gateway の例 AWS CLI
次のコード例は、API Gateway AWS Command Line Interface で を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。
アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。
各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。
トピック
アクション
次のコード例では、create-api-key を使用する方法を示しています。
- AWS CLI
-
既存の API とステージで有効になっている API キーを作成する方法
コマンド:
aws apigateway create-api-key --name 'Dev API Key' --description 'Used for development' --enabled --stage-keys restApiId='a1b2c3d4e5',stageName='dev'-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateApiKey
」を参照してください。
-
次のコード例では、create-authorizer を使用する方法を示しています。
- AWS CLI
-
例 1: API のトークンベースの API Gateway Custom Authorizer を作成する方法
次の
create-authorizerの例では、トークンベースのオーソライザーを作成します。aws apigateway create-authorizer \ --rest-api-id1234123412\ --name 'First_Token_Custom_Authorizer' \ --typeTOKEN\ --authorizer-uri 'arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations' \ --identity-source 'method.request.header.Authorization' \ --authorizer-result-ttl-in-seconds300出力:
{ "authType": "custom", "name": "First_Token_Custom_Authorizer", "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations", "authorizerResultTtlInSeconds": 300, "identitySource": "method.request.header.Authorization", "type": "TOKEN", "id": "z40xj0" }例 2: API の Cognito ユーザープールベースの API Gateway Custom Authorizer を作成する方法
次の
create-authorizerの例では、Cognito ユーザープールベースの API Gateway Custom Authorizer を作成します。aws apigateway create-authorizer \ --rest-api-id1234123412\ --name 'First_Cognito_Custom_Authorizer' \ --typeCOGNITO_USER_POOLS\ --provider-arns 'arn:aws:cognito-idp:us-east-1:123412341234:userpool/us-east-1_aWcZeQbuD' \ --identity-source 'method.request.header.Authorization'出力:
{ "authType": "cognito_user_pools", "identitySource": "method.request.header.Authorization", "name": "First_Cognito_Custom_Authorizer", "providerARNs": [ "arn:aws:cognito-idp:us-east-1:342398297714:userpool/us-east-1_qWbZzQhzE" ], "type": "COGNITO_USER_POOLS", "id": "5yid1t" }例 3: API のリクエストベースの API Gateway Custom Authorizer を作成する方法
次の
create-authorizerの例では、リクエストベースのオーソライザーを作成します。aws apigateway create-authorizer \ --rest-api-id1234123412\ --name 'First_Request_Custom_Authorizer' \ --typeREQUEST\ --authorizer-uri 'arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations' \ --identity-source 'method.request.header.Authorization,context.accountId' \ --authorizer-result-ttl-in-seconds300出力:
{ "id": "z40xj0", "name": "First_Request_Custom_Authorizer", "type": "REQUEST", "authType": "custom", "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthFunction/invocations", "identitySource": "method.request.header.Authorization,context.accountId", "authorizerResultTtlInSeconds": 300 }-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateAuthorizer
」を参照してください。
-
次のコード例では、create-base-path-mapping を使用する方法を示しています。
- AWS CLI
-
カスタムドメイン名のベースパスマッピングを取得する方法
コマンド:
aws apigateway create-base-path-mapping --domain-namesubdomain.domain.tld--rest-api-id1234123412--stageprod--base-pathv1-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateBasePathMapping
」を参照してください。
-
次のコード例では、create-deployment を使用する方法を示しています。
- AWS CLI
-
API に設定したリソースを新しいステージにデプロイする方法
コマンド:
aws apigateway create-deployment --rest-api-id1234123412--stage-namedev--stage-description 'Development Stage' --description 'First deployment to the dev stage'API に設定したリソースを既存のステージにデプロイする方法
コマンド:
aws apigateway create-deployment --rest-api-id1234123412--stage-namedev--description 'Second deployment to the dev stage'ステージ変数を使用して、API に設定したリソースを既存のステージにデプロイする方法
aws apigateway create-deployment --rest-api-id 1234123412 --stage-name dev --description 'Third deployment to the dev stage' --variables key='value',otherKey='otherValue'
-
API の詳細については、AWS CLI コマンドリファレンスの「CreateDeployment
」を参照してください。
-
次の例は、create-domain-name-access-association を使用する方法を説明しています。
- AWS CLI
-
ドメイン名アクセスの関連付けを作成するには
次の
create-domain-name-access-associationの例では、プライベートカスタムドメイン名と VPC エンドポイントとの間にドメイン名アクセスの関連付けを作成します。aws apigateway create-domain-name-access-association \ --domain-name-arnarn:aws:apigateway:us-west-2:111122223333:/domainnames/my.private.domain.tld+abcd1234\ --access-association-sourcevpce-abcd1234efg\ --access-association-source-typeVPCE出力:
{ "domainNameAccessAssociationArn": "arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg "accessAssociationSource": "vpce-abcd1234efg", "accessAssociationSourceType": "VPCE", "domainNameArn" : "arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234" }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
-
API の詳細については、AWS CLI コマンドリファレンスの「CreateDomainNameAccessAssociation
」を参照してください。
-
次の例は、create-domain-name を使用する方法を説明しています。
- AWS CLI
-
例 1: パブリックカスタムドメイン名を作成するには
次の
create-domain-nameの例では、パブリックカスタムドメイン名を作成します。aws apigateway create-domain-name \ --domain-name 'my.domain.tld' \ --certificate-name 'my.domain.tld cert'\ --certificate-arn 'arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3'出力:
{ "domainName": "my.domain.tld", "certificateName": "my.domain.tld cert", "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3", "certificateUploadDate": "2024-10-08T11:29:49-07:00", "distributionDomainName": "abcd1234.cloudfront.net", "distributionHostedZoneId": "Z2FDTNDATAQYW2", "endpointConfiguration": { "types": [ "EDGE" ] }, "domainNameStatus": "AVAILABLE", "securityPolicy": "TLS_1_2" }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのパブリック REST API 用のカスタムドメイン名」を参照してください。
例 2: プライベートカスタムドメイン名を作成するには
次の
create-domain-nameの例では、プライベートカスタムドメイン名を作成します。aws apigateway create-domain-name \ --domain-name 'my.private.domain.tld' \ --certificate-name 'my.domain.tld cert' \ --certificate-arn 'arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3' \ --endpoint-configuration '{"types": ["PRIVATE"]}' \ --security-policy 'TLS_1_2' \ --policyfile://policy.jsonpolicy.jsonの内容:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": "*", "Action": "execute-api:Invoke", "Resource": [ "execute-api:/*" ] }, { "Effect": "Deny", "Principal": "*", "Action": "execute-api:Invoke", "Resource": [ "execute-api:/*" ], "Condition" : { "StringNotEquals": { "aws:SourceVpce": "vpce-abcd1234efg" } } } ] }出力:
{ "domainName": "my.private.domain.tld", "domainNameId": "abcd1234", "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234", "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3", "certificateUploadDate": "2024-09-10T10:31:20-07:00", "endpointConfiguration": { "types": [ "PRIVATE" ] }, "domainNameStatus": "AVAILABLE", "securityPolicy": "TLS_1_2", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\"},{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\",\"Condition\":{\"StringNotEquals\":{\"aws:SourceVpc\":\"vpc-1a2b3c4d\"}}}]}" }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのパブリック REST API 用のカスタムドメイン名」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateDomainName
」を参照してください。
-
次のコード例では、create-model を使用する方法を示しています。
- AWS CLI
-
API 用のモデルを作成する方法
コマンド:
aws apigateway create-model --rest-api-id1234123412--name 'firstModel' --description 'The First Model' --content-type 'application/json' --schema '{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "firstModel", "type": "object", "properties": { "firstProperty" : { "type": "object", "properties": { "key": { "type": "string" } } } } }'出力:
{ "contentType": "application/json", "description": "The First Model", "name": "firstModel", "id": "2rzg0l", "schema": "{ \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"title\": \"firstModel\", \"type\": \"object\", \"properties\": { \"firstProperty\" : { \"type\": \"object\", \"properties\": { \"key\": { \"type\": \"string\" } } } } }" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateModel
」を参照してください。
-
次のコード例では、create-resource を使用する方法を示しています。
- AWS CLI
-
API でリソースを作成する方法
コマンド:
aws apigateway create-resource --rest-api-id1234123412--parent-ida1b2c3--path-part 'new-resource'-
API の詳細については、AWS CLI コマンドリファレンスの「CreateResource
」を参照してください。
-
次のコード例では、create-rest-api を使用する方法を示しています。
- AWS CLI
-
API を作成する方法
コマンド:
aws apigateway create-rest-api --name 'My First API' --description 'This is my first API'既存の API から複製 API を作成する方法
コマンド:
aws apigateway create-rest-api --name 'Copy of My First API' --description 'This is a copy of my first API' --clone-from1234123412-
API の詳細については、AWS CLI コマンドリファレンスの「CreateRestApi
」を参照してください。
-
次のコード例では、create-stage を使用する方法を示しています。
- AWS CLI
-
既存のデプロイを含む API にステージを作成する方法
コマンド:
aws apigateway create-stage --rest-api-id1234123412--stage-name 'dev' --description 'Development stage' --deployment-ida1b2c3既存のデプロイとカスタムステージ変数を含む API でステージを作成する方法
コマンド:
aws apigateway create-stage --rest-api-id1234123412--stage-name 'dev' --description 'Development stage' --deployment-ida1b2c3--variables key='value',otherKey='otherValue'-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateStage
」を参照してください。
-
次のコード例では、create-usage-plan-key を使用する方法を示しています。
- AWS CLI
-
既存の API キーを使用量プランに関連付ける
コマンド:
aws apigateway create-usage-plan-key --usage-plan-ida1b2c3--key-type"API_KEY"--key-id4vq3yryqm5-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateUsagePlanKey
」を参照してください。
-
次のコード例では、create-usage-plan を使用する方法を示しています。
- AWS CLI
-
月の初めにリセットされるスロットルとクォータの制限を使用して使用量プランを作成する方法
コマンド:
aws apigateway create-usage-plan --name"New Usage Plan"--description"A new usage plan"--throttleburstLimit=10,rateLimit=5--quotalimit=500,offset=0,period=MONTH-
API の詳細については、「AWS CLI コマンドリファレンス」の「CreateUsagePlan
」を参照してください。
-
次のコード例では、delete-api-key を使用する方法を示しています。
- AWS CLI
-
API キーを削除する方法
コマンド:
aws apigateway delete-api-key --api-key8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteApiKey
」を参照してください。
-
次のコード例では、delete-authorizer を使用する方法を示しています。
- AWS CLI
-
API でカスタムオーソライザーを削除する方法
コマンド:
aws apigateway delete-authorizer --rest-api-id1234123412--authorizer-id7gkfbo-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteAuthorizer
」を参照してください。
-
次のコード例では、delete-base-path-mapping を使用する方法を示しています。
- AWS CLI
-
カスタムドメイン名のベースパスマッピングを削除する方法
コマンド:
aws apigateway delete-base-path-mapping --domain-name 'api.domain.tld' --base-path 'dev'-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteBasePathMapping
」を参照してください。
-
次のコード例では、delete-client-certificate を使用する方法を示しています。
- AWS CLI
-
クライアント証明書を削除する方法
コマンド:
aws apigateway delete-client-certificate --client-certificate-ida1b2c3-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteClientCertificate
」を参照してください。
-
次のコード例では、delete-deployment を使用する方法を示しています。
- AWS CLI
-
API のデプロイを削除する方法
コマンド:
aws apigateway delete-deployment --rest-api-id1234123412--deployment-ida1b2c3-
API の詳細については、 コマンドリファレンスAWS CLI の「DeleteDeployment
」を参照してください。
-
次の例は、delete-domain-name-access-association を使用する方法を説明しています。
- AWS CLI
-
ドメイン名アクセスの関連付けを削除するには
次の
delete-domain-name-access-associationの例では、プライベートカスタムドメイン名と VPC エンドポイントとの間のドメイン名アクセスの関連付けを削除します。aws apigateway delete-domain-name-access-association \ --domain-name-access-association-arnarn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efgこのコマンドでは何も出力されません。
詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
-
API の詳細については、AWS CLI コマンドリファレンスの「DeleteDomainNameAccessAssociation
」を参照してください。
-
次の例は、delete-domain-name を使用する方法を説明しています。
- AWS CLI
-
カスタムドメイン名を削除する方法
コマンド:
aws apigateway delete-domain-name --domain-name 'api.domain.tld'-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteDomainName
」を参照してください。
-
次のコード例では、delete-integration-response を使用する方法を示しています。
- AWS CLI
-
API で特定のリソース、メソッド、ステータスコードの統合レスポンスを削除する方法
コマンド:
aws apigateway delete-integration-response --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--status-code200-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteIntegrationResponse
」を参照してください。
-
次のコード例では、delete-integration を使用する方法を示しています。
- AWS CLI
-
API で特定のリソースとメソッドの統合を削除する方法
コマンド:
aws apigateway delete-integration --rest-api-id1234123412--resource-ida1b2c3--http-methodGET-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteIntegration
」を参照してください。
-
次のコード例では、delete-method-response を使用する方法を示しています。
- AWS CLI
-
API で特定のリソース、メソッド、ステータスコードのメソッドレスポンスを削除する方法
コマンド:
aws apigateway delete-method-response --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--status-code200-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteMethodResponse
」を参照してください。
-
次のコード例では、delete-method を使用する方法を示しています。
- AWS CLI
-
API で特定のリソースのメソッドを削除する方法
コマンド:
aws apigateway delete-method --rest-api-id1234123412--resource-ida1b2c3--http-methodGET-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteMethod
」を参照してください。
-
次のコード例では、delete-model を使用する方法を示しています。
- AWS CLI
-
特定の API でモデルを削除する方法
コマンド:
aws apigateway delete-model --rest-api-id1234123412--model-name 'customModel'-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteModel
」を参照してください。
-
次のコード例では、delete-resource を使用する方法を示しています。
- AWS CLI
-
API でリソースを削除する方法
コマンド:
aws apigateway delete-resource --rest-api-id1234123412--resource-ida1b2c3-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteResource
」を参照してください。
-
次のコード例では、delete-rest-api を使用する方法を示しています。
- AWS CLI
-
API を削除する方法
コマンド:
aws apigateway delete-rest-api --rest-api-id1234123412-
API の詳細については、AWS CLI コマンドリファレンスの「DeleteRestApi
」を参照してください。
-
次のコード例では、delete-stage を使用する方法を示しています。
- AWS CLI
-
API でインスタンスを削除する方法
コマンド:
aws apigateway delete-stage --rest-api-id1234123412--stage-name 'dev'-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteStage
」を参照してください。
-
次のコード例では、delete-usage-plan-key を使用する方法を示しています。
- AWS CLI
-
使用量プランから API キーを削除する方法
コマンド:
aws apigateway delete-usage-plan-key --usage-plan-ida1b2c3--key-id1NbjQzMReAkeEQPNAW8r3dXsU2rDD7fc7f2Sipnu-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteUsagePlanKey
」を参照してください。
-
次のコード例では、delete-usage-plan を使用する方法を示しています。
- AWS CLI
-
使用量プランを削除する方法
コマンド:
aws apigateway delete-usage-plan --usage-plan-ida1b2c3-
API の詳細については、「AWS CLI コマンドリファレンス」の「DeleteUsagePlan
」を参照してください。
-
次のコード例では、flush-stage-authorizers-cache を使用する方法を示しています。
- AWS CLI
-
ステージのすべてのオーソライザーキャッシュエントリをすべて消去する方法
コマンド:
aws apigateway flush-stage-authorizers-cache --rest-api-id1234123412--stage-namedev-
API の詳細については、「AWS CLI コマンドリファレンス」の「FlushStageAuthorizersCache
」を参照してください。
-
次のコード例では、flush-stage-cache を使用する方法を示しています。
- AWS CLI
-
API のステージのキャッシュをすべて消去する方法
次の
flush-stage-cacheの例では、ステージのキャッシュをフラッシュします。aws apigateway flush-stage-cache \ --rest-api-id1234123412\ --stage-namedevこのコマンドでは何も出力されません。
詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway での API ステージキャッシュをフラッシュする」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「FlushStageCache
」を参照してください。
-
次のコード例では、generate-client-certificate を使用する方法を示しています。
- AWS CLI
-
クライアント側 SSL 証明書を作成する方法
コマンド:
aws apigateway generate-client-certificate --description 'My First Client Certificate'-
API の詳細については、「AWS CLI コマンドリファレンス」の「GenerateClientCertificate
」を参照してください。
-
次のコード例では、get-account を使用する方法を示しています。
- AWS CLI
-
API Gateway アカウント設定を取得する方法
コマンド:
aws apigateway get-account出力:
{ "cloudwatchRoleArn": "arn:aws:iam::123412341234:role/APIGatewayToCloudWatchLogsRole", "throttleSettings": { "rateLimit": 500.0, "burstLimit": 1000 } }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetAccount
」を参照してください。
-
次のコード例では、get-api-key を使用する方法を示しています。
- AWS CLI
-
特定の API に関する情報を取得する方法
コマンド:
aws apigateway get-api-key --api-key8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk出力:
{ "description": "My first key", "enabled": true, "stageKeys": [ "a1b2c3d4e5/dev", "e5d4c3b2a1/dev" ], "lastUpdatedDate": 1456184515, "createdDate": 1456184452, "id": "8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk", "name": "My key" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetApiKey
」を参照してください。
-
次のコード例では、get-api-keys を使用する方法を示しています。
- AWS CLI
-
API キーの一覧を取得する方法
コマンド:
aws apigateway get-api-keys出力:
{ "items": [ { "description": "My first key", "enabled": true, "stageKeys": [ "a1b2c3d4e5/dev", "e5d4c3b2a1/dev" ], "lastUpdatedDate": 1456184515, "createdDate": 1456184452, "id": "8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk", "name": "My key" } ] }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetApiKeys
」を参照してください。
-
次のコード例では、get-authorizer を使用する方法を示しています。
- AWS CLI
-
API Gateway per-API Authorizer 設定を取得する方法
コマンド:
aws apigateway get-authorizer --rest-api-id1234123412--authorizer-idgfi4n3出力:
{ "authorizerResultTtlInSeconds": 300, "name": "MyAuthorizer", "type": "TOKEN", "identitySource": "method.request.header.Authorization", "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:authorizer_function/invocations", "id": "gfi4n3" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetAuthorizer
」を参照してください。
-
次のコード例では、get-authorizers を使用する方法を示しています。
- AWS CLI
-
REST API のオーソライザーの一覧を取得する方法
コマンド:
aws apigateway get-authorizers --rest-api-id1234123412出力:
{ "items": [ { "name": "MyAuthorizer", "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:My_Authorizer_Function/invocations", "authorizerResultTtlInSeconds": 300, "identitySource": "method.request.header.Authorization", "type": "TOKEN", "id": "gfi4n3" } ] }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetAuthorizers
」を参照してください。
-
次のコード例では、get-base-path-mapping を使用する方法を示しています。
- AWS CLI
-
カスタムドメイン名のベースパスマッピングを取得する方法
コマンド:
aws apigateway get-base-path-mapping --domain-namesubdomain.domain.tld--base-pathv1出力:
{ "basePath": "v1", "restApiId": "1234w4321e", "stage": "api" }-
API の詳細については、AWS CLI コマンドリファレンスの「GetBasePathMapping
」を参照してください。
-
次のコード例では、get-base-path-mappings を使用する方法を示しています。
- AWS CLI
-
カスタムドメイン名のベースパスマッピングを取得する方法
コマンド:
aws apigateway get-base-path-mappings --domain-namesubdomain.domain.tld出力:
{ "items": [ { "basePath": "(none)", "restApiId": "1234w4321e", "stage": "dev" }, { "basePath": "v1", "restApiId": "1234w4321e", "stage": "api" } ] }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetBasePathMappings
」を参照してください。
-
次のコード例では、get-client-certificate を使用する方法を示しています。
- AWS CLI
-
クライアント証明書を取得する方法
コマンド:
aws apigateway get-client-certificate --client-certificate-ida1b2c3-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetClientCertificate
」を参照してください。
-
次のコード例では、get-client-certificates を使用する方法を示しています。
- AWS CLI
-
クライアント証明書の一覧を取得する方法
コマンド:
aws apigateway get-client-certificates出力:
{ "items": [ { "pemEncodedCertificate": "-----BEGIN CERTIFICATE----- <certificate content> -----END CERTIFICATE-----", "clientCertificateId": "a1b2c3", "expirationDate": 1483556561, "description": "My Client Certificate", "createdDate": 1452020561 } ] }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetClientCertificates
」を参照してください。
-
次のコード例では、get-deployment を使用する方法を示しています。
- AWS CLI
-
デプロイの情報を取得する方法
コマンド:
aws apigateway get-deployment --rest-api-id1234123412--deployment-idztt4m2出力:
{ "description": "myDeployment", "id": "ztt4m2", "createdDate": 1455218022 }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetDeployment
」を参照してください。
-
次のコード例では、get-deployments を使用する方法を示しています。
- AWS CLI
-
REST API のデプロイの一覧を取得する方法
コマンド:
aws apigateway get-deployments --rest-api-id1234123412出力:
{ "items": [ { "createdDate": 1453797217, "id": "0a2b4c", "description": "Deployed my API for the first time" } ] }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetDeployments
」を参照してください。
-
次の例は、get-domain-name-access-associations を使用する方法を説明しています。
- AWS CLI
-
例 1: すべてのドメイン名アクセスの関連付けを一覧表示するには
次の
get-domain-name-access-associationsの例では、すべてのドメイン名アクセスの関連付けを一覧表示します。aws apigateway get-domain-name-access-associations出力:
{ "items": [ { "domainNameAccessAssociationArn": "arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg "accessAssociationSource": "vpce-abcd1234efg", "accessAssociationSourceType": "VPCE", "domainNameArn" : "arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234" } ] }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
例 2: この AWS アカウントが所有するすべてのドメイン名アクセスの関連付けを一覧表示するには
次の の
get-domain-name-access-associations例では、現在の AWS アカウントが所有するすべてのドメイン名アクセスの関連付けを一覧表示します。aws apigateway get-domain-name-access-associations \ --resource-ownerSELF出力:
{ "items": [ { "domainNameAccessAssociationArn": "arn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg "accessAssociationSource": "vpce-abcd1234efg", "accessAssociationSourceType": "VPCE", "domainNameArn" : "arn:aws:apigateway:us-west-2:111122223333:/domainnames/private.example.com+abcd1234" } ] }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
-
API の詳細については、AWS CLI コマンドリファレンスの「GetDomainNameAccessAssociations
」を参照してください。
-
次の例は、get-domain-name を使用する方法を説明しています。
- AWS CLI
-
例 1: パブリックカスタムドメイン名に関する情報を取得するには
次の
get-domain-nameの例では、パブリックカスタムドメイン名に関する情報を取得します。aws apigateway get-domain-name \ --domain-nameapi.domain.tld出力:
{ "domainName": "api.domain.tld", "distributionDomainName": "d1a2f3a4c5o6d.cloudfront.net", "certificateName": "uploadedCertificate", "certificateUploadDate": 1462565487 }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのパブリック REST API 用のカスタムドメイン名」を参照してください。
例 2: プライベートカスタムドメイン名に関する情報を取得するには
次の
get-domain-nameの例では、プライベートカスタムドメイン名に関する情報を取得します。aws apigateway get-domain-name \ --domain-nameapi.private.domain.tld\ --domain-name-idabcd1234出力:
{ "domainName": "my.private.domain.tld", "domainNameId": "abcd1234", "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234", "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3", "certificateUploadDate": "2024-09-10T10:31:20-07:00", "endpointConfiguration": { "types": [ "PRIVATE" ] }, "domainNameStatus": "AVAILABLE", "securityPolicy": "TLS_1_2", "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\"},{\"Effect\":\"Deny\",\"Principal\":\"*\",\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234\",\"Condition\":{\"StringNotEquals\":{\"aws:SourceVpc\":\"vpc-1a2b3c4d\"}}}]}" }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのパブリック REST API 用のカスタムドメイン名」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetDomainName
」を参照してください。
-
次の例は、get-domain-names を使用する方法を説明しています。
- AWS CLI
-
例 1: カスタムドメイン名のリストを取得するには
次の
get-domain-namesコマンドは、ドメイン名のリストを取得します。aws apigateway get-domain-names出力:
{ "items": [ { "distributionDomainName": "d9511k3l09bkd.cloudfront.net", "certificateUploadDate": 1452812505, "certificateName": "my_custom_domain-certificate", "domainName": "subdomain.domain.tld" } ] }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
例 2: この AWS アカウントが所有するカスタムドメイン名のリストを取得するには
次の
get-domain-namesコマンドは、この AWS アカウントが所有するドメイン名のリストを取得します。aws apigateway get-domain-names \ --resource-ownerSELF出力:
{ "items": [ { "domainName": "my.domain.tld", "domainNameArn": "arn:aws:apigateway:us-east-1::/domainnames/my.private.domain.tld", "certificateUploadDate": "2024-08-15T17:02:55-07:00", "regionalDomainName": "d-abcd1234.execute-api.us-east-1.amazonaws.com", "regionalHostedZoneId": "Z1UJRXOUMOOFQ8", "regionalCertificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3", "endpointConfiguration": { "types": [ "REGIONAL" ] }, "domainNameStatus": "AVAILABLE", "securityPolicy": "TLS_1_2" }, { "domainName": "my.private.domain.tld", "domainNameId": "abcd1234", "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234", "certificateArn": "arn:aws:acm:us-east-1:012345678910:certificate/fb1b9770-a305-495d-aefb-27e5e101ff3", "certificateUploadDate": "2024-11-26T11:44:40-08:00", "endpointConfiguration": { "types": [ "PRIVATE" ] }, "domainNameStatus": "AVAILABLE", "securityPolicy": "TLS_1_2" } ] }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
例 3: ドメイン名アクセスの関連付けを作成できる他の AWS アカウントが所有するカスタムドメイン名のリストを取得するには。
次の
get-domain-namesコマンドは、ドメイン名アクセスの関連付けを作成するためにアクセスできる他の AWS アカウントが所有するドメイン名のリストを取得します。aws apigateway get-domain-names \ --resource-ownerOTHER_ACCOUNTS出力:
{ "items": [ { "domainName": "my.private.domain.tld", "domainNameId": "abcd1234", "domainNameArn": "arn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234" } ] }詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetDomainNames
」を参照してください。
-
次のコード例では、get-export を使用する方法を示しています。
- AWS CLI
-
ステージの JSON Swagger テンプレートを取得するには
コマンド:
aws apigateway get-export --rest-api-ida1b2c3d4e5--stage-namedev--export-typeswagger/path/to/filename.jsonステージの JSON Swagger テンプレート + API Gateway Extentions を取得する方法
コマンド:
aws apigateway get-export --parameters extensions='integrations' --rest-api-ida1b2c3d4e5--stage-namedev--export-typeswagger/path/to/filename.jsonステージの JSON Swagger テンプレート + Postman Extensions を取得する方法
コマンド:
aws apigateway get-export --parameters extensions='postman' --rest-api-ida1b2c3d4e5--stage-namedev--export-typeswagger/path/to/filename.json-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetExport
」を参照してください。
-
次のコード例では、get-integration-response を使用する方法を示しています。
- AWS CLI
-
REST API のリソースで定義された HTTP メソッドの統合レスポンス構成を取得する方法
コマンド:
aws apigateway get-integration-response --rest-api-id1234123412--resource-idy9h6rt--http-methodGET--status-code200出力:
{ "statusCode": "200", "responseTemplates": { "application/json": null } }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetIntegrationResponse
」を参照してください。
-
次のコード例では、get-integration を使用する方法を示しています。
- AWS CLI
-
REST API のリソースで定義された HTTP メソッドの統合構成を取得する方法
コマンド:
aws apigateway get-integration --rest-api-id1234123412--resource-idy9h6rt--http-methodGET出力:
{ "httpMethod": "POST", "integrationResponses": { "200": { "responseTemplates": { "application/json": null }, "statusCode": "200" } }, "cacheKeyParameters": [], "type": "AWS", "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:My_Function/invocations", "cacheNamespace": "y9h6rt" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetIntegration
」を参照してください。
-
次のコード例では、get-method-response を使用する方法を示しています。
- AWS CLI
-
REST API のリソースで定義された HTTP メソッドのメソッドレスポンスリソース構成を取得する方法
コマンド:
aws apigateway get-method-response --rest-api-id1234123412--resource-idy9h6rt--http-methodGET--status-code200出力:
{ "responseModels": { "application/json": "Empty" }, "statusCode": "200" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetMethodResponse
」を参照してください。
-
次のコード例では、get-method を使用する方法を示しています。
- AWS CLI
-
REST API のリソースで定義された HTTP メソッドのメソッドリソース構成を取得する方法
コマンド:
aws apigateway get-method --rest-api-id1234123412--resource-idy9h6rt--http-methodGET出力:
{ "apiKeyRequired": false, "httpMethod": "GET", "methodIntegration": { "integrationResponses": { "200": { "responseTemplates": { "application/json": null }, "statusCode": "200" } }, "cacheKeyParameters": [], "uri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:My_Function/invocations", "httpMethod": "POST", "cacheNamespace": "y9h6rt", "type": "AWS" }, "requestParameters": {}, "methodResponses": { "200": { "responseModels": { "application/json": "Empty" }, "statusCode": "200" } }, "authorizationType": "NONE" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetMethod
」を参照してください。
-
次のコード例では、get-model-template を使用する方法を示しています。
- AWS CLI
-
REST API で定義されたモデルのマッピングテンプレートを取得する方法
コマンド:
aws apigateway get-model-template --rest-api-id1234123412--model-nameEmpty出力:
{ "value": "#set($inputRoot = $input.path('$'))\n{ }" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetModelTemplate
」を参照してください。
-
次のコード例では、get-model を使用する方法を示しています。
- AWS CLI
-
REST API で定義されたモデルの構成を取得する方法
コマンド:
aws apigateway get-model --rest-api-id1234123412--model-nameEmpty出力:
{ "contentType": "application/json", "description": "This is a default empty schema model", "name": "Empty", "id": "etd5w5", "schema": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"title\" : \"Empty Schema\",\n \"type\" : \"object\"\n}" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetModel
」を参照してください。
-
次のコード例では、get-models を使用する方法を示しています。
- AWS CLI
-
REST API のリソースの一覧を取得する方法
コマンド:
aws apigateway get-models --rest-api-id1234123412出力:
{ "items": [ { "description": "This is a default error schema model", "schema": "{\n \"$schema\" : \"http://json-schema.org/draft-04/schema#\",\n \"title\" : \"Error Schema\",\n \"type\" : \"object\",\n \"properties\" : {\n \"message\" : { \"type\" : \"string\" }\n }\n}", "contentType": "application/json", "id": "7tpbze", "name": "Error" }, { "description": "This is a default empty schema model", "schema": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"title\" : \"Empty Schema\",\n \"type\" : \"object\"\n}", "contentType": "application/json", "id": "etd5w5", "name": "Empty" } ] }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetModels
」を参照してください。
-
次のコード例では、get-resource を使用する方法を示しています。
- AWS CLI
-
リソースに関する情報を取得する方法
コマンド:
aws apigateway get-resource --rest-api-id1234123412--resource-idzwo0y3出力:
{ "path": "/path", "pathPart": "path", "id": "zwo0y3", "parentId": "uyokt6ij2g" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetResource
」を参照してください。
-
次のコード例では、get-resources を使用する方法を示しています。
- AWS CLI
-
REST API のリソースの一覧を取得する方法
コマンド:
aws apigateway get-resources --rest-api-id1234123412出力:
{ "items": [ { "path": "/resource/subresource", "resourceMethods": { "POST": {} }, "id": "024ace", "pathPart": "subresource", "parentId": "ai5b02" } ] }-
API の詳細については、AWS CLI コマンドリファレンスの「GetResources
」を参照してください。
-
次のコード例では、get-rest-api を使用する方法を示しています。
- AWS CLI
-
API に関する情報を取得する方法
コマンド:
aws apigateway get-rest-api --rest-api-id1234123412出力:
{ "name": "myAPI", "id": "o1y243m4f5", "createdDate": 1453416433 }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetRestApi
」を参照してください。
-
次のコード例では、get-rest-apis を使用する方法を示しています。
- AWS CLI
-
REST API の一覧を取得する方法
コマンド:
aws apigateway get-rest-apis出力:
{ "items": [ { "createdDate": 1438884790, "id": "12s44z21rb", "name": "My First API" } ] }-
API の詳細については、AWS CLI コマンドリファレンスの「GetRestApis
」を参照してください。
-
次のコード例では、get-sdk を使用する方法を示しています。
- AWS CLI
-
REST API ステージの Android SDK を取得する方法
コマンド:
aws apigateway get-sdk --rest-api-id1234123412--stage-namedev--sdk-typeandroid--parameters groupId='com.mycompany',invokerPackage='com.mycompany.clientsdk',artifactId='Mycompany-client',artifactVersion='1.0.0'/path/to/android_sdk.zip出力:
{ "contentType": "application/octet-stream", "contentDisposition": "attachment; filename=\"android_2016-02-22_23-52Z.zip\"" }REST API ステージの IOS SDK を取得する方法
コマンド:
aws apigateway get-sdk --rest-api-id1234123412--stage-namedev--sdk-typeobjectivec--parameters classPrefix='myprefix'/path/to/iOS_sdk.zip出力:
{ "contentType": "application/octet-stream", "contentDisposition": "attachment; filename=\"objectivec_2016-02-22_23-52Z.zip\"" }REST API ステージの Javascript SDK を取得する方法
コマンド:
aws apigateway get-sdk --rest-api-id1234123412--stage-namedev--sdk-typejavascript/path/to/javascript_sdk.zip出力:
{ "contentType": "application/octet-stream", "contentDisposition": "attachment; filename=\"javascript_2016-02-22_23-52Z.zip\"" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetSdk
」を参照してください。
-
次のコード例では、get-stage を使用する方法を示しています。
- AWS CLI
-
API のステージに関する情報を取得する方法
コマンド:
aws apigateway get-stage --rest-api-id1234123412--stage-namedev出力:
{ "stageName": "dev", "cacheClusterSize": "0.5", "cacheClusterEnabled": false, "cacheClusterStatus": "NOT_AVAILABLE", "deploymentId": "rbh1fj", "lastUpdatedDate": 1466802961, "createdDate": 1460682074, "methodSettings": { "*/*": { "cacheTtlInSeconds": 300, "loggingLevel": "INFO", "dataTraceEnabled": false, "metricsEnabled": true, "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER", "throttlingRateLimit": 500.0, "cacheDataEncrypted": false, "cachingEnabled": false, "throttlingBurstLimit": 1000, "requireAuthorizationForCacheControl": true }, "~1resource/GET": { "cacheTtlInSeconds": 300, "loggingLevel": "INFO", "dataTraceEnabled": false, "metricsEnabled": true, "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER", "throttlingRateLimit": 500.0, "cacheDataEncrypted": false, "cachingEnabled": false, "throttlingBurstLimit": 1000, "requireAuthorizationForCacheControl": true } } }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetStage
」を参照してください。
-
次のコード例では、get-stages を使用する方法を示しています。
- AWS CLI
-
REST API のリソースの一覧を取得する方法
コマンド:
aws apigateway get-stages --rest-api-id1234123412出力:
{ "item": [ { "stageName": "dev", "cacheClusterSize": "0.5", "cacheClusterEnabled": true, "cacheClusterStatus": "AVAILABLE", "deploymentId": "123h64", "lastUpdatedDate": 1456185138, "createdDate": 1453589092, "methodSettings": { "~1resource~1subresource/POST": { "cacheTtlInSeconds": 300, "loggingLevel": "INFO", "dataTraceEnabled": true, "metricsEnabled": true, "throttlingRateLimit": 500.0, "cacheDataEncrypted": false, "cachingEnabled": false, "throttlingBurstLimit": 1000 } } } ] }-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetStages
」を参照してください。
-
次のコード例では、get-usage-plan-key を使用する方法を示しています。
- AWS CLI
-
Usage Plan に関連付けられた API キーの詳細を取得する方法
コマンド:
aws apigateway get-usage-plan-key --usage-plan-ida1b2c3--key-id1NbjQzMReAkeEQPNAW8r3dXsU2rDD7fc7f2Sipnu-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetUsagePlanKey
」を参照してください。
-
次のコード例では、get-usage-plan-keys を使用する方法を示しています。
- AWS CLI
-
使用量プランに関連付けられた API キーの一覧を取得する方法
コマンド:
aws apigateway get-usage-plan-keys --usage-plan-ida1b2c3-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetUsagePlanKeys
」を参照してください。
-
次のコード例では、get-usage-plan を使用する方法を示しています。
- AWS CLI
-
使用量プランの詳細を取得する方法
コマンド:
aws apigateway get-usage-plan --usage-plan-ida1b2c3-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetUsagePlan
」を参照してください。
-
次のコード例では、get-usage-plans を使用する方法を示しています。
- AWS CLI
-
すべての使用量プランの詳細を取得する方法
コマンド:
aws apigateway get-usage-plans-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetUsagePlans
」を参照してください。
-
次のコード例では、get-usage を使用する方法を示しています。
- AWS CLI
-
使用量プランの使用の詳細を取得する方法
コマンド:
aws apigateway get-usage --usage-plan-ida1b2c3--start-date"2016-08-16"--end-date"2016-08-17"-
API の詳細については、「AWS CLI コマンドリファレンス」の「GetUsage
」を参照してください。
-
次のコード例では、import-rest-api を使用する方法を示しています。
- AWS CLI
-
Swagger テンプレートをインポートして API を作成する方法
コマンド:
aws apigateway import-rest-api --body 'file:///path/to/API_Swagger_template.json'-
API の詳細については、「AWS CLI コマンドリファレンス」の「ImportRestApi
」を参照してください。
-
次のコード例では、put-integration-response を使用する方法を示しています。
- AWS CLI
-
マッピングテンプレートを定義して、統合レスポンスをデフォルトレスポンスとして作成する方法
コマンド:
aws apigateway put-integration-response --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--status-code200--selection-pattern "" --response-templates '{"application/json": "{\"json\": \"template\"}"}'regex が 400 でヘッダー値が静的に定義された統合レスポンスを作成する方法
コマンド:
aws apigateway put-integration-response --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--status-code400--selection-pattern400--response-parameters '{"method.response.header.custom-header": "'"'"'custom-value'"'"'"}'-
API の詳細については、AWS CLI コマンドリファレンスの「PutIntegrationResponse
」を参照してください。
-
次のコード例では、put-integration を使用する方法を示しています。
- AWS CLI
-
MOCK 統合リクエストを作成する方法
コマンド:
aws apigateway put-integration --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--typeMOCK--request-templates '{ "application/json": "{\"statusCode\": 200}" }'HTTP 統合リクエストを作成する方法
コマンド:
aws apigateway put-integration --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--typeHTTP--integration-http-methodGET--uri 'https://domain.tld/path'Lambda 関数エンドポイントと AWS の統合リクエストを作成するには
コマンド:
aws apigateway put-integration --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--typeAWS--integration-http-methodPOST--uri 'arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:function_name/invocations'-
API の詳細については、AWS CLI コマンドリファレンスの「PutIntegration
」を参照してください。
-
次のコード例では、put-method-response を使用する方法を示しています。
- AWS CLI
-
カスタムメソッドレスポンスヘッダーを使用して、指定したステータスコードでメソッドレスポンスを作成する方法
コマンド:
aws apigateway put-method-response --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--status-code400--response-parameters"method.response.header.custom-header=false"-
API の詳細については、AWS CLI コマンドリファレンスの「PutMethodResponse
」を参照してください。
-
次のコード例では、put-method を使用する方法を示しています。
- AWS CLI
-
権限なし、API キーなし、カスタムメソッドリクエストヘッダーありで API 内のリソース用のメソッドを作成する方法
コマンド:
aws apigateway put-method --rest-api-id1234123412--resource-ida1b2c3--http-methodPUT--authorization-type"NONE"--no-api-key-required --request-parameters"method.request.header.custom-header=false"-
API の詳細については、AWS CLI コマンドリファレンスの「PutMethod
」を参照してください。
-
次のコード例では、put-rest-api を使用する方法を示しています。
- AWS CLI
-
Swagger テンプレートを使用して既存の API を上書きする方法
コマンド:
aws apigateway put-rest-api --rest-api-id1234123412--modeoverwrite--body 'fileb:///path/to/API_Swagger_template.json'Swagger テンプレートを既存の API にマージする方法
コマンド:
aws apigateway put-rest-api --rest-api-id1234123412--modemerge--body 'fileb:///path/to/API_Swagger_template.json'-
API の詳細については、「AWS CLI コマンドリファレンス」の「PutRestApi
」を参照してください。
-
次の例は、reject-domain-name-access-association を使用する方法を説明しています。
- AWS CLI
-
ドメイン名アクセスの関連付けを拒否するには
次の
reject-domain-name-access-associationの例では、プライベートカスタムドメイン名と VPC エンドポイントとの間のドメイン名アクセスの関連付けを拒否します。aws apigateway reject-domain-name-access-association \ --domain-name-access-association-arnarn:aws:apigateway:us-west-2:012345678910:/domainnameaccessassociations/domainname/my.private.domain.tld/vpcesource/vpce-abcd1234efg\ --domain-name-arnarn:aws:apigateway:us-east-1:012345678910:/domainnames/my.private.domain.tld+abcd1234このコマンドでは何も出力されません。
詳細については、Amazon API Gateway デベロッパーガイドの「API Gateway でのプライベート API 用のカスタムドメイン名」を参照してください。
-
API の詳細については、AWS CLI コマンドリファレンスの「RejectDomainNameAccessAssociation
」を参照してください。
-
次の例は、test-invoke-authorizer を使用する方法を説明しています。
- AWS CLI
-
必要なヘッダーと値を含むカスタムオーソライザーへのリクエストをテストする方法
コマンド:
aws apigateway test-invoke-authorizer --rest-api-id1234123412--authorizer-id5yid1t--headers Authorization='Value'-
API の詳細については、「AWS CLI コマンドリファレンス」の「TestInvokeAuthorizer
」を参照してください。
-
次のコード例では、test-invoke-method を使用する方法を示しています。
- AWS CLI
-
GET リクエストを実行して API のルートリソースをテストする方法
コマンド:
aws apigateway test-invoke-method --rest-api-id1234123412--resource-idavl5sg8fw8--http-methodGET--path-with-query-string '/'パスパラメータ値を指定して GET リクエストを実行し、API でサブリソースを呼び出すテストをする方法
コマンド:
aws apigateway test-invoke-method --rest-api-id1234123412--resource-id3gapai--http-methodGET--path-with-query-string '/pets/1'-
API の詳細については、「AWS CLI コマンドリファレンス」の「TestInvokeMethod
」を参照してください。
-
次のコード例では、update-account を使用する方法を示しています。
- AWS CLI
-
CloudWatch Logs へのログ記録用の IAM ロール ARN を変更する方法
コマンド:
aws apigateway update-account --patch-operations op='replace',path='/cloudwatchRoleArn',value='arn:aws:iam::123412341234:role/APIGatewayToCloudWatchLogs'出力:
{ "cloudwatchRoleArn": "arn:aws:iam::123412341234:role/APIGatewayToCloudWatchLogs", "throttleSettings": { "rateLimit": 1000.0, "burstLimit": 2000 } }-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateAccount
」を参照してください。
-
次のコード例では、update-api-key を使用する方法を示しています。
- AWS CLI
-
API キーの名前を変更する方法
コマンド:
aws apigateway update-api-key --api-keysNvjQDMReA1eEQPNAW8r37XsU2rDD7fc7m2SiMnu--patch-operations op='replace',path='/name',value='newName'出力:
{ "description": "currentDescription", "enabled": true, "stageKeys": [ "41t2j324r5/dev" ], "lastUpdatedDate": 1470086052, "createdDate": 1445460347, "id": "sNvjQDMReA1vEQPNzW8r3dXsU2rrD7fcjm2SiMnu", "name": "newName" }API キーを無効にする方法
コマンド:
aws apigateway update-api-key --api-keysNvjQDMReA1eEQPNAW8r37XsU2rDD7fc7m2SiMnu--patch-operations op='replace',path='/enabled',value='false'出力:
{ "description": "currentDescription", "enabled": false, "stageKeys": [ "41t2j324r5/dev" ], "lastUpdatedDate": 1470086052, "createdDate": 1445460347, "id": "sNvjQDMReA1vEQPNzW8r3dXsU2rrD7fcjm2SiMnu", "name": "newName" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateApiKey
」を参照してください。
-
次のコード例では、update-authorizer を使用する方法を示しています。
- AWS CLI
-
Custom Authorizer の名前を変更する方法
コマンド:
aws apigateway update-authorizer --rest-api-id1234123412--authorizer-idgfi4n3--patch-operations op='replace',path='/name',value='testAuthorizer'出力:
{ "authType": "custom", "name": "testAuthorizer", "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:customAuthorizer/invocations", "authorizerResultTtlInSeconds": 300, "identitySource": "method.request.header.Authorization", "type": "TOKEN", "id": "gfi4n3" }カスタムオーソライザーによって呼び出される Lambda 関数を変更する方法
コマンド:
aws apigateway update-authorizer --rest-api-id1234123412--authorizer-idgfi4n3--patch-operations op='replace',path='/authorizerUri',value='arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:newAuthorizer/invocations'出力:
{ "authType": "custom", "name": "testAuthorizer", "authorizerUri": "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123412341234:function:newAuthorizer/invocations", "authorizerResultTtlInSeconds": 300, "identitySource": "method.request.header.Authorization", "type": "TOKEN", "id": "gfi4n3" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateAuthorizer
」を参照してください。
-
次のコード例では、update-base-path-mapping を使用する方法を示しています。
- AWS CLI
-
カスタムドメイン名のベースパスマッピングを変更する方法
コマンド:
aws apigateway update-base-path-mapping --domain-nameapi.domain.tld--base-pathprod--patch-operations op='replace',path='/basePath',value='v1'出力:
{ "basePath": "v1", "restApiId": "1234123412", "stage": "api" }-
API の詳細については、AWS CLI コマンドリファレンスの「UpdateBasePathMapping
」を参照してください。
-
次のコード例では、update-client-certificate を使用する方法を示しています。
- AWS CLI
-
クライアント証明書の説明を更新する方法
コマンド:
aws apigateway update-client-certificate --client-certificate-ida1b2c3--patch-operations op='replace',path='/description',value='My new description'-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateClientCertificate
」を参照してください。
-
次のコード例では、update-deployment を使用する方法を示しています。
- AWS CLI
-
デプロイの説明を変更する方法
コマンド:
aws apigateway update-deployment --rest-api-id1234123412--deployment-idztt4m2--patch-operations op='replace',path='/description',value='newDescription'出力:
{ "description": "newDescription", "id": "ztt4m2", "createdDate": 1455218022 }-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateDeployment
」を参照してください。
-
次のコード例では、update-domain-name を使用する方法を示しています。
- AWS CLI
-
カスタムドメイン名の証明書を変更する方法
次の
update-domain-nameの例では、カスタムドメインの証明書名を変更します。aws apigateway update-domain-name \ --domain-nameapi.domain.tld\ --patch-operations op='replace',path='/certificateArn',value='arn:aws:acm:us-west-2:111122223333:certificate/CERTEXAMPLE123EXAMPLE'出力:
{ "domainName": "api.domain.tld", "distributionDomainName": "d123456789012.cloudfront.net", "certificateArn": "arn:aws:acm:us-west-2:111122223333:certificate/CERTEXAMPLE123EXAMPLE", "certificateUploadDate": 1462565487 }詳細については、「Amazon API Gateway デベロッパーガイド」の「Set up Custom Domain Name for an API in API Gateway」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateDomainName
」を参照してください。
-
次のコード例では、update-integration-response を使用する方法を示しています。
- AWS CLI
-
統合レスポンスヘッダーを「*」の静的マッピングに変更する方法
コマンド:
aws apigateway update-integration-response --rest-api-id1234123412--resource-id3gapai--http-methodGET--status-code200--patch-operations op='replace',path='/responseParameters/method.response.header.Access-Control-Allow-Origin',value='"'"'*'"'"'出力:
{ "statusCode": "200", "responseParameters": { "method.response.header.Access-Control-Allow-Origin": "'*'" } }統合レスポンスヘッダーを削除する方法
コマンド:
aws apigateway update-integration-response --rest-api-id1234123412--resource-id3gapai--http-methodGET--status-code200--patch-operations op='remove',path='/responseParameters/method.response.header.Access-Control-Allow-Origin'-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateIntegrationResponse
」を参照してください。
-
次のコード例では、update-integration を使用する方法を示しています。
- AWS CLI
-
Input Passthrough で設定された「コンテンツタイプ: application/json」マッピングテンプレートを追加する方法
コマンド:
aws apigateway update-integration \ --rest-api-ida1b2c3d4e5\ --resource-ida1b2c3\ --http-methodPOST\ --patch-operations"op='add',path='/requestTemplates/application~1json'"カスタムテンプレートで設定された「コンテンツタイプ: application/json」マッピングテンプレートを更新 (置き換え) する方法
コマンド:
aws apigateway update-integration \ --rest-api-ida1b2c3d4e5\ --resource-ida1b2c3\ --http-methodPOST\ --patch-operations "op='replace',path='/requestTemplates/application~1json',value='{"example": "json"}'"「コンテンツタイプ: application/json」に関連付けられたカスタムテンプレートを Input Passthrough で更新 (置き換え) する方法
コマンド:
aws apigateway update-integration \ --rest-api-ida1b2c3d4e5\ --resource-ida1b2c3\ --http-methodPOST\ --patch-operations"op='replace',path='requestTemplates/application~1json'"「コンテンツタイプ: application/json」マッピングテンプレートを削除する方法
コマンド:
aws apigateway update-integration \ --rest-api-ida1b2c3d4e5\ --resource-ida1b2c3\ --http-methodPOST\ --patch-operations"op='remove',path='/requestTemplates/application~1json'"-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateIntegration
」を参照してください。
-
次のコード例では、update-method-response を使用する方法を示しています。
- AWS CLI
-
メソッドで 200 レスポンスの新しいメソッドレスポンスヘッダーを作成し、不要として定義する方法 (デフォルト)
コマンド:
aws apigateway update-method-response --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--status-code200--patch-operations op="add",path="/responseParameters/method.response.header.custom-header",value="false"メソッドで 200 レスポンスのレスポンスモデルを削除する方法
コマンド:
aws apigateway update-method-response --rest-api-id1234123412--resource-ida1b2c3--http-methodGET--status-code200--patch-operations op="remove",path="/responseModels/application~1json"-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateMethodResponse
」を参照してください。
-
次のコード例では、update-method を使用する方法を示しています。
- AWS CLI
-
例 1: API キーを要求するようにメソッドを変更する方法
次の
update-methodの例では、API キーを要求するようにメソッドを変更します。aws apigateway update-method \ --rest-api-id1234123412\ --resource-ida1b2c3\ --http-methodGET\ --patch-operations op="replace",path="/apiKeyRequired",value="true"出力:
{ "httpMethod": "GET", "authorizationType": "NONE", "apiKeyRequired": true, "methodResponses": { "200": { "statusCode": "200", "responseModels": {} } }, "methodIntegration": { "type": "AWS", "httpMethod": "POST", "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789111:function:hello-world/invocations", "passthroughBehavior": "WHEN_NO_MATCH", "contentHandling": "CONVERT_TO_TEXT", "timeoutInMillis": 29000, "cacheNamespace": "h7i8j9", "cacheKeyParameters": [], "integrationResponses": { "200": { "statusCode": "200", "responseTemplates": {} } } } }例 2: メソッドを変更して IAM 認証を要求する方法
次の
update-methodの例では、IAM 認証を必要とするようにメソッドを変更します。aws apigateway update-method \ --rest-api-id1234123412\ --resource-ida1b2c3\ --http-methodGET\ --patch-operations op="replace",path="/authorizationType",value="AWS_IAM"出力:
{ "httpMethod": "GET", "authorizationType": "AWS_IAM", "apiKeyRequired": false, "methodResponses": { "200": { "statusCode": "200", "responseModels": {} } }, "methodIntegration": { "type": "AWS", "httpMethod": "POST", "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789111:function:hello-world/invocations", "passthroughBehavior": "WHEN_NO_MATCH", "contentHandling": "CONVERT_TO_TEXT", "timeoutInMillis": 29000, "cacheNamespace": "h7i8j9", "cacheKeyParameters": [], "integrationResponses": { "200": { "statusCode": "200", "responseTemplates": {} } } } }例 3: Lambda 認証を要求するようにメソッドを変更する方法
次の
update-methodの例では、メソッドを必要な Lambda 認証に変更します。aws apigateway update-method --rest-api-id1234123412\ --resource-ida1b2c3\ --http-methodGET\ --patch-operations op="replace",path="/authorizationType",value="CUSTOM" op="replace",path="/authorizerId",value="e4f5g6"出力:
{ "httpMethod": "GET", "authorizationType": "CUSTOM", "authorizerId" : "e4f5g6", "apiKeyRequired": false, "methodResponses": { "200": { "statusCode": "200", "responseModels": {} } }, "methodIntegration": { "type": "AWS", "httpMethod": "POST", "uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:123456789111:function:hello-world/invocations", "passthroughBehavior": "WHEN_NO_MATCH", "contentHandling": "CONVERT_TO_TEXT", "timeoutInMillis": 29000, "cacheNamespace": "h7i8j9", "cacheKeyParameters": [], "integrationResponses": { "200": { "statusCode": "200", "responseTemplates": {} } } } }詳細については、「Amazon API Gateway デベロッパーガイド」の「API Gateway CLI と REST API を使用した使用量プランの作成、設定、テスト」と「API Gateway の REST API へのアクセスの制御と管理」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateMethod
」を参照してください。
-
次のコード例では、update-model を使用する方法を示しています。
- AWS CLI
-
API でモデルの説明を変更する方法
コマンド:
aws apigateway update-model --rest-api-id1234123412--model-name 'Empty' --patch-operations op=replace,path=/description,value='New Description'API でモデルのスキーマを変更する方法
コマンド:
aws apigateway update-model --rest-api-id1234123412--model-name 'Empty' --patch-operations op=replace,path=/schema,value='"{ \"$schema\": \"http://json-schema.org/draft-04/schema#\", \"title\" : \"Empty Schema\", \"type\" : \"object\" }"'-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateModel
」を参照してください。
-
次のコード例では、update-resource を使用する方法を示しています。
- AWS CLI
-
リソースを移動して API 内の別の親リソースに配置する方法
コマンド:
aws apigateway update-resource --rest-api-id1234123412--resource-id1a2b3c--patch-operations op=replace,path=/parentId,value='3c2b1a'出力:
{ "path": "/resource", "pathPart": "resource", "id": "1a2b3c", "parentId": "3c2b1a" }API でリソース (pathPart) の名前を変更する方法
コマンド:
aws apigateway update-resource --rest-api-id1234123412--resource-id1a2b3c--patch-operationsop=replace,path=/pathPart,value=newresourcename出力:
{ "path": "/newresourcename", "pathPart": "newresourcename", "id": "1a2b3c", "parentId": "3c2b1a" }-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateResource
」を参照してください。
-
次のコード例では、update-rest-api を使用する方法を示しています。
- AWS CLI
-
API の名前を変更する方法
コマンド:
aws apigateway update-rest-api --rest-api-id1234123412--patch-operations op=replace,path=/name,value='New Name'API の説明を変更する方法
コマンド:
aws apigateway update-rest-api --rest-api-id1234123412--patch-operations op=replace,path=/description,value='New Description'-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateRestApi
」を参照してください。
-
次のコード例では、update-stage を使用する方法を示しています。
- AWS CLI
-
例 1: リソースとメソッドのステージ設定を上書きする方法
次の
update-stageの例では、ステージ設定を上書きし、特定のリソースとメソッドの完全なリクエスト/レスポンスログ記録をオフにします。aws apigateway update-stage \ --rest-api-id1234123412\ --stage-name 'dev' \ --patch-operationsop=replace,path=/~1resourceName/GET/logging/dataTrace,value=false出力:
{ "deploymentId": "5ubd17", "stageName": "dev", "cacheClusterEnabled": false, "cacheClusterStatus": "NOT_AVAILABLE", "methodSettings": { "~1resourceName/GET": { "metricsEnabled": false, "dataTraceEnabled": false, "throttlingBurstLimit": 5000, "throttlingRateLimit": 10000.0, "cachingEnabled": false, "cacheTtlInSeconds": 300, "cacheDataEncrypted": false, "requireAuthorizationForCacheControl": true, "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER" } }, "tracingEnabled": false, "createdDate": "2022-07-18T10:11:18-07:00", "lastUpdatedDate": "2022-07-18T10:19:04-07:00" }詳細については、「Amazon API Gateway デベロッパーガイド」の「REST API にステージを設定」を参照してください。
例 2: API ステージのすべてのリソースとメソッドのステージ設定を更新する方法
次の
update-stageの例では、API ステージのすべてのリソースとメソッドの完全なリクエスト/レスポンスログ記録をオンにします。aws apigateway update-stage \ --rest-api-id1234123412\ --stage-name 'dev' \ --patch-operations 'op=replace,path=/*/*/logging/dataTrace,value=true'出力:
{ "deploymentId": "5ubd17", "stageName": "dev", "cacheClusterEnabled": false, "cacheClusterStatus": "NOT_AVAILABLE", "methodSettings": { "*/*": { "metricsEnabled": false, "dataTraceEnabled": true, "throttlingBurstLimit": 5000, "throttlingRateLimit": 10000.0, "cachingEnabled": false, "cacheTtlInSeconds": 300, "cacheDataEncrypted": false, "requireAuthorizationForCacheControl": true, "unauthorizedCacheControlHeaderStrategy": "SUCCEED_WITH_RESPONSE_HEADER" } }, "tracingEnabled": false, "createdDate": "2022-07-18T10:11:18-07:00", "lastUpdatedDate": "2022-07-18T10:31:04-07:00" }詳細については、「Amazon API Gateway デベロッパーガイド」の「REST API にステージを設定」を参照してください。
-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateStage
」を参照してください。
-
次のコード例では、update-usage-plan を使用する方法を示しています。
- AWS CLI
-
使用量プランで定義された期間を変更する方法
コマンド:
aws apigateway update-usage-plan --usage-plan-ida1b2c3--patch-operations op="replace",path="/quota/period",value="MONTH"使用量プランで定義されているクォータ制限を変更する方法
コマンド:
aws apigateway update-usage-plan --usage-plan-ida1b2c3--patch-operations op="replace",path="/quota/limit",value="500"使用量プランで定義されているスロットルレート制限を変更する方法
コマンド:
aws apigateway update-usage-plan --usage-plan-ida1b2c3--patch-operations op="replace",path="/throttle/rateLimit",value="10"使用量プランで定義されているスロットルバースト制限を変更する方法
コマンド:
aws apigateway update-usage-plan --usage-plan-ida1b2c3--patch-operations op="replace",path="/throttle/burstLimit",value="20"-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateUsagePlan
」を参照してください。
-
次のコード例では、update-usage を使用する方法を示しています。
- AWS CLI
-
使用量プランで定義されている現在の期間の API キーのクォータを一時的に変更する方法
コマンド:
aws apigateway update-usage --usage-plan-ida1b2c3--key-id1NbjQzMReAkeEQPNAW8r3dXsU2rDD7fc7f2Sipnu--patch-operations op="replace",path="/remaining",value="50"-
API の詳細については、「AWS CLI コマンドリファレンス」の「UpdateUsage
」を参照してください。
-