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

error running atlantis: exit status 1: running "sh -c terraform plan -input=false -refresh -no-color -out...." #369

Closed
st33v opened this issue Dec 2, 2018 · 3 comments
Labels
question Further information is requested

Comments

@st33v
Copy link

st33v commented Dec 2, 2018

I'm trying to run atlantis for the first time and all I can get it to produce is 'exit 1' when running a plan.

Is there a way to get more log information than this?

version: 2
projects:
- name: infrastructure
  dir: .
  autoplan:
    when_modified: ["*.tf", "./modules/**.tf"]
    enabled: true
  apply_requirements: [approved]
  workflow: myworkflow
workflows:
  myworkflow:
    plan:
      steps:
      - run: eval $(./scripts/aws_secrets.sh)
      - init
      - plan
    apply:
      steps:
      - run: eval $(./scripts/aws_secrets.sh)
      - apply

that's my config. I 'eval' a script that fetches secrets and exports them as variables into the shell:

➜  infrastructure git:(test_atlantis) ./scripts/aws_secrets.sh
export RAILS_MASTER_KEY=foo
export DATADOG_API_KEY=bar
export DATADOG_EXTERNAL_ID=foobar
export DATADOG_APP_KEY=flarg
export GITHUB_TOKEN=foobarre
export TF_VAR_atlantis_github_user=st33v
export TF_VAR_atlantis_github_user_token=foo

the 'init' and the 'eval' with seem to work and then I get 'exit 1' when running a plan.

@lkysow
Copy link
Member

lkysow commented Dec 3, 2018

  1. @st33v right now each step runs in its own shell so what you're doing won't work because the env vars don't get transferred in between each step.

  2. For now, you would have to write custom steps that source and run the init/plan:

    - run: "eval $(./scripts/aws_secrets.sh) && terraform init"
    

    I haven't tested ☝️so you might need to play around with quotes.

  3. I'm not sure why plan is just returning exit 1. It should at least give you an error message. Is there no output whatsoever?

  4. I'm going to create another ticket (Implement BASH_ENV functionality to share env vars between steps. #370) for implementing a BASH_ENV functionality in Atlantis, where you can write export statements to $BASH_ENV and those will be sourced on each step. That's how circleci handles this: https://circleci.com/docs/2.0/env-vars/#using-bash_env-to-set-environment-variables

@st33v
Copy link
Author

st33v commented Dec 3, 2018

got it. Thanks. That's similar to the solution that I ended up with minus the quotes. I didn't need them at all.

Yeah, I was surprised by the lack of output too. The environment vars that I'm reading contain creds for providers so I could see where terraform would totally puke on not having them.

Thanks for opening the feature request. I think that would work for me nicely.

@lkysow
Copy link
Member

lkysow commented Dec 3, 2018

Okay cool. I'll close this issue then since the proper fix is being tracked in #370.

@lkysow lkysow closed this as completed Dec 3, 2018
@lkysow lkysow added the question Further information is requested label Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants