<p>I figured it out. The stub resource has to have a provider that is configured with the proper AWS region. All these security groups were in us-west-2. You need this:</p>
<pre><code>resource &quot;aws_security_group&quot; &quot;rds-launch-wizard-2&quot; { provider = aws.us_west_2 }
</code></pre>
<p>instead of this:</p>
<pre><code>resource &quot;aws_security_group&quot; &quot;rds-launch-wizard-2&quot; {}
</code></pre>
<p>This assumes you have a provider already configured thus:</p>
<pre><code>provider &quot;aws&quot; {
  region  = &quot;us-west-2&quot;
  alias   = &quot;us_west_2&quot;
}
</code></pre>

CC BY-SA 4.0
2021-05-28T14:55:36.060Z
2021-05-28T14:55:36.060Z
Chris W.
<p>I'm in the middle of importing a bunch of AWS resources into Terraform by doing the following:</p>
<ul>
<li>put a stub resource into a <code>.tf</code> file</li>
<li><code>terraform import</code> the resource (using the same address)</li>
<li>copy the relevant config out of the output of <code>terraform show -no-color</code> into a new <code>.tf</code> file</li>
</ul>
<p>This has worked before, but now I'm doing a bunch of security groups and it doesn't seem to be working. I'll do an import:</p>
<pre><code>terraform import aws_security_group.rds-launch-wizard-2 sg-XXXXXXXX
</code></pre>
<p>This succeeds. I would expect <code>aws_security_group.rds-launch-wizard-2</code> to show up in the output of <code>terraform state list</code> or <code>terraform show</code>, but it doesn't. I feel like maybe I'm missing something easy? Thanks for any help.</p>

<amazon-web-services><terraform>
Resources don't seem to show up in Terraform state after import
Chris W.
# Resources don't seem to show up in Terraform state after import

(Asked by: username_0 on 2021-05-28)

I'm in the middle of importing a bunch of AWS resources into Terraform by doing the following:

put a stub resource into a .tf file
terraform import the resource (using the same address)
copy the relevant config out of the output of terraform show -no-color into a new .tf file

This has worked before, but now I'm doing a bunch of security groups and it doesn't seem to be working. I'll do an import:
terraform import aws_security_group.rds-launch-wizard-2 sg-XXXXXXXX

This succeeds. I would expect aws_security_group.rds-launch-wizard-2 to show up in the output of terraform state list or terraform show, but it doesn't. I feel like maybe I'm missing something easy? Thanks for any help.

**Tags:** amazon-web-services, terraform


---

## 1 answers

### Answer by username_0 on 2021-05-28. Score: 2 | Accepted answer

I figured it out. The stub resource has to have a provider that is configured with the proper AWS region. All these security groups were in us-west-2. You need this:
resource "aws_security_group" "rds-launch-wizard-2" { provider = aws.us_west_2 }

instead of this:
resource "aws_security_group" "rds-launch-wizard-2" {}

This assumes you have a provider already configured thus:
provider "aws" {
  region  = "us-west-2"
  alias   = "us_west_2"
}


---

