Control: API Gateway Method should have restrictive access
Description
This control checks whether the API Gateway Method is not open to broad unrestricted access.
Usage
Run the control in your terminal:
powerpipe control run terraform_aws_compliance.control.apigateway_method_restricts_open_accessSnapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_aws_compliance.control.apigateway_method_restricts_open_access --shareSQL
This control uses a named query:
select  address as resource,  case    when (attributes_std ->> 'http_method') != 'OPTIONS' and (attributes_std ->> 'authorization') = 'NONE' and (attributes_std ->> 'api_key_required') is null then 'alarm'    when (attributes_std ->> 'http_method') != 'OPTIONS' and (attributes_std ->> 'authorization') = 'NONE' and (attributes_std ->> 'api_key_required') = 'false' then 'alarm'    else 'ok'  end status,  split_part(address, '.', 2) || case    when (attributes_std ->> 'http_method') != 'OPTIONS' and (attributes_std ->> 'authorization') = 'NONE' and (attributes_std ->> 'api_key_required') is null then ' does not restrict open access'    when (attributes_std ->> 'http_method') != 'OPTIONS' and (attributes_std ->> 'authorization') = 'NONE' and (attributes_std ->> 'api_key_required') = 'false' then ' does not restrict open access'    else ' is restrictive with http_method as ' || (attributes_std ->> 'http_method') || ', authorization as ' || (attributes_std ->> 'authorization') || ' and api_key_required as ' || (attributes_std ->> 'api_key_required')  end || '.' reason    , path || ':' || start_linefrom  terraform_resourcewhere  type = 'aws_api_gateway_method';