You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
property on the destination bucket. This will avoid the logical ID problem mentioned above.
186
186
187
+
## Retain on Delete
188
+
189
+
By default, the contents of the destination bucket will **not** be deleted when the
190
+
`BucketDeployment` resource is removed from the stack or when the destination is
191
+
changed. You can use the option `retainOnDelete: false` to disable this behavior,
192
+
in which case the contents will be deleted.
193
+
194
+
## IAM Permissions and Security
195
+
196
+
The `BucketDeployment` construct automatically configures IAM permissions following the principle of least privilege. When you specify a `destinationKeyPrefix`, the Lambda function's execution role will only receive permissions to access objects under that specific prefix, rather than the entire bucket.
197
+
198
+
```ts
199
+
declareconst destinationBucket:s3.Bucket;
200
+
201
+
// The Lambda will only have access to objects under 'app/static/*'
This scoped permission approach provides several security benefits:
210
+
Limits the blast radius if deployment credentials are compromised
211
+
Enables multiple independent deployments to the same bucket with isolation
212
+
Prevents accidental modification of objects outside the intended prefix
213
+
214
+
If no `destinationKeyPrefix` is specified, the Lambda will have access to all objects in the bucket (/*), maintaining backward compatibility with existing deployments.
215
+
187
216
## Prune
188
217
189
218
By default, files in the destination bucket that don't exist in the source will be deleted
0 commit comments