Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(s3): explicitly call out the Bucket.grantWrite() change in the docs #12737

Merged
merged 4 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ used by CDK Pipelines) must upgrade their bootstrap stacks. Run `cdk bootstrap`.
## [1.85.0](https://github.com/aws/aws-cdk/compare/v1.84.0...v1.85.0) (2021-01-14)

* **s3-deployment**: This version includes an important update, please upgrade to prevent deployment failure. This is in prepartion of Lambda deprecation of the request module in boto, more details are available in [AWS blog](https://aws.amazon.com/blogs/compute/upcoming-changes-to-the-python-sdk-in-aws-lambda/). Note, users of versions < `1.81.0` will not be impacted by this deprecation, but are still encouraged to upgrade to the latest version.
* **s3**: The `grantWrite()` and `grantReadWrite()` methods no longer add the `s3:PutObject*` permissions that included `s3:PutObjectAcl`,
which could be used to grant read/write object access to IAM principals in other accounts.
This change is gated behind the `@aws-cdk/aws-s3:grantWriteWithoutAcl` feature flag,
so make sure to set it to `true` in the `context` key of your `cdk.json` file when upgrading.
If you still need the principal to have `s3:PutObjectAcl` permissions after upgrading,
use the new `grantPutAcl()` method.

### Features

Expand Down
35 changes: 16 additions & 19 deletions packages/@aws-cdk/aws-s3/lib/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ export interface IBucket extends IResource {
* If encryption is used, permission to use the key to encrypt the contents
* of written files will also be granted to the same principal.
*
* Before CDK version 1.85.0, this method granted the `s3:PutObject*` permission that included `s3:PutObjectAcl`,
* which could be used to grant read/write object access to IAM principals in other accounts.
* If you want to get rid of that behavior, update your CDK version to 1.85.0 or later,
* and make sure the `@aws-cdk/aws-s3:grantWriteWithoutAcl` feature flag is set to `true`
* in the `context` key of your cdk.json file.
* If you've already updated, but still need the principal to have permissions to modify the ACLs,
* use the {@link grantPutAcl} method.
*
* @param identity The principal
* @param objectsKeyPattern Restrict the permission to a certain key pattern (default '*')
*/
Expand Down Expand Up @@ -190,6 +198,14 @@ export interface IBucket extends IResource {
* If an encryption key is used, permission to use the key for
* encrypt/decrypt will also be granted.
*
* Before CDK version 1.85.0, this method granted the `s3:PutObject*` permission that included `s3:PutObjectAcl`,
* which could be used to grant read/write object access to IAM principals in other accounts.
* If you want to get rid of that behavior, update your CDK version to 1.85.0 or later,
* and make sure the `@aws-cdk/aws-s3:grantWriteWithoutAcl` feature flag is set to `true`
* in the `context` key of your cdk.json file.
* If you've already updated, but still need the principal to have permissions to modify the ACLs,
* use the {@link grantPutAcl} method.
*
* @param identity The principal
* @param objectsKeyPattern Restrict the permission to a certain key pattern (default '*')
*/
Expand Down Expand Up @@ -587,15 +603,6 @@ abstract class BucketBase extends Resource implements IBucket {
this.arnForObjects(objectsKeyPattern));
}

/**
* Grant write permissions to this bucket to an IAM principal.
*
* If encryption is used, permission to use the key to encrypt the contents
* of written files will also be granted to the same principal.
*
* @param identity The principal
* @param objectsKeyPattern Restrict the permission to a certain key pattern (default '*')
*/
public grantWrite(identity: iam.IGrantable, objectsKeyPattern: any = '*') {
return this.grant(identity, this.writeActions, perms.KEY_WRITE_ACTIONS,
this.bucketArn,
Expand Down Expand Up @@ -632,16 +639,6 @@ abstract class BucketBase extends Resource implements IBucket {
this.arnForObjects(objectsKeyPattern));
}

/**
* Grants read/write permissions for this bucket and it's contents to an IAM
* principal (Role/Group/User).
*
* If an encryption key is used, permission to use the key for
* encrypt/decrypt will also be granted.
*
* @param identity The principal
* @param objectsKeyPattern Restrict the permission to a certain key pattern (default '*')
*/
public grantReadWrite(identity: iam.IGrantable, objectsKeyPattern: any = '*') {
const bucketActions = perms.BUCKET_READ_ACTIONS.concat(this.writeActions);
// we need unique permissions because some permissions are common between read and write key actions
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cx-api/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const KMS_DEFAULT_KEY_POLICIES = '@aws-cdk/aws-kms:defaultKeyPolicies';
/**
* Change the old 's3:PutObject*' permission to 's3:PutObject' on Bucket,
* as the former includes 's3:PutObjectAcl',
* which allows changing the visibility of an object written to the Bucket.
* which could be used to grant read/write object access to IAM principals in other accounts.
* Use a feature flag to make sure existing customers who might be relying
* on the overly-broad permissions are not broken.
*/
Expand Down