hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

Home Page:https://www.terraform.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error importing ec2

DON77 opened this issue · comments

Terraform Version

terraform version
Terraform v1.4.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v5.54.1

Your version of Terraform is out of date! The latest version
is 1.8.5. You can update by downloading from https://www.terraform.io/downloads.html

Terraform Configuration Files

# Import the existing EC2 instance
  8 resource "aws_instance" "existing_ec2" {
  9   instance_id = real_instance_id
 10 }```


### Debug Output

can't replicate the issue to post output

### Expected Behavior

ec2 instance imported to terraform

### Actual Behavior

....o:sqs armensadoyan$ terraform import aws_instance.existing_ec2 i-00f2a3030eab61456
aws_instance.existing_ec2: Importing from ID "i-00f2a3030eab61456"...
aws_instance.existing_ec2: Import prepared!
  Prepared aws_instance for import
aws_instance.existing_ec2: Refreshing state... [id=i-00f2a3030eab61456]
╷
│ Error: no schema available for aws_iam_instance_profile_attachment.ec2_instance_profile_attachment to validate for self-references; this is a bug in Terraform and should be reported


### Steps to Reproduce

terraform init
terraform import:q

### Additional Context

_No response_

### References

_No response_

Hi @DON77,

Thanks for filing the issue. Without an example to reproduce the issue it's probably not going to be possible to pinpoint what may have gone wrong here. Can you show the configuration for the aws_iam_instance_profile_attachment in the error message, or how it might exist in the state?

I would also suggest updating to a current release of Terraform, since there have been many updates and fixes to the import system, most notably the addition of the import block for a more declarative process.