https://www.runatlantis.io/ logo
Title
j

jwr

03/30/2023, 2:12 PM
How can I get an example of a planfile as atlantis would get one? I want to use it to build a custom workflow which will need to
jq
the planfile and do different things based on which resources are going to change. If I need to get a planfile into json locally outside the context of atlantis, I can do:
terraform plan -out=tfplan
terraform show -json tfplan | jq -S .
So inside atlantis, assuming that a plan had already been run, should I expect something like this to work?
workflows:
  init-plan-apply:
    plan:
      steps:
        - init
        - plan:
            extra_args: ["-lock-timeout=300s"]
    apply:
      steps:
        - init
        # Do some jq stuff with the plan before applying
        - terraform show -json $PLANFILE | jq -S .
        - apply:
            extra_args: ["-lock-timeout=300s"]
i

Isaac Wilson

03/30/2023, 2:29 PM
What are you trying to do with jq?
j

jwr

03/30/2023, 2:31 PM
we have certain resources which shouldn't be changed during certain hours. So I want to use jq to check which resources will be changed, and if one of the restricted resources is going to be changed during the restricted hours, just
exit 1
and fail the apply before applying.
p

PePe Amengual

03/30/2023, 3:00 PM
can't you use opa policies with contest?
j

jwr

03/30/2023, 3:10 PM
I'm not opposed to using proper opa policies, but I'm not sure those can accomplish what I want. For example, if I did it on my own in bash, this would meet my requirements: https://pastebin.com/raw/ERbAdn9Q Can opa policies do that?
p

PePe Amengual

03/30/2023, 3:15 PM
I will be surprised if is not possible