Skip to content

Terraform Import bug #38660

@ehedges

Description

@ehedges

Terraform Version

Terraform v1.15.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v6.47.0

Your version of Terraform is out of date! The latest version
is 1.15.5. You can update by downloading from https://developer.hashicorp.com/terraform/install

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
}

import {
  to = aws_instance.one
  id = "i-0aef1c99938c2b6ca"
}

Debug Output

aws_instance.one: Refreshing state... [id=i-0485b1463c0c0b364]
aws_instance.one: Refreshing state... [id=i-0485b1463c0c0b364]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform planned the following actions, but then encountered a problem:

  # aws_instance.one will be destroyed
  # (because aws_instance.one is not in configuration)
  - resource "aws_instance" "one" {
      - ami                                  = "ami-00e801948462f718a" -> null
      - arn                                  = "arn:aws:ec2:us-east-1:123936123826:instance/i-0485b1463c0c0b364" -> null
      - associate_public_ip_address          = false -> null
      - availability_zone                    = "us-east-1d" -> null
      - disable_api_stop                     = false -> null
      - disable_api_termination              = false -> null
      - ebs_optimized                        = false -> null
      - force_destroy                        = false -> null
      - get_password_data                    = false -> null
      - hibernation                          = false -> null
      - id                                   = "i-0485b1463c0c0b364" -> null
      - instance_initiated_shutdown_behavior = "stop" -> null
      - instance_state                       = "stopped" -> null
      - instance_type                        = "t2.micro" -> null
      - ipv6_address_count                   = 0 -> null
      - ipv6_addresses                       = [] -> null
      - monitoring                           = false -> null
      - placement_partition_number           = 0 -> null
      - primary_network_interface_id         = "eni-0b34b1776a84fbd47" -> null
      - private_dns                          = "ip-172-31-32-246.ec2.internal" -> null
      - private_ip                           = "172.31.32.246" -> null
      - region                               = "us-east-1" -> null
      - secondary_private_ips                = [] -> null
      - security_groups                      = [
          - "default",
        ] -> null
      - source_dest_check                    = true -> null
      - subnet_id                            = "subnet-02b6e1b92f0d4afe3" -> null
      - tags                                 = {
          - "Name" = "raham-server"
        } -> null
      - tags_all                             = {
          - "Name" = "raham-server"
        } -> null
      - tenancy                              = "default" -> null
      - user_data_replace_on_change          = false -> null
      - vpc_security_group_ids               = [
          - "sg-06feb4e59bf7b6b83",
        ] -> null
        # (11 unchanged attributes hidden)

      - capacity_reservation_specification {
          - capacity_reservation_preference = "open" -> null
        }

      - cpu_options {
          - core_count            = 1 -> null
          - threads_per_core      = 1 -> null
            # (2 unchanged attributes hidden)
        }

      - credit_specification {
          - cpu_credits = "standard" -> null
        }

      - enclave_options {
          - enabled = false -> null
        }

      - maintenance_options {
          - auto_recovery = "default" -> null
        }

      - metadata_options {
          - http_endpoint               = "enabled" -> null
          - http_protocol_ipv6          = "disabled" -> null
          - http_put_response_hop_limit = 2 -> null
          - http_tokens                 = "required" -> null
          - instance_metadata_tags      = "disabled" -> null
        }

      - primary_network_interface {
          - delete_on_termination = true -> null
          - network_interface_id  = "eni-0b34b1776a84fbd47" -> null
        }

      - private_dns_name_options {
          - enable_resource_name_dns_a_record    = false -> null
          - enable_resource_name_dns_aaaa_record = false -> null
          - hostname_type                        = "ip-name" -> null
        }

      - root_block_device {
          - delete_on_termination = true -> null
          - device_name           = "/dev/xvda" -> null
          - encrypted             = false -> null
          - iops                  = 3000 -> null
          - tags                  = {} -> null
          - tags_all              = {} -> null
          - throughput            = 125 -> null
          - volume_id             = "vol-08c385b3a8e206d07" -> null
          - volume_size           = 8 -> null
          - volume_type           = "gp3" -> null
            # (1 unchanged attribute hidden)
        }
    }

Plan: 0 to add, 0 to change, 1 to destroy.
╷
│ Error: Resource has no configuration
│
│ Terraform attempted to process a resource at aws_instance.one that has no configuration. This is a bug in Terraform; please report it!

Expected Behavior

On AWS I created a basic ubuntu EC2 instance and wanted to import it into terraform.

Actual Behavior

Throws an error. Process has no resource. Means I probably need to have a resource in the file

Steps to Reproduce

Manually create Ec2 instance.
terraform file with :

provider "aws" {
  region = "us-east-1"
}

import {
  to = aws_instance.one
  id = "i-0aef1c99938c2b6ca"
}
terraform init
terraform plan
terraform apply

Additional Context

(I am learning terraform right now, but I am following the output. It told me there was a bug so now I bother you.) EC2 instance summary.
Image

References

No response

Generative AI / LLM assisted development?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions