简体   繁体   English

创建 S3 存储桶时触发 Lambda function

[英]Trigger Lambda function when S3 buckets get created

I want to create a Lambda function using Java or Python so that whenever a new S3 bucket gets created, by default it enables default encryption of AES256 and server-access logs on those buckets, if they were not enabled while creating the bucket. I want to create a Lambda function using Java or Python so that whenever a new S3 bucket gets created, by default it enables default encryption of AES256 and server-access logs on those buckets, if they were not enabled while creating the bucket.

You can use Cloudwatch event here.您可以在此处使用 Cloudwatch 事件。

  1. Go to cloudwatch and under events, select rule. Go 到 cloudwatch 和事件,select 规则。
  2. Create a new rule.创建新规则。
  3. Select Event Pattern, specific operations, and then select CreateBucket. Select Event Pattern,具体操作,然后是select CreateBucket。
  4. Now in the next column you can click add target and select the lambda you want to trigger.现在在下一列中,您可以单击添加目标和 select 您要触发的 lambda。 (create one if you don't already have it) (如果您还没有,请创建一个)

Now write your lambda using Java and use the SDK to make whatever changes you require.现在使用 Java 编写您的 lambda 并使用 SDK 进行所需的任何更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM