Terraform's default plan output leaves a bit to be desired in terms of readability, especially when updating things like IAM policies. My team makes heavy use of terraform-landscape to make our plan outputs easier to read. I know we can still use this with an atlantis.yml file but it would be great if there was an option to use this or something similar to make Plans easier to read out of the box.
I understand that it's annoying to have to specify custom steps that pipe plan through landscape.
What about something like:
projects:
- dir: .
workflow: custom
workflows:
custom:
plan:
terraform_landscape: true
The other options I don't like:
--use-terraform-landscapeatlantis server flags because inevitably people need per-project customizationterraform_landscapeThat seems like a good option. If the server-side atlantis.yml were to get implemented it would be great if it were valid there as well.
Could we add terraform-landscape to the docker container as well? It would save us from having to maintain a dockerfile fork
Integration with terraform-landscape would be fantastic.
@lkysow with your example if we had 50 different terraform setups under the root would this effect all of them or just the root folder? I would love if we could set it for all of them instead of having to call out all 50 different folders and add a new configuration everytime we add a new terraform setup.
projects:
- dir: .
workflow: custom
workflows:
custom:
plan:
terraform_landscape: true
Right now you'd have to specify it for each of them. However if we implemented the idea of a "default" workflow, then you would only have to specify it once.
This would be great, although it kind of seems like this should be part of Terraform itself :)
Hi,
I've been doing this with atlantis.yaml file, but I'm wondering if there is an easier way to do this.
atlantis.yaml
version: 2
projects:
- name: poc-devhub
dir: poc-aws/dev/terraform
apply_requirements: [mergeable]
autoplan:
when_modified: ["../dev-policies/*.terraform", "*.tf", "*.tfvars"]
workflow: landscape
workflows:
landscape:
plan:
steps:
- init
- run: terraform plan -input=false -refresh -no-color -out $PLANFILE -var atlantis_user=$PULL_AUTHOR -var atlantis_repo=$BASE_REPO_OWNER/$BASE_REPO_NAME -var atlantis_repo_name=$BASE_REPO_NAME -var atlantis_repo_owner=$BASE_REPO_OWNER -var atlantis_pull_num=$PULL_NUM | landscape --no-color
I just want to pipe the output of the terraform plan into landscape:
Q1 - Is there an easier way than rewriting all of the atlantis plan, into a custom comand and adding all of the environment variables?
Q2 - Should there be a env var for atlantis_repo? This way we would not need to concatenat BASE_REPO_OWNER with BASE_REPO_NAME
Below is the output of the plan with landscape:
~ module.dev_atlantis1_poc_okta_policies.aws_iam_policy.policy
policy: {
"Statement": [
{
- "Action": "ec2:tbd",
+ "Action": "ec2:tbd_sanity_check",
"Effect": "Allow",
"Resource": "*",
"Sid": "AtlantisPocb5DevHubkhkjg"
}
],
Plan: 0 to add, 1 to change, 0 to destroy.
Q1 - Is there an easier way than rewriting all of the atlantis plan, into a custom comand and adding all of the environment variables?
No, not right now.
Q2 - Should there be a env var for atlantis_repo? This way we would not need to concatenat BASE_REPO_OWNER with BASE_REPO_NAME
You mean the full repo name like runatlantis/atlantis? No there's no env var right now.
If we do include this in Atlantis, I'd recommend using scenery instead of landscape. It's also written in go, so has fewer dependencies.
@ivankisic Thanks for your quick feedback
This can be accomplished through creating a custom workflow and then making it the default (https://www.runatlantis.io/docs/server-side-repo-config.html#change-the-default-atlantis-workflow). I don't think this should be integrated into the atlantis core.
@lkysow what would a custom workflow look like for this?
Can I just pipeline the default "apply" and "plan" commands to landscape?
For example can I add this to my current workflow like this:
repos:
- id: /.*/
workflow: our_workflow
workflows:
our_workflow:
plan:
- plan | landscape
apply:
steps:
- run: if [ "$USER_NAME" != "admin1" ] && [ "$USER_NAME" != "admin2" ]; then echo "$USER_NAME" is NOT allowed to apply; exit 1; fi
- run: echo "$USER_NAME allowed, applying..."
- apply | landscape
Will I have to rewrite the entire terraform command atlantis runs? Are the terraform commands atlantis runs documented somewhere I can just copy from? What to make sure its running the same commands atlantis would and just piping to landscape (or scenery or whatever)
It looks like https://www.runatlantis.io/docs/custom-workflows.html#custom-init-plan-apply-commands
You can't pipe the built-in steps, you need to replace then with a run step, ex.
plan:
- init
- run: terraform plan -input=false -refresh -no-color -out $PLANFILE | landscape
@lkysow looks like its also doing a bunch of other stuff like getting the author ($PULL_AUTHOR ?) and version (ATLANTIS_TERRAFORM_VERSION).
Is there a way I can see the actual commands its running for the built-in steps or is the full command documented somewhere? Id like to avoid having to reverse engineer that thing
thanks for the super quick response! i love atlantis!
There's no easy way I know of. The code is here:
https://github.com/runatlantis/atlantis/blob/master/server/events/runtime/plan_step_runner.go#L36
For Terraform versions you can use terraform${ATLANTIS_TERRAFORM_VERSION}
plan
It's hard to directly replicate the golang code in bash so most people get
it working to the extent they need rather than trying to replicate it fully.
On Mon, Sep 16, 2019 at 9:33 AM red8888 notifications@github.com wrote:
@lkysow https://github.com/lkysow looks like its also doing a bunch of
other stuff like getting the author ($PULL_AUTHOR ?) and version
(ATLANTIS_TERRAFORM_VERSION).Is there a way I can see the actual commands its running for the built-in
steps or is the full command documented somewhere? Id like to avoid having
to reverse engineer that thingthanks for the super quick response! i love atlantis!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/runatlantis/atlantis/issues/286?email_source=notifications&email_token=AAH4RPLIF2WL4MDO6AE663TQJ6YPLA5CNFSM4FXDY552YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6ZXTTI#issuecomment-531855821,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAH4RPPZQN35G5BADPWQMYTQJ6YPLANCNFSM4FXDY55Q
.
Closing because this pretty old (pre 0.12) and terraform has made a lot of strides with regards to readability.
Most helpful comment
If we do include this in Atlantis, I'd recommend using scenery instead of landscape. It's also written in go, so has fewer dependencies.