我想使用 AWS SAM 为某些 lambda 函数创建部署脚本。其中两个函数将部署到一个账户(账户 A)中,但将由第二个账户(账户 B)中的 s3 存储桶对象创建事件触发。据我所知,执行此操作的唯一方法是向我的 lambda 添加基于资源的策略。但我不知道如何在 AWS SAM 中做到这一点。我当前的 yaml 文件如下所示。
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
deploy-test-s3-triggered-lambda
Parameters:
AppBucketName:
Type: String
Description: "REQUIRED: Unique S3 bucket name to use for the app."
Resources:
S3TriggeredLambda:
Type: AWS::Serverless::Function
Properties:
Role: arn:aws:iam::************:role/lambda-s3-role
Handler: src/handlers/s3-triggered-lambda.invokeAPI
CodeUri: src/handlers/s3-triggered-lambda.js.zip
Runtime: nodejs10.x
MemorySize: 128
Timeout: 60
Policies:
S3ReadPolicy:
BucketName: !Ref AppBucketName
Events:
S3NewObjectEvent:
Type: S3
Properties:
Bucket: !Ref AppBucket
Events: s3:ObjectCreated:*
AppBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Ref AppBucketName
Run Code Online (Sandbox Code Playgroud)
我需要向此 yaml …