hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.17k forks source link

Some states are null in import of aws_lb_target_group #13373

Open habuchin opened 4 years ago

habuchin commented 4 years ago

Community Note

Terraform Version

0.12.25

Affected Resource(s)

Terraform Configuration Files

resource "aws_lb_target_group" "example" {
  name                               = "example-target"
  port                               = 443
  protocol                           = "TCP"
  target_type                        = "ip"
  vpc_id                             = data.aws_vpc.vpc.id
  deregistration_delay               = 300
  slow_start                         = 0
  lambda_multi_value_headers_enabled = false

  health_check {
    interval            = 10
    path                = "/healthcheck"
    port                = "traffic-port"
    protocol            = "HTTPS"
    healthy_threshold   = 2
    unhealthy_threshold = 2
  }
}

Debug Output

Panic Output

Expected Behavior

I'd like to see state given a default value, as there should be no difference in the terrafrom plan when importing aws_lb_target_group.

Actual Behavior

When import aws_lb_target_group, the following three state values are null, so there is a difference in the terraform plan.

  ~ resource "aws_lb_target_group" "example" {
        arn                                = "arn:aws:elasticloadbalancing:ap-northeast-1:000000000000:targetgroup/example-target/0000000000000000"
        arn_suffix                         = "targetgroup/example-target/000000000000000"
      + deregistration_delay               = 300
        id                                 = "arn:aws:elasticloadbalancing:ap-northeast-1:000000000000:targetgroup/example-target/0000000000000000"
      + lambda_multi_value_headers_enabled = false
        name                               = "example-target"
        port                               = 443
        protocol                           = "TCP"
        proxy_protocol_v2                  = false
      + slow_start                         = 0

Steps to Reproduce

  1. terraform import aws_lb_target_group.example arn:aws:elasticloadbalancing:ap-northeast-1:000000000000:targetgroup/example-target/0000000000000000
  2. terraform plan

Important Factoids

References

justinretzolk commented 3 years ago

Hey @habuchin 👋 Thank you for taking the time to file this issue. Given that there's been a number of Terraform and AWS Provider releases since you initially filed it, can you confirm whether you're still experiencing this?

carlwain74 commented 2 years ago

I am seeing this issue on my setup for target groups and other resource types. on latest

Terraform v1.3.2
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v4.34.0
  # module.cvos_tg.aws_alb_target_group.alb-tg will be updated in-place
  ~ resource "aws_alb_target_group" "alb-tg" {
      + connection_termination             = false
      ~ deregistration_delay               = "15" -> "10"
        id                                 = "arn:aws:elasticloadbalancing:us-west-2:413388241797:targetgroup/cvos-int2-80/1830b2c810fa1bd7"
      + lambda_multi_value_headers_enabled = false
        name                               = "cvos-int2-80"
      + proxy_protocol_v2                  = false
        tags                               = {}
        # (10 unchanged attributes hidden)

      ~ health_check {
          ~ path                = "/health" -> "/version"
          ~ port                = "80" -> "traffic-port"
            # (7 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }

  # module.htfs_asg.aws_autoscaling_group.asg will be updated in-place
  ~ resource "aws_autoscaling_group" "asg" {
      + force_delete              = false
      + force_delete_warm_pool    = false
        id                        = "htfs-int2"
        name                      = "htfs-int2"
      + wait_for_capacity_timeout = "10m"
        # (21 unchanged attributes hidden)

        # (4 unchanged blocks hidden)
    }

You can see in the state file the null values for the autoscaling resource I imported.

            ],
            "force_delete": null,
            "force_delete_warm_pool": null,
            "health_check_grace_period": 300,
            "health_check_type": "ELB",