NetApp / terraform-provider-netapp-cloudmanager

Terraform provider to create NetAPP OCCM instances, CVO resources, volumes, snapshots, ... in Azure, AWS, GCP.
Mozilla Public License 2.0
17 stars 27 forks source link

Terraform wants to create a connector in aws that already exists, and is already in the state file #29

Closed watsonjm closed 3 years ago

watsonjm commented 3 years ago

I was adding to my Terraform code today and it wants to create a resource that already exists in the state file, and nothing I added is related to this resource or anything it depends on. I can't figure out why it wants to create a new one, so any help is appreciated. Here is the result of the plan for this resource and also the current resource shown in the state file:

root@PC:/mnt/e/Git/Github/aws-core-infrastructure# terraform plan -var-file=./config/test.tfvars -out test.tfplan -target netapp-cloudmanager_connector_aws.occm

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # netapp-cloudmanager_connector_aws.occm will be created
  + resource "netapp-cloudmanager_connector_aws" "occm" {
      + account_id                    = "account-xxxxxxxx"
      + associate_public_ip_address   = true
      + client_id                     = (known after apply)
      + company                       = "My Co"
      + enable_termination_protection = false
      + iam_instance_profile_name     = "iam_profile_name"
      + id                            = (known after apply)
      + instance_type                 = "t3.xlarge"
      + key_name                      = "my-key"
      + name                          = "netapp-connector"
      + region                        = "us-east-1"
      + security_group_id             = "sg-xxxxxxxx3"
      + subnet_id                     = "subnet-xxxxxxxx4"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Warning: Resource targeting is in effect

You are creating a plan with the -target option, which means that the result
of this plan may not represent all of the changes requested by the current
configuration.

The -target option is not for routine use, and is provided only for
exceptional situations such as recovering from errors or mistakes, or when
Terraform specifically suggests to use it as part of an error message.

------------------------------------------------------------------------

This plan was saved to: test.tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "test.tfplan"

root@PC:/mnt/e/Git/Github/aws-core-infrastructure# terraform state show netapp-cloudmanager_connector_aws.occm
# netapp-cloudmanager_connector_aws.occm:
resource "netapp-cloudmanager_connector_aws" "occm" {
    account_id                  = "account-xxxxxxxx"
    associate_public_ip_address = true
    client_id                   = "xxxxxxxx1"
    company                     = "My Co"
    iam_instance_profile_name   = "iam_profile_name"
    id                          = "xxxxxxxx2"
    instance_type               = "t3.xlarge"
    key_name                    = "my-key"
    name                        = "netapp-connector"
    region                      = "us-east-1"
    security_group_id           = "sg-xxxxxxxx3"
    subnet_id                   = "subnet-xxxxxxxx4"
}
lonico commented 3 years ago

This is puzzling. But this is really a core terraform issue. Not something specific about this provider.

Do you see the same issue if you don't use -target?

lonico commented 3 years ago

most likely related to #45

We were told to ignore the AMI, but we believe we should store it's value in the status file. If a new image is deployed, we only look for the latest AMI id, rather than the one that was used at deployment time. Working on a fix.

lonico commented 3 years ago

fixed in a46401d67704dc50cddb597beff92263fe59d1da

released as 21.6.0