forked from matanolabs/matano
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a config option to not explicitly set S3 Block Public Access
Unblocks users who have org policies preventing usage of s3:PutPublicAccessBlock API (matanolabs#124). Signed-off-by: 🐼 Samrose Ahmed 🐼 <[email protected]>
- Loading branch information
1 parent
7373558
commit daee999
Showing
6 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IConstruct } from "constructs"; | ||
import * as cdk from "aws-cdk-lib"; | ||
import * as s3 from "aws-cdk-lib/aws-s3"; | ||
import { MatanoStack } from "../MatanoStack"; | ||
|
||
export class S3BlockPublicAccessAspect implements cdk.IAspect { | ||
public visit(node: IConstruct): void { | ||
const doSetBlockPublicAccess = (cdk.Stack.of(node) as MatanoStack).matanoConfig?.aws?.set_block_public_access !== false; | ||
|
||
if (node instanceof s3.CfnBucket) { | ||
if (node.publicAccessBlockConfiguration === undefined && doSetBlockPublicAccess) { | ||
node.publicAccessBlockConfiguration = { | ||
blockPublicAcls: true, | ||
blockPublicPolicy: true, | ||
ignorePublicAcls: true, | ||
restrictPublicBuckets: true, | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters