配置中不存在Terraform导入错误资源地址


provider "aws" {
region     = "us-east-1"
access_key = "My access key"
secret_key = "My secret key"
}
resource "aws_eip" "lb" {
instance = aws_instance.myweb-server-instance.id
vpc      = true
}
resource "aws_instance" "myweb-server-instance" {
ami               = "ami-085925f297f89fce1"
instance_type     = "t2.micro"
availability_zone = "us-east-1a"
}

导入的资源如下所示:

c:terraform> terraform import aws_eip.lb  
eipalloc-0ce64f24cdabcda76
aws_eip.lb: Importing from ID "eipalloc-0ce64f24cdabcda76"...
aws_eip.lb: Import prepared!
Prepared aws_eip for import
aws_eip.lb: Refreshing state... [id=eipalloc-0ce64f24cdabcda76]
Import successful!
These resources are now in
your Terraform state and will henceforth be managed by 
Terraform.

但是如果我复制上述代码并在Azure Devops管道中导入语句并运行,我会得到以下错误:

错误:资源地址" aws_ip .lb"不存在于配置。在导入该资源之前,请先创建其

请让我知道我错过了什么。谢谢。

我刚刚注意到我的配置文件(elastic_ip)没有。tf扩展名和terraform没有读取我的配置文件。在添加了.tf (elastic.tf)扩展名之后,现在导入在Azure Devops管道中工作了。

最新更新