本文介绍了AWS lambda:没有名为“cfnresponse"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经部署了一个 AWS lambda,其中包含:
I have deployed an AWS lambda which contains:
import json
import boto3
import cfnresponse
import urllib.request
from botocore.exceptions import ClientError
def lambda_handler(event, context):
...
cfnresponse.send(event, context, status, responseData, "CustomResourcePhysicalID")
我试图在我的 cloudformations 中获取 cfnresponse
的值:
I tried to get the values of the cfnresponse
in my cloudformations:
Resources:
API:
Type: Custom::API
Version: '1.0'
Properties:
ServiceToken: arn:aws:lambda:eu-west-1:1234567891011:function:getCountry
Outputs:
Status:
Value:
!GetAtt API.Data
现在 cfn 卡住了,我收到了错误:
Now th cfn is stuck and I got the error:
Unable to import module 'lambda_function': No module named 'cfnresponse'
我做错了什么?当我查看 文档.
What am I doing wrong? It seems the way to do it when I check the docs.
推荐答案
Cfnresponse 在 Python 2.7 中默认仅在 lambda 中可用.可能您使用的是 3.6.
Cfnresponse is just available in lambda by default with python 2.7. Probably you are using 3.6.
这篇关于AWS lambda:没有名为“cfnresponse"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!