Closed ehaselwanter closed 5 years ago
Hi Edmond, I don't think this is possible right now. Any extra arguments aren't currently passed to custom workflows.
You could create a PR to add an environment variable to https://github.com/runatlantis/atlantis/blob/master/server/events/runtime/run_step_runner.go#L40.
"EXTRA_ARGS": strings.Join(ctx.CommentArgs, ","),
I'm going to close this but please comment if you have any more questions.
@lkysow Would the one-liner fix you specified above solve the problem? If so, I can create the PR.
@sryabkov for sure if you'd like to PR that would be great!
@sryabkov
So, have you solved this? Can we destroy with terragrunt?
~No, nothing has changed.~
Actually I'm incorrect. The COMMENT_ARGS
environment variable is now available and so a custom workflow can use the args.
are there plans to fix to support terragrunt workflows? we're investigating atlantis as a possibility for our team. thanks.
@aeugenio
I am pretty sure you can customize your plan with a sprinkle of bash and python.
For example I have just added a feature that at least n
predefined users from AWS SSM must do a 👍 on a MR, otherwise atlantis apply
will fail. I can imagine that custom atlantis plan
will do the trick too.
You will have to build your custom Dockerfile, install python3
(or any other language of choice), copy your scripts into the container and so on. At the bottom of the page: https://www.runatlantis.io/docs/custom-workflows.html#reference that COMMENT_ARGS
env variable is available. Just create a dumb if/else .py
or .sh
file that checks if that env variable contains a word 'destroy' - if yes, destroy stuff, otherwise plan.
Also configure it globally in repos.yaml
:
repos:
- id: "/.*/"
workflow: plandestroy
workflows:
plandestroy:
plan:
steps:
- run: /your/script.sh
It is rather straightforward, should be done in few hours with no prior Atlantis experience. Just google stuff and you'll be fine.
are there plans to fix to support terragrunt workflows? we're investigating atlantis as a possibility for our team. thanks.
Hi Alan, There are no plans to add more support to terragrunt to the Atlantis core because everything can be accomplished with custom workflows which was their purpose. If you are unable to accomplish what you need then we can look at making a change to the Atlantis core.
For example last week we merged a change that made autoplanning work with terragrunt. This change could not have been made with custom workflows. However I probably wouldn't want to add a change to treat terragrunt destroy's differently if that problem is already solvable with an existing Atlantis feature (in this case custom workflows).
Hi, I managed to solve it using the custom args inside our atlantis.yaml. I will leave the planning part here, maybe it will help someone.
workflows:
terragrunt:
plan:
steps:
- env:
name: TERRAGRUNT_TFPATH
command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
- env:
name: DESTROY_PARAMETER
command: if [ "$COMMENT_ARGS" = "\-\d\e\s\t\r\o\y" ]; then echo "-destroy"; else echo ""; fi
- run: terragrunt plan -no-color -out $PLANFILE $DESTROY_PARAMETER
@aschi1 can you help me understand how this works? If I delete the folder with my .hcl
file, I can make a PR, but terragrunt says there's no changes (because I deleted the .hcl file). If I don't delete the .hcl file, I have nothing to PR....which is where I would run atlantis plan -- -destroy
The chicken / egg problem confuses me
@jasonrberk Its a workaround for terragrunt that we implemented for our atlantis workflow to be able to destroy our projects. Its not very "smart" but it enables us to run terragrunt destroy commands.
In your case I would probably add couple spaces/linebreaks to your .hcl file to create changes, create a PR, run atlantis plan -- -destroy and after its all destroyed I would delete the .hcl file and then merge it back to master. Hope this helps
that's almost exactly what I figured I would end up needing to do, but wanted to make sure I wasn't missing something. thanks for the fast feedback
Sure, glad to help :)
This is best config to plan/apply destroy config,
repos:
id: "/.*/" workflow: terragrunt apply_requirements: [approved] allowed_overrides: [apply_requirements] workflows: terragrunt: plan: steps:
+++++++++++++++++ Destroy Comments with plan and apply ++++++++++++ atlantis plan -d dir -- -destroy atlantis apply -d dir -- -destroy
is this already hidden somewhere in the documentation?