Skip to content

Interpolation issue when attaching aws_security_group_rule to aws_security_group created in module #190

@anthonycolon25

Description

@anthonycolon25

Description :
I have a TF template which creates an aws_security_group within a module and outputs the security group id (sg_id). From my main TF template at am creating an aws_security_group_rule and associating it to the security group created within the module. I am trying to test that tcp port 22 is not open to 0.0.0.0/0. The tests always passes even when the CIDR block of the aws_security_group_rule is set to 0.0.0.0/0.

If I create the security group within my main TF template and associate the aws_security_group_rule it will correctly fail when set to 0.0.0.0/0.

It would seem that it is not associating the aws_security_group_rule to the module's aws_security_group. Any ideas.

To Reproduce

  1. I was using an older terraform-compliance version (1.0.34) but tried the latest version and get the same result.
Feature: Security Groups Rules should be used to protect services/instances
  In order to improve security
  As engineers
  We'll use AWS Security Group Rules as a Perimeter Defense

  Scenario Outline: Well-known insecure protocol exposure on Public Network for ingress traffic
    Given I have AWS Security Group defined
  	When it contains ingress
    Then it must not have <proto> protocol and port <portNumber> for 0.0.0.0/0

  Examples:
    | ProtocolName | proto | portNumber |
    | HTTP         | tcp   | 80         |
    | HTTPS        | tcp   | 443        |
    | Telnet       | tcp   | 23         |
    | SSH          | tcp   | 22         |
    | MySQL        | tcp   | 3306       |
    | MSSQL        | tcp   | 1443       |
    | NetBIOS      | tcp   | 139        |
    | RDP          | tcp   | 3389       |
    | Jenkins Slave| tcp   | 50000      |

I am attaching my plan.json.

plan.out.json.txt

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions