首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在API网关Boto3上将Lambda设置为POST

在API网关Boto3上将Lambda设置为POST
EN

Stack Overflow用户
提问于 2021-04-19 03:53:13
回答 1查看 127关注 0票数 0

我正在尝试使用boto3将lambda端点设置为我的api网关。我使用的是API网关boto3文档中描述的方法put_integration。我已经成功地设置了POST方法,但是我无法集成lambda。特别是,我在查找uri参数的命名时遇到了问题。我有accountID、regionName和functionName,但是我不知道如何正确地格式化这个参数

代码语言:javascript
复制
 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参数的规范方法。以下摘录是相关的:

代码语言:javascript
复制
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在这里:

代码语言:javascript
复制
 https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway.html#APIGateway.Client.put_integration

当我给出lambda arn时,我得到了错误

代码语言:javascript
复制
AWS ARN for integration must contain path or action

如果能得到任何帮助,我将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2021-10-08 19:48:26

根据this文档,uri应该是这样的。

代码语言:javascript
复制
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。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67152817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档