add cors rule to existing bucket #23184
-
I could see there is a function called I am trying to achieve a similar thing for an existing S3 bucket that is not created by me, and it's in another AWS account. The return type of all the finding existing bucket functions e.g. fromBucketAttributes is IBucket. It does not provide a method for adding a new cors rule. I am wondering if there will be a workaround to achieve this? Thank you very much. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Unfortunately, you cannot modify imported resources. See our documentation here for more info. If you wish to modify an existing bucket through CDK, I think the only way would be with a CustomResource of your own to run the logic you want to, or AwsCustomResource to easily make use of an SDK call. Keep in mind that if the bucket is in another account you'll need to properly configure permissions to allow for that |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Unfortunately, you cannot modify imported resources. See our documentation here for more info.
If you wish to modify an existing bucket through CDK, I think the only way would be with a CustomResource of your own to run the logic you want to, or AwsCustomResource to easily make use of an SDK call. Keep in mind that if the bucket is in another account you'll need to properly configure permissions to allow for that