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.

1 Answer 1


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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.