-
|
Hello, I am currently attempting to import existing security group rules using terragrunt import command. This worked without an issue when I did the same for a cloudwatch log group. However, with security group rules I am not able to do this. Can you please let me know what I am doing wrong here. OUTPUT OF TERRAGRUNT PLAN: The IPs "10.8.80.0/21", "10.8.88.0/21", "10.8.96.0/21" are already added manually from the console. When I applied, the security group lost all the ingress rules. When I planned next time it showed the ingress rules ready to be applied. Running apply one more time recreated the rules properly, but I don't want to do that in my production environment - therefore trying the import option. COMMAND: ERROR: |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
|
Hi @sewmiuraj, First of all - thank you for the outstanding bug report. We really appreciate your taking the time to fill in all this helpful information. I think we know what might be going on here: Your import command is very close - but I'm guessing you went to these docs like me and saw the examples mentioning the However, in your case the correct address is This means your command should be:
Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
|
Hi @zackproser , Thank you for your response. As you've suggested, I did refer to the documentation that you've mentioned. I did try the solution you provided as well, however it still returns an error: zsh: no matches found: aws_security_group_rule.allow_connections_from_cidr_blocks[0] Could this be because it's unable to find the source_securtiy_group_id? On another note, I also tried zsh: no matches found: module.database.aws_security_group_rule.allow_connections_from_cidr_blocks[0] |
Beta Was this translation helpful? Give feedback.
-
|
Hi @sewmiuraj Could you please try running the
This should output the correct addresses for resources that we can use with the |
Beta Was this translation helpful? Give feedback.
-
|
Hi @zackproser, I was able to use terragrunt state list to find the address. It returned: PLAN BEFORE IMPORT IMPORT COMMAND THAT WORKED PLAN AFTER IMPORT |
Beta Was this translation helpful? Give feedback.
-
|
Small Update - I was able to get the import command to work with [0] by adding '' around the address. But the import fails with error. Import does work if I use [3] instead, but then it would prompt to destroy it in the next plan - as explained in my last reply. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, import in [3] works since resource is added as a new element in list, but later is proposed for removal since it is not defined in terraform files... Can be attempted to remove from state reference to and attempted to re-import it back |
Beta Was this translation helpful? Give feedback.
Hi @zackproser,
I was able to use terragrunt state list to find the address. It returned:
module.database.aws_security_group_rule.allow_connections_from_cidr_blocks[0], but the command only worked without [0].PLAN BEFORE IMPORT