是否可以使用CFT将通知配置添加到现有S3存储桶?

时间:2022-11-02 23:04:25

I am still a newbie with AWS services.

我仍然是AWS服务的新手。

I would like to add a Lambda trigger on an existing S3 bucket using a CFT. Is that possible?

我想使用CFT在现有S3存储桶上添加Lambda触发器。那可能吗?

When I create a CFT in the following it is attempting to create a new S3 bucket and add an event notificaiton on it.

当我在下面创建CFT时,它尝试创建一个新的S3存储桶并在其上添加事件通知。

S3BUCKET_NOTIFCATION = Bucket(
    "S3Bucket",
    BucketName=s3_bucket("confidential", Ref(ENV)),
    NotificationConfiguration=NotificationConfiguration(
        LambdaConfigurations=[
            LambdaConfigurations(
                Event="s3:ObjectCreated:*",
                Filter=Filter(
                    S3Key=S3Key(
                        Rules=[Rules(Name="prefix", Value=Ref(inputKeyPrefix)),
                               Rules(Name="suffix", Value=".json")]
                    )
                ),
                Function=Ref(cost_function)
            )
        ]
    )
)

Is it possible to add the Notification configuration to an existing bucket?

是否可以将Notification配置添加到现有存储桶?

1 个解决方案

#1


1  

I've been unable to add NotificationConfiguration to an existing bucket as well. When you try, you'll get the error "CREATE_FAILED. Reason: S3_BUCKET already exists"

我也无法将NotificationConfiguration添加到现有存储桶中。当您尝试时,您将收到错误“CREATE_FAILED。原因:S3_BUCKET已存在”

This post is from 2013 detailing that modifications of a pre-existing bucket is not allowed. It appears to still be correct.

这篇文章来自2013年,详细说明不允许对现有存储桶进行修改。它似乎仍然是正确的。

https://serverfault.com/questions/610788/using-cloudformation-with-an-existing-s3-bucket

https://serverfault.com/questions/610788/using-cloudformation-with-an-existing-s3-bucket

#1


1  

I've been unable to add NotificationConfiguration to an existing bucket as well. When you try, you'll get the error "CREATE_FAILED. Reason: S3_BUCKET already exists"

我也无法将NotificationConfiguration添加到现有存储桶中。当您尝试时,您将收到错误“CREATE_FAILED。原因:S3_BUCKET已存在”

This post is from 2013 detailing that modifications of a pre-existing bucket is not allowed. It appears to still be correct.

这篇文章来自2013年,详细说明不允许对现有存储桶进行修改。它似乎仍然是正确的。

https://serverfault.com/questions/610788/using-cloudformation-with-an-existing-s3-bucket

https://serverfault.com/questions/610788/using-cloudformation-with-an-existing-s3-bucket