Skip to content

fix(CKV2_AWS_19): allow EIPs attached to Network Load Balancers to pass#7564

Open
AlexanderSanin wants to merge 1 commit into
bridgecrewio:mainfrom
AlexanderSanin:fix/ckv2-aws-19-nlb-domain-vpc
Open

fix(CKV2_AWS_19): allow EIPs attached to Network Load Balancers to pass#7564
AlexanderSanin wants to merge 1 commit into
bridgecrewio:mainfrom
AlexanderSanin:fix/ckv2-aws-19-nlb-domain-vpc

Conversation

@AlexanderSanin

Copy link
Copy Markdown
Contributor

Summary

  • CKV2_AWS_19 was producing a false positive for aws_eip resources with domain = "vpc" when the EIP is used in the subnet_mapping.allocation_id of an aws_lb (Network Load Balancer).
  • The check already validates VPC membership correctly (via vpc = true or domain = "vpc"), but the connection check only allowed aws_instance, aws_nat_gateway, aws_transfer_server, and aws_eip_association — not NLBs.
  • Add aws_lb and aws_alb as valid connected resource types in the YAML definition so EIPs legitimately assigned to NLBs are no longer flagged.

Closes #7532

Test plan

  • Added aws_eip.ok_eip_nlb test resource in tests/terraform/graph/checks/resources/EIPAllocatedToVPCAttachedEC2/main.tf — an EIP with domain = "vpc" referenced by an aws_lb via subnet_mapping.allocation_id
  • Updated expected.yaml to include aws_eip.ok_eip_nlb in the pass list
  • Existing test test_EIPAllocatedToVPCAttachedEC2 passes locally with the new test case

CKV2_AWS_19 was reporting a false positive for EIPs with `domain = "vpc"`
that are used in the `subnet_mapping.allocation_id` of an `aws_lb` (Network
Load Balancer). The check correctly verified VPC membership via the
`domain` attribute, but the connection check only permitted aws_instance,
aws_nat_gateway, aws_transfer_server, and aws_eip_association — not NLBs.

Add `aws_lb` and `aws_alb` as valid connected resource types so that EIPs
attached to Network Load Balancers (a legitimate use case) are no longer
flagged as violations.

Add a corresponding test case with an NLB `subnet_mapping` that references
the EIP via `allocation_id`.

Closes bridgecrewio#7532

Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>
@AlexanderSanin

Copy link
Copy Markdown
Contributor Author

Hey @yuvalmich @omriyoffe-panw @maxamel. Could you, please, have a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CKV2_AWS_19 still fails when "domain = vpc"

1 participant