以编程方式向AWS API网关添加POST方法



我试图通过编程方式从调用lambda函数的AWS API网关创建POST方法。但是我不知道该怎么做。这是我尝试过的:

response = client.create_rest_api(
name=api_name,
endpointConfiguration={
'types': [
'REGIONAL',
],
},
)

创建API

response = client.put_method(
restApiId=api_id,
resourceId=func_arn,
httpMethod='POST',
authorizationType='NONE',
)

我正在放置API字符串ID(不是名称),并传递lambda ARN。然而,我得到错误:

botocore.errorfactory.NotFoundException: An error occurred (NotFoundException) when calling the CreateResource operation: Invalid Resource identifier specified

我不知道我做错了什么。如果您能帮助我们获取API POST方法来调用lambda,我们将不胜感激。

从你发布的内容来看,似乎你想使用不正确的resourceId。看起来你正在使用lambda函数arn (func_arn)。但是,resourceId应该是通过create_resource方法创建的资源。

因此,一旦您使用create_resource创建了资源,那么您就可以使用put_method向该资源添加方法。

最新更新