Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Clarity Terraform testing for checking resource tags

I am new to clarity test tool. I wanted to know whether clarity can be used to check whether tags are added to AWS resources or not.

I wrote the clarity test for tags like below:

Scenario: EC2 should have tag "application"
    Given Terraform
    And a "aws_instance" of type "resource"
    And "our component is <tag-key>"
    When attribute "tags" exists
    Then attribute "tags" matches regex  "tags.*<tag-key>*"

    Examples:
    | tag-key |
    | Name   |
    | application  |

But I got below error:

Feature: EC2 should have encrypted EBS volume attached

  Scenario: EC2 should have tag "application"        # main.feature:3
    Given Terraform                                  # terraform.go:92 -> *Match
    And a "aws_instance" of type "resource"          # terraform.go:279 -> *Match
    And "our component is <tag-key>"                 # clarity_test.go:49 -> noopComment
    Then attribute "tags" exists                     # terraform.go:304 -> *Match
    Then attribute "tags" matches regex  "<tag-key>"

    Examples:
      | tag-key     |
      | Name        |
      | application |

2 scenarios (2 undefined)
10 steps (8 passed, 2 undefined)
1.849441ms

You can implement step definitions for undefined steps with these snippets:

func attributeMatchesRegex(arg1, arg2 string) error {
        return godog.ErrPending
}

func FeatureContext(s *godog.Suite) {
        s.Step(`^attribute "([^"]*)" matches regex  "([^"]*)"$`, attributeMatchesRegex)
}

Any suggestions here would be helpful.

Regards,

TechGirl

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The documentation on clarity is pretty minimal regrettably and it mentions nothing about how to write a matcher for entries in an attribute of type map. There are also no examples in clarity's own test suite for this kind of matcher.

I could not find a concrete answer to this, but this might work (adjusting your matcher to match the existence of a tag by its name):

Then attribute "tags.<tag-key>" exists
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!