1 Risposta
- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
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:*:*:*
Contenuto pertinente
- AWS UFFICIALEAggiornata 4 anni fa
- AWS UFFICIALEAggiornata 4 anni fa
- AWS UFFICIALEAggiornata 7 mesi fa
Thanks . I see cfnmodule is only available if we are using ZipFile