Hi all!
In an OpenStack environment I have some VMs and security groups created by a main.tf file. In a second step a want to run another main.tf which adds some rules to the SGs. The rules are based on IP addresses that are only available after running the first main.tf. But to create the security rules I have to refer to the already existing security group, which is not defined in my second main.tf.
I managed to fetch the IDs from the terraform.tfstate file using jq, but I fail to import them. Command is:
terraform import openstack_networking_secgroup_v2.foo id-from-tfstate
But when I run this I get āBefore importing this resource, please create its configuration in the root moduleā.
When I add the mentioned resource to the configuration it says āTerraform is already managing a remote object for openstack_networking_secgroup_v2.foo. To import to this address you must first remove the existing object from the stateā.
How can I use existing IDs in other main.tfs?
Thanks a lot,
Oliver