turbot/steampipe-mod-terraform-aws-compliance

Control: S3 bucket default encryption should be enabled

Description

To help protect data at rest, ensure default encryption is enabled for your Amazon Simple Storage Service (Amazon S3) buckets.

Usage

Run the control in your terminal:

powerpipe control run terraform_aws_compliance.control.s3_bucket_default_encryption_enabled

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run terraform_aws_compliance.control.s3_bucket_default_encryption_enabled --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'), '') = '' then 'alarm'
when coalesce(trim(attributes_std -> 'server_side_encryption_configuration' -> 'rule' -> 'apply_server_side_encryption_by_default' ->> 'sse_algorithm'), '') not in ('aws:kms', 'AES256') 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') in ('aws:kms', 'AES256') then ' default encryption enabled'
else ' default encryption disabled'
end || '.' as reason
, path || ':' || start_line
from
terraform_resource
where
type = 'aws_s3_bucket';

Tags