cli icon indicating copy to clipboard operation
cli copied to clipboard

How to check if Param1 value is same as Param2 value?

Open vrbcntrl opened this issue 4 years ago • 3 comments

** Question : ** Hi,

I have the below use case where I need to check peer_vpc_id value is same as vpc_id value

resource "aws_vpc_peering_connection" "foo" {
  peer_owner_id = var.peer_owner_id
  peer_vpc_id   = aws_vpc.bar.id
  vpc_id        = aws_vpc.foo.id
  auto_accept   = true

  tags = {
    Name = "VPC Peering between foo and bar"
  }
}

resource "aws_vpc" "foo" {
  cidr_block = "10.1.0.0/16"
}

resource "aws_vpc" "bar" {
  cidr_block = "10.2.0.0/16"
}

In the above example, peer_vpc_id = aws_vpc.bar.id and vpc_id = aws_vpc.foo.id so my Scenario should FAIL However, if their values were to be same, Ex: peer_vpc_id = aws_vpc.foo.id and vpc_id = aws_vpc.foo.id then my Scenario should PASS

wondering if there is a way to implement this in TC. I'd appreciate any help on this.

Thanks!

vrbcntrl avatar Aug 05 '20 19:08 vrbcntrl

Hi @vrbcntrl,

Thanks for the issue. This is something that had me surprised before for not existing in Terraform-Compliance yet.

The closest I could get to the requirement is:

Scenario: using in step variables
	Given I have aws_vpc_peering_connection defined
	Then it must have peer_vpc_id
	And it must be in {aws_vpc_peering_connection.values.vpc_id}
	And it must cover {aws_vpc_peering_connection.values.vpc_id}

However, this scenario checks whether the set of all peer_vpc_ids over all aws_vpc_peering_connections is equal to the set of all vpc_ids over all aws_vpc_peering_connections

Then it must be in haystack

I do think we should be able to compare two things from the plan. However, it's a bit counter-intuitive to the filter and drill flow of TC.

I'm going to add this issue to our backlog and ping it if we decide on adding the functionality.

Kudbettin avatar Aug 12 '20 17:08 Kudbettin

Thank you @Kudbettin for looking into the issue. Please let me know when you have a possible solution for the above requirement.

Have a great day!

vrbcntrl avatar Aug 12 '20 19:08 vrbcntrl

agree this would be nice functionality. Especially if we can compare to value that was never in haystack or that was filtered out by earlier when clauses

sleightsec avatar Dec 21 '20 15:12 sleightsec