“刷新状态”时 Terrform Import 命令出错

“刷新状态”时 Terrform Import 命令出错

我正在尝试将资源从 AWS 导入到一个简单的 terraform 文件中。

Terraform 文件:

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

resource "aws_vpc" "Test_VPC" {

}

当我尝试Test_VPC使用terraform import aws_vpc.Test_VPC vpc-xxxxxxxx(vpx-xxxxxxxx 是有效的 VPC ID)导入时,出现以下错误:

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.

你知道我做错了什么或如何解决这个问题吗?

答案1

供后人参考,如果其他人遇到这种情况:我使用的凭据没有足够的权限。运行后,aws ec2 describe-vpcs -vpc-ids vpc-xxxxxxxx这个问题就变得很明显了。

相关内容