Control: S3 bucket default encryption should be enabled with KMS
Description
To help protect data at rest, ensure encryption is enabled for your Amazon Simple Storage Service (Amazon S3) buckets using KMS.
Usage
Run the control in your terminal:
powerpipe control run terraform_aws_compliance.control.s3_bucket_default_encryption_enabled_kms
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_aws_compliance.control.s3_bucket_default_encryption_enabled_kms --share
SQL
This control uses a named query:
select address as resource, case when coalesce(trim(attributes_std -> 'server_side_encryption_configuration' -> 'rule' -> 'apply_server_side_encryption_by_default' ->> 'sse_algorithm'), '') <> 'aws:kms' then 'alarm' else 'ok' end as status, split_part(address, '.', 2) || case when coalesce(trim(attributes_std -> 'server_side_encryption_configuration' -> 'rule' -> 'apply_server_side_encryption_by_default' ->> 'sse_algorithm'), '') = '' then ' ''sse_algorithm'' is not defined' when trim(attributes_std -> 'server_side_encryption_configuration' -> 'rule' -> 'apply_server_side_encryption_by_default' ->> 'sse_algorithm') = 'aws:kms' then ' default encryption with KMS enabled' else ' default encryption with KMS disabled' end || '.' as reason , path || ':' || start_linefrom terraform_resourcewhere type = 'aws_s3_bucket';