id: s3-bucket-key info: name: S3 Bucket Key not enabled author: princechaddha severity: medium description: | This template verifies if Amazon S3 buckets have bucket keys enabled to optimize the cost of AWS Key Management Service (SSE-KMS) for server-side encryption reference: - https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html tags: cloud,devops,aws,amazon,s3,aws-cloud-config flow: | code(1) for(let bucketName of iterate(template.buckets)){ set("bucket", bucketName) code(2) } self-contained: true code: - engine: - sh - bash source: | aws s3api list-buckets --query 'Buckets[*].Name' extractors: - type: json # type of the extractor internal: true name: buckets json: - '.[]' - engine: - sh - bash source: | aws s3api get-bucket-encryption --bucket cc-prod-log-bucket --query 'ServerSideEncryptionConfiguration.Rules[?ApplyServerSideEncryptionByDefault.SSEAlgorithm==`aws:kms`].BucketKeyEnabled' matchers: - type: word words: - false extractors: - type: dsl dsl: - '"Key is not enabled for S3 Bucket " + bucket' # digest: 490a0046304402207628f02f223a9c45013004373f631bfe358fe0898a91b4558b461cdbcb0cb33f02204c02ff4be552778912c6b81a4d7f06b0436bf0facd4066dd1b7b6a60c7fe8727:922c64590222798bb761d5b6d8e72950