I'm trying to do a complex regex for filtering amis when using a data.tf, this is the code I have
data "aws_ami" "main" {
most_recent = true
name_regex = var.ami_regex
owners = var.owners
}
Then I'm trying to send a proper regex inside the var.ami_regex without success, I have the following naming convention for my amis.
1 ) centos-7-java-testing-DATE
2 ) centos-7-java-pci-testing-DATE
And as the *2 is created after the 1, if I want to match the 1 inside my code, It will match the 2, because of the date, So my idea is to add a proper regex to exclude the one that includes the "pci" word on the name, I tried the following regex ^centos-7-java-(?!.*pci).* but no luck, looks like terraform doesn't like that kind of regex.
The error:
Error: "name_regex": error parsing regexp: invalid or unsupported Perl syntax: `(?!
I would think the best practice is to declare both AMI as resources and either:
terraform importthem or,importblockDepending on your Terraform version.
Alternatively, have you considered using a ternary operator?