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

Atlantis is not respecting remote state #935

Closed
jesseneal opened this issue Feb 24, 2020 · 4 comments
Closed

Atlantis is not respecting remote state #935

jesseneal opened this issue Feb 24, 2020 · 4 comments
Labels
question Further information is requested waiting-on-response Waiting for a response from the user

Comments

@jesseneal
Copy link

I have a provider.tf which has a remote state in Azure.

In order to rm the old state since Atlantis keeps creating a new one instead of pulling the remote state with init I have had to do the following:

atlantis.yaml

workflows:
  central-us:
    plan:
      steps:
        - run: rm -rf .terraform/ && terraform init -no-color && terraform plan -no-color

Instead of just being able to:

workflows:
  central-us:
    plan:
      steps:
        - run: rm -rf .terraform
        - init
        - plan

With this code atlantis creates a new remote state and pushes it to Azure which does not accurately depict the state my resources are are in.

I go it to work with my one liner run code but why will that work and not the other yaml I provided?

@lkysow lkysow added the question Further information is requested label Mar 2, 2020
@lkysow
Copy link
Member

lkysow commented Mar 2, 2020

Hmm, I'm not sure why this is happening. The main difference is that the built-in init command runs slightly different commands than just terraform init -no-color. Are you by chance using workspaces?

The first workflow you posted will ignore workspaces but the second one will try to switch to the workspace set in projects.

If you look at the logs at debug level in Atlantis you can see exactly what command are being run. This should help you debug what the differences are.

@jesseneal
Copy link
Author

Yes, I have workspace with the name test in my projects:

@jesseneal
Copy link
Author

version: 3
projects:
  - name: central-us
    dir: ./dir/another-dir
    workflow: central-us
    workspace: test
workflows:
  central-us:
    plan:
      steps:
        - run: rm -rf .terraform/ && terraform init -no-color && terraform plan -no-color

@lkysow
Copy link
Member

lkysow commented Mar 11, 2020

Ahh so you'll need to do a terraform workspace switch if you're using a custom workflow.

@lkysow lkysow added the waiting-on-response Waiting for a response from the user label Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested waiting-on-response Waiting for a response from the user
Projects
None yet
Development

No branches or pull requests

2 participants