I am currently trying to move existing custom automation system for creating set of cloud resources on AWS to terraform. Currently system creates several security groups with specific set of rules that are shared among all other cloud resources.
Let's say that in us-east-1 region we have security groups A, B and C.
Every time a new set of resources is created they should be tied to those groups, ie if they already exist during creation system should use them and not create new ones.
So how would one resolve that case in terraform? Would it be needed to check for presence of those groups and than do terraform import, or something else?
CodePudding user response:
You should have a "shared" set of resources in a separate Terraform template that you deploy and manage separately. Your other Terraform templates will depend on the "shared" resources already having been deployed to AWS.
Then in your other Terraform templates, they would use Terraform data source lookups to find those resources so they can reference them.