Skip to content

Commit

Permalink
feat(config): S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED managed rule (a…
Browse files Browse the repository at this point in the history
…ws#18890)

> Currently [ManagedRuleIdentifiers](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-config.ManagedRuleIdentifiers.html) doesn't support identifier for s3-bucket-level-public-access-prohibited managed rule (S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED). The documentation for this rule is [here](https://docs.aws.amazon.com/config/latest/developerguide/s3-bucket-level-public-access-prohibited.html)

Copied from: aws#18888 
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
sringel authored and TikiTDO committed Feb 21, 2022
1 parent dcf1707 commit 016d59e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-config/lib/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,13 @@ export class ManagedRuleIdentifiers {
* @see https://docs.aws.amazon.com/config/latest/developerguide/s3-account-level-public-access-blocks.html
*/
public static readonly S3_ACCOUNT_LEVEL_PUBLIC_ACCESS_BLOCKS = 'S3_ACCOUNT_LEVEL_PUBLIC_ACCESS_BLOCKS';
/**
* Checks if Amazon Simple Storage Service (Amazon S3) buckets are publicly accessible. This rule is
* NON_COMPLIANT if an Amazon S3 bucket is not listed in the excludedPublicBuckets parameter and bucket level
* settings are public.
* @see https://docs.aws.amazon.com/config/latest/developerguide/s3-bucket-level-public-access-prohibited.html
*/
public static readonly S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED = 'S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED';
/**
* Checks that the Amazon Simple Storage Service bucket policy does not allow
* blocked bucket-level and object-level actions on resources in the bucket
Expand Down
20 changes: 20 additions & 0 deletions packages/@aws-cdk/aws-config/test/managed-rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,23 @@ describe('ec2 instance', () => {
});
});
});

describe('s3 bucket level', () => {
test('public access prohibited', () => {
// GIVEN
const stack = new cdk.Stack();

// WHEN
new config.ManagedRule(stack, 'S3BucketLevelPublicAccessProhibited', {
identifier: config.ManagedRuleIdentifiers.S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Config::ConfigRule', {
Source: {
Owner: 'AWS',
SourceIdentifier: config.ManagedRuleIdentifiers.S3_BUCKET_LEVEL_PUBLIC_ACCESS_PROHIBITED,
},
});
});
});

0 comments on commit 016d59e

Please sign in to comment.