1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
2
Hello.
I tried running the CloudFormation template below and confirmed that Lambda was executed successfully.
I ran it in the Tokyo region.
It's possible that the issue is region-specific, so please try deploying the template below in the region you're using and see if you can reproduce the issue.
By the way, as commented in the URL below, "cfnresponse" can only be used when deploying Lambda and code using Zip with CloudFormation.
https://repost.aws/questions/QUtqrQ6_3zSxmKo3QtFW_4Aw/cfnresponse-package-is-missing-in-new-python-3-9-runtime#CO4K6fg1FGTMyq34g7Igzy_Q
AWSTemplateFormatVersion: "2010-09-09"
Resources:
SampleLambda:
Type: Custom::SampleLambda
Properties:
ServiceToken: !GetAtt "LambdaFunction.Arn"
Hoge: "hoge"
LambdaFunction:
Type: AWS::Lambda::Function
Properties:
Role: !GetAtt "LambdaExecutionRole.Arn"
Runtime: "python3.12"
Handler: index.lambda_handler
Timeout: "180"
Code:
ZipFile: |
import cfnresponse
def lambda_handler(event, context):
hoge = event['ResourceProperties']['Hoge']
if event['RequestType'] == 'Create':
print('Create:'+hoge)
cfnresponse.send(event, context, cfnresponse.SUCCESS,
{'Response': 'Success'})
if event['RequestType'] == 'Delete':
print('Delete:'+hoge)
cfnresponse.send(event, context, cfnresponse.SUCCESS,
{'Response': 'Success'})
if event['RequestType'] == 'Update':
print('Update:'+hoge)
cfnresponse.send(event, context, cfnresponse.SUCCESS,
{'Response': 'Success'})
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: /
Policies:
- PolicyName: sample-lambda-policy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource: arn:aws:logs:*:*:*
Conteúdo relevante
- AWS OFICIALAtualizada há 4 anos
- AWS OFICIALAtualizada há 2 anos
- AWS OFICIALAtualizada há 8 meses
Thanks . I see cfnmodule is only available if we are using ZipFile