我正在尝试使用boto3将lambda端点设置为我的api网关。我使用的是API网关boto3文档中描述的方法put_integration。我已经成功地设置了POST方法,但是我无法集成lambda。特别是,我在查找uri参数的命名时遇到了问题。我有accountID、regionName和functionName,但是我不知道如何正确地格式化这个参数
botoKwargs = {
'restApiId' : api_id,
'resourceId' : resource_id,
'httpMethod' : 'POST',
'type' : 'AWS',
'integrationHttpMethod' : 'POST',
'uri' : uri,
# 'credentials' : credentials,
}
apig_client = get_apig_client()
apig_client.put_integration(**botoKwargs)我确信这是唯一的问题。我找不到设置uri参数的规范方法。以下摘录是相关的:
For AWS or AWS_PROXY integrations, the URI is of the form arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api} . Here, {Region} is the API Gateway region (e.g., us-east-1 ); {service} is the name of the integrated AWS service (e.g., s3 ); and {subdomain} is a designated subdomain supported by certain AWS service for fast host-name lookup. action can be used for an AWS service action-based API, using an Action={name}&{p1}={v1}&p2={v2}... query string. The ensuing {service_api} refers to a supported action {name} plus any required input parameters. Alternatively, path can be used for an AWS service path-based API. The ensuing service_api refers to the path to an AWS service resource, including the region of the integrated AWS service, if applicable. For example, for integration with the S3 API of `GetObject <https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html>`__ , the uri can be either arn:aws:apigateway:us-west-2:s3:action/GetObject&Bucket={bucket}&Key={key} or arn:aws:apigateway:us-west-2:s3:path/{bucket}/{key}url在这里:
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway.html#APIGateway.Client.put_integration当我给出lambda arn时,我得到了错误
AWS ARN for integration must contain path or action如果能得到任何帮助,我将不胜感激。
发布于 2021-10-08 19:48:26
根据this文档,uri应该是这样的。
arn:aws:apigateway:api-region:lambda:path//2015-03-31/functions/arn:aws:lambda:lambda-region:account-id:function:lambda-function-name/invocations注意:您需要根据您的数据修改api-region、lambda-function-name -id、-id。
https://stackoverflow.com/questions/67152817
复制相似问题