Control: EC2 Spot Fleet requests with launch parameters should enable encryption for attached EBS volumes
Description
This control checks whether an Amazon EC2 Spot Fleet request that specifies launch parameters is configured to enable encryption for all Amazon Elastic Block Store (Amazon EBS) volumes attached to EC2 instances. The control fails if the Spot Fleet request specifies launch parameters and doesn't enable encryption for one or more EBS volumes specified in the request.
Usage
Run the control in your terminal:
powerpipe control run aws_compliance.control.ec2_spot_fleet_request_with_launch_parameter_ebs_encryption_enabledSnapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run aws_compliance.control.ec2_spot_fleet_request_with_launch_parameter_ebs_encryption_enabled --shareSQL
This control uses a named query:
select  spot_fleet_request_id as resource,  case    when launch_specifications is null then 'skip'    when exists (      select 1      from jsonb_array_elements(launch_specifications) spec,           jsonb_array_elements(spec -> 'BlockDeviceMappings') bdm      where (bdm -> 'Ebs' ->> 'Encrypted')::boolean = false         or bdm -> 'Ebs' ->> 'Encrypted' is null    ) then 'alarm'    else 'ok'  end as status,  case    when launch_specifications is null then title || ' does not define any launch specifications.'    when exists (      select 1      from jsonb_array_elements(launch_specifications) spec,           jsonb_array_elements(spec -> 'BlockDeviceMappings') bdm      where (bdm -> 'Ebs' ->> 'Encrypted')::boolean = false         or bdm -> 'Ebs' ->> 'Encrypted' is null    )      then title || ' has launch parameters with unencrypted EBS volumes.'    else title || ' has all launch parameters with encrypted EBS volumes.'  end as reason    , region, account_idfrom  aws_ec2_spot_fleet_request;