Terraform import error troubleshooting

1,043 views
Skip to first unread message

Craig Wampler

unread,
Jan 24, 2018, 11:28:08 AM1/24/18
to Terraform
Hello,

I posted this on ServerFault, but no response yet (https://serverfault.com/questions/893131/terrform-import-command-error-when-refreshing-state). Trying the mailing list...


I am trying to import resources from AWS into a simple terraform file.


Terraform file:

provider aws {
    access_key = "..."
    secret_key = "..."
    region = "us-east-1"
}

resource "aws_vpc" "Test_VPC" {

}


When I try to import the Test_VPC, using terraform import aws_vpc.Test_VPC vpc-xxxxxxxx(vpx-xxxxxxxx is a valid VPC ID), I get the following error:


aws_vpc.Test_VPC: Importing from ID "vpc-xxxxxxxx"...
aws_vpc.Test_VPC: Import complete!
  Imported aws_vpc (ID: vpc-xxxxxxxx)
aws_vpc.Test_VPC: Refreshing state... (ID: vpc-xxxxxxxx)
Error importing: 1 error(s) occurred:

* aws_vpc.Test_VPC (import id: vpc-xxxxxxxx): 1 error(s) occurred:

* import aws_vpc.Test_VPC result: vpc-xxxxxxxx: import aws_vpc.Test_VPC (id: vpc-xxxxxxxx): Terraform detected a resource with this ID doesn't
exist. Please verify the ID is correct. You cannot import non-existent
resources using Terraform import.


Any ideas what I'm doing wrong or how to troubleshoot this?

Tim Sattarov

unread,
Jan 24, 2018, 11:55:50 AM1/24/18
to terrafo...@googlegroups.com

Hi Craig,

as first step of debugging, I would check if those credentials from provider definition have access to that VPC.
something like:

aws ec2 describe-vpcs --vpc-ids vpc-xxxxx
-- 
Tim, the beardless keeper of keys and grounds @ AgileBits Inc.
~~~~~~~~~~~~~~~~~~~~~~~
1Password remembers all your passwords for you. It keeps your digital life secure and always available, safe behind the one password that only you know.
Create your 1Password account today at https://1password.com
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/4bb0288d-4ef9-4c39-b587-da1ac07dc5b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Craig Wampler

unread,
Jan 25, 2018, 5:30:22 PM1/25/18
to Terraform
Doht! Thanks Tim =)
Reply all
Reply to author
Forward
0 new messages