Skip to content

Commit

Permalink
fix(s3): updating blockPublicAccess to enable default true settings (…
Browse files Browse the repository at this point in the history
…under feature flag)
  • Loading branch information
Ike Nefcy committed Feb 27, 2025
1 parent 340c231 commit 087488a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { App, Stack } from 'aws-cdk-lib';
import { BlockPublicAccess, Bucket } from 'aws-cdk-lib/aws-s3';
import { S3_BLOCK_PUBLIC_ACCESS_OPTION_AUTO_TRUE } from 'aws-cdk-lib/cx-api';

const app = new App();
const app = new App({
context: {
[S3_BLOCK_PUBLIC_ACCESS_OPTION_AUTO_TRUE]: true,
},
});

const stack = new Stack(app, 'aws-cdk-s3-bucket-block-access');

Expand Down
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Flags come in three types:
| [@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections](#aws-cdkaws-iamoidcrejectunauthorizedconnections) | When enabled, the default behaviour of OIDC provider will reject unauthorized connections | 2.177.0 | (fix) |
| [@aws-cdk/core:enableAdditionalMetadataCollection](#aws-cdkcoreenableadditionalmetadatacollection) | When enabled, CDK will expand the scope of usage data collected to better inform CDK development and improve communication for security concerns and emerging issues. | 2.178.0 | (config) |
| [@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy](#aws-cdkaws-lambdacreatenewpolicieswithaddtorolepolicy) | When enabled, Lambda will create new inline policies with AddToRolePolicy instead of adding to the Default Policy Statement | 2.180.0 | (fix) |
| [@aws-cdk/aws-s3BlockPublicAccessOptionAutoTrue](#aws-cdkaws-s3blockpublicaccessoptionautotrue) | When enabled, setting any combination of options for BlockPublicAccess will automatically set true for any options not defined. | V2NEXT | (fix) |
| [@aws-cdk/aws-s3:blockPublicAccessOptionAutoTrue](#aws-cdkaws-s3blockpublicaccessoptionautotrue) | When enabled, setting any combination of options for BlockPublicAccess will automatically set true for any options not defined. | V2NEXT | (fix) |

<!-- END table -->

Expand Down Expand Up @@ -169,7 +169,7 @@ The following json shows the current recommended set of flags, as `cdk init` wou
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true,
"@aws-cdk/aws-s3BlockPublicAccessOptionAutoTrue": true
"@aws-cdk/aws-s3:blockPublicAccessOptionAutoTrue": true
}
}
```
Expand Down Expand Up @@ -1707,7 +1707,7 @@ This solves an issue where a circular dependency could occur if adding lambda to
| 2.180.0 | `false` | `true` |


### @aws-cdk/aws-s3BlockPublicAccessOptionAutoTrue
### @aws-cdk/aws-s3:blockPublicAccessOptionAutoTrue

*When enabled, setting any combination of options for BlockPublicAccess will automatically set true for any options not defined.* (fix)

Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/cx-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ _cdk.json_
}
```

* `@aws-cdk/aws-s3BlockPublicAccessOptionAutoTrue`
* `@aws-cdk/aws-s3:blockPublicAccessOptionAutoTrue`

When BlockPublicAccess is not set at all, s3's default behavior will be to set all options to true in aws console.
The previous behavior in cdk before this feature was; if only some of the BlockPublicAccessOptions were set (not all 4), then the ones undefined would default to false.
Expand All @@ -641,7 +641,7 @@ _cdk.json_
```json
{
"context": {
"@aws-cdk/aws-s3BlockPublicAccessOptionAutoTrue": true
"@aws-cdk/aws-s3:blockPublicAccessOptionAutoTrue": true
}
}
```
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/cx-api/lib/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const ALB_DUALSTACK_WITHOUT_PUBLIC_IPV4_SECURITY_GROUP_RULES_DEFAULT = '@
export const IAM_OIDC_REJECT_UNAUTHORIZED_CONNECTIONS = '@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections';
export const ENABLE_ADDITIONAL_METADATA_COLLECTION = '@aws-cdk/core:enableAdditionalMetadataCollection';
export const LAMBDA_CREATE_NEW_POLICIES_WITH_ADDTOROLEPOLICY = '@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy';
export const S3_BLOCK_PUBLIC_ACCESS_OPTION_AUTO_TRUE = '@aws-cdk/aws-s3BlockPublicAccessOptionAutoTrue';
export const S3_BLOCK_PUBLIC_ACCESS_OPTION_AUTO_TRUE = '@aws-cdk/aws-s3:blockPublicAccessOptionAutoTrue';

export const FLAGS: Record<string, FlagInfo> = {
//////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion packages/aws-cdk-lib/recommended-feature-flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@
"@aws-cdk/aws-elasticloadbalancingV2:albDualstackWithoutPublicIpv4SecurityGroupRulesDefault": true,
"@aws-cdk/aws-iam:oidcRejectUnauthorizedConnections": true,
"@aws-cdk/core:enableAdditionalMetadataCollection": true,
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true
"@aws-cdk/aws-lambda:createNewPoliciesWithAddToRolePolicy": true,
"@aws-cdk/aws-s3:blockPublicAccessOptionAutoTrue": true
}

0 comments on commit 087488a

Please sign in to comment.