Control: VPC security groups should be associated with at least one ENI
Description
This rule ensures the security groups are attached to an Amazon Elastic Compute Cloud (Amazon EC2) instance or to an ENI. This rule helps monitor unused security groups in the inventory and the management of your environment.
Usage
Run the control in your terminal:
powerpipe control run terraform_aws_compliance.control.vpc_security_group_associated_to_eniSnapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_aws_compliance.control.vpc_security_group_associated_to_eni --shareSQL
This control uses a named query:
select  address as resource,  case    when name in (select split_part((jsonb_array_elements(attributes_std -> 'security_groups')::text), '.', 2) from terraform_resource where type = 'aws_network_interface') then 'ok'    else 'alarm'  end status,  split_part(address, '.', 2) || case  when name in (select split_part((jsonb_array_elements(attributes_std -> 'security_groups')::text), '.', 2) from terraform_resource where type = 'aws_network_interface') then ' has attached ENI(s)'  else ' has no attached ENI(s)'  end || '.' as reason    , path || ':' || start_linefrom  terraform_resourcewhere  type = 'aws_security_group';