- 最新
- 投票最多
- 评论最多
If I understand correctly, you deploy multiple stacks, each with a different bucket, but all with the same Lambda function. You want the bucket name to be determined by CFN, but you need to know in the function the origin bucket, or more specifically, what the bucket is used for, not its name.
If this is the case and your function performs different actions based on the origin bucket, I would recommend creating different functions. This way each stack creates a different S3 bucket with a different function, that knows what to do.
Hi, while creating an S3 bucket using CDK you can manually set the bucketName
property: https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-s3.Bucket.html
This will ensure that the bucket has the same name every-time it is deployed, which should address your issue.
Thanks,
Marrick.
Fair enough! In that case, your best bet is probably to using S3 to publish event messages to SNS which would in-turn trigger your Lambda function: https://docs.aws.amazon.com/AmazonS3/latest/userguide/how-to-enable-disable-notification-intro.html. Specifically, configuring each bucket to send SNS events with a different SNS Topic would allow your Lambda function to determine where the event came from.
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前
Hi, thanks for your response, but I prefer to have the bucketName assigned by the CloudFormation as the doc said: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Bucket.html#bucketname