提前致謝。我正在嘗試創建 s3 存盤桶和 lambda 函式。目標是在我們將任何內容上傳到 s3 存盤桶時執行 lambda 函式。我嘗試了不同的方法,但似乎不起作用。任何幫助表示贊賞。
Resources:
s3bucketvideo:
Type: AWS::S3::Bucket
DependsOn: S3InvokeLambdaPermission
Properties:
BucketName: s3bucketvideo
NotificationConfiguration:
LambdaConfigurations:
- Event: 's3:ObjectCreated:*'
Function: !GetAtt VideoToImageLambda.Arn
S3InvokeLambdaPermission:
Type: AWS::Lambda::Permission
Properties:
Action: lambda:InvokeFunction
FunctionName: !Ref VideoToImageLambda
Principal: s3.amazonaws.com
SourceArn: !GetAtt s3bucketvideo.Arn
cflambdarole:
Type: AWS::IAM::Role
Properties:
RoleName: cflambdarole
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AWSLambda_FullAccess
- arn:aws:iam::aws:policy/AWSLambdaExecute
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
VideoToImageLambda:
Type: AWS::Lambda::Function
Properties:
FunctionName: VideoToImageLambda
Timeout: 120
Role:
Fn::GetAtt:
- cflambdarole
- Arn
Runtime: python3.9
Handler: script.hprint
Code:
S3Bucket: s3-neuralopsdev
S3Key: script.zip
uj5u.com熱心網友回復:
一種快速解決方案是在權限中使用 SourceAccount 而不是 SourceArn:
SourceAccount: !Ref 'AWS::AccountId'
創建堆疊后,您還可以添加 SourceArn 并進行更新。
這也在此處討論。
uj5u.com熱心網友回復:
只是一個更新。我創建了沒有存盤桶通知的堆疊,然后使用存盤桶通知更新了堆疊以獲得快速解決方案。它做到了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/374061.html
