tldr;
Need to import a security group and and a subnet given either a couple tags OR a known resource group.
For a SecurityGroup and a Subnet I've created a resourcegroup
given this terraform module definition:
resource "aws_resourcegroups_group" "private_networking" {
name = "us-blog-private-networking"
resource_query {
query = <<JSON
{
"ResourceTypeFilters": [
"AWS::EC2::SecurityGroup",
"AWS::EC2::Subnet"
],
"TagFilters": [
{
"Key": "Property",
"Values": ["us-blog-production"]
},
{
"Key": "Private",
"Values": [true]
}
]
}
JSON
}
}
The fact that neither SecurityGroup or Subnet would get fromXXAttributes
methods allowing tagging made me create a resource group.
Then I'm trying to find a way to fetch this resources and get a reference. I'd expect a L2 construct API for resourcegroups but only L1 is available.
All I got is CfnGroup
which wouldn't have an static method to fetch the group.
I'd like to avoid having to harcode networking elements ids or going redundant creating SSM parameters with such.
What's the most appropriate approach?