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

Parametrizing with different remote states causes unexpected issues #384

Closed
kaisellgren opened this issue Sep 26, 2020 · 3 comments
Closed
Labels
bug Something isn't working cdktf-cli

Comments

@kaisellgren
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

Terraform v0.12.29

  • provider.google v3.30.0

"cdktf": "0.0.17",
"constructs": "^3.0.4"
"cdktf-cli": "0.0.17",

Affected Resource(s)

Debug Output

Expected Behavior

diff & deploy should work normally.

Actual Behavior

Sometimes cdktf hangs forever at initializing <name>... and sometimes I get:

⠹ initializing builds...
⠙ initializing builds...

2020/09/26 18:34:39 [TRACE] backendMigrateState: both source and destination workspaces have states, so might overwrite destination with source

Error: error asking for state migration action: input disabled

non-zero exit code 1

And sometimes different states get entangled so that diffing a dev environment will want to destroy staging and prod resources.

Steps to Reproduce

I am using env variables to parametrize cdktf. I have ENV set to dev/staging/prod. Each env specifies a diff remote state:

    new GcsBackend(this, {
      bucket: 'terraform-state',
      prefix: `app-${process.env.ENV}`,
    })

I also have two stacks: app and builds stacks. They both have the same env specific parameters, and builds stack has this:

    new GcsBackend(this, {
      bucket: 'terraform-state',
      prefix: `builds-${process.env.ENV}`,
    })

If I run cdktf diff or cdktf deploy, it either hangs forever, produces the error shown earlier or shows wrong diff results (wanting to delete resources of other environments).

The only way to make it work is to do rm -rf cdktf.out. If I always delete the out folder then it works so it has to do with its existence. This also seems to be universal across every type of resource. Right now my script just runs rm -rf cdktf.out and it works well that way.

Important Factoids

References

  • #0000
@kaisellgren kaisellgren added the bug Something isn't working label Sep 26, 2020
@skorfmann
Copy link
Contributor

Sounds similar to what's described in this comment #376 (comment)

@DanielMSchmidt
Copy link
Contributor

I think this is the same as #398; I could not reproduce that one, if it's fundamentally different please let me know and I'll see if this is still an issue 👍

@github-actions
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working cdktf-cli
Projects
None yet
Development

No branches or pull requests

4 participants