Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform 0.12 remote state : Attribute name required #20835

Closed
riteshnanda09 opened this issue Mar 26, 2019 · 13 comments

Comments

Projects
None yet
8 participants
@riteshnanda09
Copy link

commented Mar 26, 2019

Terraform Version

Terraform v0.12.0-beta1
+ provider.google v2.1.0

Terraform Configuration Files

terraform {
  backend "gcs" {
    bucket = "tf-state"
    prefix = "bootstrap/state"
  }
}

Debug Output


Terraform has detected that the configuration specified for the backend
has changed. Terraform will now check for existing state in the backends.


2019/03/26 14:06:14 [TRACE] backendMigrateState: need to migrate from "gcs" to "gcs" backend config
2019/03/26 14:06:14 [TRACE] backendMigrateState: migrating "default" workspace to "default" workspace

Error: Error loading state:
    2 problems:

- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.

Terraform failed to load the default state from the "gcs" backend.
State migration cannot occur unless the state can be loaded. Backend
modification and state migration has been aborted. The state in both the
source and the destination remain unmodified. Please resolve the
above error and try again.

Steps to Reproduce

  1. terraform init

Actual Behavior

With Terraform 0.11 it works.

With terraform 0.12 it gives very minimal information to what is the problem with the state file. Trying in Trace and debug mode is the same . Any way i can know which attribute it is erroring out.

@apparentlymart apparentlymart added this to the v0.12.0 milestone Mar 27, 2019

@mildwonkey

This comment has been minimized.

Copy link
Member

commented Mar 28, 2019

Hi @riteshnanda09 !
Thanks for reporting this issue, and I'm sorry you're experiencing it. I'd like to try and reproduce it so we can figure out what's going on!

You can run TF_LOG=DEBUG terraform init to get (a lot) more information from terraform. It would be helpful if you share the output of that command (as a gist, please, and remove any sensitive information), and the rest of your terraform configuration files, including the prior backend configuration. It would be great if we could come up with a "minimal" reproduction case.

Finally, can you share the precise minor version of terraform 0.11 is working for you? The current latest is 0.11.13.

Thanks!

@mildwonkey mildwonkey self-assigned this Mar 28, 2019

@riteshnanda09

This comment has been minimized.

Copy link
Author

commented Mar 28, 2019

Here is the Debug output with terraform 0.12, its small so not sharing using gist.

 TF_LOG=DEBUG ./terraform init
2019/03/28 09:35:38 [INFO] Terraform version: 0.12.0 beta1
2019/03/28 09:35:38 [INFO] Go runtime version: go1.11.5
2019/03/28 09:35:38 [INFO] CLI args: []string{"terraform", "init"}
2019/03/28 09:35:38 [DEBUG] Attempting to open CLI config file: .terraformrc
2019/03/28 09:35:38 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2019/03/28 09:35:38 [INFO] CLI command args: []string{"init"}
Initializing modules...
2019/03/28 09:35:38 [DEBUG] Module installer: begin constraint-policies
2019/03/28 09:35:38 [DEBUG] Module installer: begin pubsub

Initializing the backend...
Backend configuration changed!

Terraform has detected that the configuration specified for the backend
has changed. Terraform will now check for existing state in the backends.



Error: Error loading state:
    2 problems:

- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.

Terraform failed to load the default state from the "gcs" backend.
State migration cannot occur unless the state can be loaded. Backend
modification and state migration has been aborted. The state in both the
source and the destination remain unmodified. Please resolve the
above error and try again.

Here is the gist to main.tf

This modules runs fine with version

Terraform v0.11.10
+ provider.google v1.17.1
+ provider.random v2.1.0
@mildwonkey

This comment has been minimized.

Copy link
Member

commented Mar 28, 2019

Thank you for the additional information, @riteshnanda09.

🤔 This looks like it might be tricky to reproduce, but I have a few ideas. This error seems to happen when the state upgrader callers one of the addrs.Parse... functions, which is during provider parsing:

providerAddr, diags = addrs.ParseAbsProviderConfigStr(oldProviderAddr)

Are there any provider blocks in the modules you call from your main.tf? I'd be curious to see if any of them look unusual. You can also run terraform state pull to manually download a copy of your statefile and peek in it for anything that looks "unusual", especially in any "provider" blocks.

I'm sorry to use such a vague term as "unusual", but hopefully we can tease out some information that will help me track down the issue. Thanks again!

@maciejqantas

This comment has been minimized.

Copy link

commented Mar 31, 2019

I have a similar issue with TF 0.12 and the AWS provider 1.60.0-dev20190216h00-dev.

I get

Failed to refresh state: 7 problems:

- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.

and that's on both plan and state pull.

I looked at the logs, as per your suggestion above, and there's nothing of interest.
I looked at the state and haven't spotted anything "unusual".

I'm trying to upgrade from 0.11.11 to 0.12.

@mildwonkey would you have any other ideas? Any other place to look for potential issues?

@mildwonkey

This comment has been minimized.

Copy link
Member

commented Apr 1, 2019

Hi @maciejdrozdzowski, thanks for chiming in and I'm sorry you've also run across this.

The first guess I have involves provider aliases. In versions 0.11 and earlier it was possible have a provider alias with ., like mycloud-us.east.1, but in 0.12 the alias can only have letters, numbers or hyphens: mycloud-us-east-1.

That's only a loose guess. If you have a terraform config file that can be used to reproduce this upgrade issue I'd love to dig in.

@maciejqantas

This comment has been minimized.

Copy link

commented Apr 1, 2019

@mildwonkey
I actually only have one provider of each type, without aliases

provider "aws" {
  version = "1.60.0-dev20190216h00-dev"

  region = "ap-southeast-2"

  assume_role {
    role_arn = "arn:aws:iam::***"
  }
}

provider "archive" {
  version = "~> 1.0"
}

provider "template" {
  version = "~> 1.0"
}

I cannot really share the code - too much work-specific stuff going on in there :)

@mildwonkey

This comment has been minimized.

Copy link
Member

commented Apr 16, 2019

Hi @riteshnanda09 and @maciejdrozdzowski ,
Sorry for the silence on this issue. I am still trying to reproduce the problem and could use your help.

The error message indicates that the error occurs while parsing a provider, resource or dependency address. I understand that you cannot share your entire state or configuration - I would not ask you to - but perhaps you could help me by getting the names of any resources, providers and dependencies, search for those names in both the old and new state, then share the values of the attributes you find?

Unfortunately, since terraform state pull is failing you will need to get the state file directly from the backend. I am sorry that I don't have a simpler way to dig into this 😞

If either of you are able to reproduce this issue with a simplified configuration that does not contain any sensitive information, please share it here so that I can reproduce locally. For instance @riteshnanda09 , if it is possible to isolate this error to a single module in the main.tf you've shared, and share that module (or a sanitized version which causes the same error) I can dive into it here.

Thanks, and sorry again for the odd error.

@kshpytsya

This comment has been minimized.

Copy link

commented Apr 25, 2019

I have encountered a similar issue (with s3 state backend), and for me the culprit was the following depends_on:

                 "aws_db_subnet_group.one": {
                     "type": "aws_db_subnet_group",
                     "depends_on": [
                         "aws_subnet.one",
                         "aws_subnet.one.1",
                         "aws_subnet.one.2"
                     ],

Once I edited it to "depends_on": [], the the state was successfully loaded by terraform 0.12.

If that is of any relevance, I have also manually edited the state due to reorganization of my Terraform code:

     "modules": [
         {
             "path": [
-                "root",
-                "modulename"
+                "root"
             ],

I.e. the v0.11.13 state was created with all the resources defined in a modulename module, state was manually edited, and v0.12 was executed with all resources defined in root module giving the hoped for:

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

All of this is done on sacrificial resources, so I can easily reproduce this should any extra investigation be needed.

@nicolasochem

This comment has been minimized.

Copy link

commented May 23, 2019

I have the same problem when doing terraform plan

2019/05/23 16:31:14 [DEBUG] [aws-sdk-go]
Error refreshing state: 4 problems:

- Attribute name required: Dot must be followed by attribute name.
- Attribute name required: Dot must be followed by attribute name.
- Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.
- Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.

I can't share the code but I don't know where to start looking. Can we have file and line information about this error. I will hardcode terraform 0.11 in my pipeline until shis is fixed.

@luhn

This comment has been minimized.

Copy link

commented May 24, 2019

I've encountered this as well. I had some resources that started with a number (renamed after upgrading), which apparently don't play nicely with the state. I manually downloaded to stated and removed the offending resources from any depends_on they showed up in. It worked after this.

@apparentlymart

This comment has been minimized.

Copy link
Member

commented May 24, 2019

Hi all!

Let's use #21435 to discuss the ongoing issues of this type. The PR associated with this issue addressed one cause of the error, but it seems like there is at least one other cause we need to investigate and fix. I asked the submitter of #21435 to try to gather some additional info from the state file; if you have similar info to share to answer that question, that'd be very helpful in figuring out what rule is missing from the state upgrader. Thanks!

@rismoney

This comment has been minimized.

Copy link

commented Jun 6, 2019

Not sure if this is a separate issue: Just trying to run init as nothing was previously flagged as on checklist...
I am using vsphere provider.

Error: Attribute name required

  on ..\modules\vsphere_win10\workstation.tf line 77, in resource "vsphere_virtual_machine" "wks":
  77:     ignore_changes =["wait_for_guest_net_routable","extra_config","annotation","wait_for_guest_net_timeout","power_state","clone.0.template_uuid"]

Dot must be followed by attribute name.
`

It looks like it doesn't like the way I specified uuid
@maciejqantas

This comment has been minimized.

Copy link

commented Jun 24, 2019

@mildwonkey, apologies for ghosting you - this slipped through the cracks.
I have not attempted to resolve this again, I gave up on 0.12 for the time being and promised myself to come back to it one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.