Skip to content

Commit

Permalink
feat: Enable Block Public access for all Access <> PublicRead (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig authored Aug 16, 2022
1 parent 4088c70 commit b2879c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Conditions:
HasPartitionPublic: !Equals [!Ref 'AWS::Partition', 'aws']
HasPartitionChina: !Equals [!Ref 'AWS::Partition', 'aws-cn']
HasPartitionUsGov: !Equals [!Ref 'AWS::Partition', 'aws-us-gov']
HasPublicAccessBlock: !Not [!Condition HasPublicReadAccess]
Resources:
PolicyLambdaEventTarget1:
Type: 'AWS::IAM::Policy'
Expand Down Expand Up @@ -223,6 +224,7 @@ Resources:
- !If [HasLambdaEventTargetLambdaModule2, {Event: !Ref LambdaEventType2, Function: {'Fn::ImportValue': !Sub '${LambdaEventTargetLambdaModule2}-Arn'}}, !Ref 'AWS::NoValue']
- !If [HasLambdaEventTargetLambdaModule3, {Event: !Ref LambdaEventType3, Function: {'Fn::ImportValue': !Sub '${LambdaEventTargetLambdaModule3}-Arn'}}, !Ref 'AWS::NoValue']
# QueueConfigurations: # Using SQS as a target does not work because the SQS queue policy can not be restricted to an AWS account (only to single S3 buckets which is not possible because we don't have that information (cyclic dependency)).
PublicAccessBlockConfiguration: !If [HasPublicAccessBlock, {BlockPublicAcls: true, BlockPublicPolicy: true, IgnorePublicAcls: true, RestrictPublicBuckets: true}, !Ref 'AWS::NoValue'] # AWS Foundational Security Best Practices v1.0.0 S3.8
VersioningConfiguration: !If [HasVersioning, {Status: Enabled}, !If [HadVersioning, {Status: Suspended}, !Ref 'AWS::NoValue']]
BucketEncryption: !If [HasKmsKeyModule, {ServerSideEncryptionConfiguration: [{ServerSideEncryptionByDefault: {KMSMasterKeyID: {'Fn::ImportValue': !Sub '${KmsKeyModule}-Arn'}, SSEAlgorithm: 'aws:kms'}}]}, !Ref 'AWS::NoValue']
BucketPolicyPrivate:
Expand Down Expand Up @@ -388,7 +390,7 @@ Outputs:
ModuleId:
Value: 's3-bucket'
ModuleVersion:
Value: '1.6.0'
Value: '1.7.0'
StackName:
Value: !Ref 'AWS::StackName'
Arn:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfn-modules/s3-bucket",
"version": "1.6.0",
"version": "1.7.0",
"description": "AWS S3 bucket with encryption and backups",
"author": "Michael Wittig <michael@widdix.de>",
"license": "Apache-2.0",
Expand Down

0 comments on commit b2879c8

Please sign in to comment.