I'm using Packer to create AMIs with baked in services. I know I can test the end product using serverspec, but I have a number of naming and tagging standards I'd like to enforce before the AMI is created. Such as version, OS, name etc. These values are held in a JSON file which is fed into packer during image creation.
My question is, is there a way to test/ pass in these values to Rspec and then use regex matcher to validate them. For example if I had in my variables.json
{"version: "0.1.0", "region": "eu-west-1"}
How could I check it using Rspecs regex matcher like
expect(region).to match(/^[a-z]{2}-[a-z]+-[0-9]$/)