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

Luiz Silva

02/27/2023, 5:56 PM
Hi people, how are you doing? I currently have an atlantis pipeline working with terragrunt dirs and I’m trying to delete the resource running this commands here: ◦
atlantis plan -d somepath/myresource.hcl -- -destroy
atlantis apply
The atlantis pipeline is running the plan to create the resource, instead of running the destroy. Do you guys know how can I solve this problem? I’m currently running my atlantis in v0.21.0 Thanks in advance 🙂
1
p

PePe Amengual

02/27/2023, 5:58 PM
it is
--destroy
I think
l

Luiz Silva

02/27/2023, 5:59 PM
Error: unknown flag: --destroy.
p

PePe Amengual

02/27/2023, 5:59 PM
sorry….you got it right
-- -destroy
l

Luiz Silva

02/27/2023, 6:00 PM
it appears when I pass the -d flag, atlantis dosen’t read the — -destroy
when I run
atlantis plan -d somepath/myresource.hcl -- -destroy
image.png
p

PePe Amengual

02/27/2023, 7:17 PM
are you passing COMMENT_ARGS to your custom workflow?
l

Luiz Silva

02/27/2023, 7:24 PM
No, do you hava any documentation speaking about?
my repos.yaml
repos:
- id: "/.*/"
  workflow: terragrunt
workflows:
  terragrunt:
    plan:
      steps:
      - env:
          name: TERRAGRUNT_TFPATH
          command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
      - run: terragrunt plan -input=false -out=$PLANFILE
      - run: terragrunt show -json $PLANFILE > $SHOWFILE
    apply:
      steps:
      - env:
          name: TERRAGRUNT_TFPATH
          command: 'echo "terraform${ATLANTIS_TERRAFORM_VERSION}"'
      - run: terragrunt apply -input=false $PLANFILE
COMMENT_ARGS - Any additional flags passed in the comment on the pull request. Flags are separated by commas and every character is escaped, ex. atlantis plan -- arg1 arg2 will result in COMMENT_ARGS=\a\r\g\1,\a\r\g\2.
if you enable debug you should be able to see the command that is being executed
l

Luiz Silva

02/27/2023, 7:29 PM
But atlantis dosen’t have an extra arg for destroy, should I put --destroy in the plan arg?
p

PePe Amengual

02/27/2023, 7:31 PM
I do not know how terragunt works but if this supports
terragrunt plan -input=false -out=$PLANFILE -destroy
then you need to pass the comment_ARGS
atlantis does not have a
destroy
command
l

Luiz Silva

02/27/2023, 7:31 PM
It works the same way as terraform
But every time that I run plan, the --destroy flag is going to run?
p

PePe Amengual

02/27/2023, 7:32 PM
no
those are passed in the comment
if you do not pass them it will be empty
that is why I said, enable debug and look at the command is running when you add
-- -destroy
and see if is passing it, if is not you will need add the
COMMENT_ARGS
to your custom workflow
l

Luiz Silva

02/27/2023, 7:35 PM
{"level":"debug","ts":"2023-02-27T19:34:37.823Z","caller":"models/shell_command_runner.go:93","msg":"starting \"terragrunt plan -input=false -out=$PLANFILE\
only running this
p

PePe Amengual

02/27/2023, 7:36 PM
and then is when you added the destroy flag?
l

Luiz Silva

02/27/2023, 8:24 PM
One question PePe, the COMMENT_ARGS goes in the workflow env, the documentation is not very clear
l

Luiz Silva

02/27/2023, 9:57 PM
This workaround currently works, but I don’t think it fits for the reality that I’m into. Anyway, thanks for answering me!
p

PePe Amengual

02/27/2023, 10:06 PM
why it does not fit?
l

Luiz Silva

02/27/2023, 10:12 PM
Because we need to find de PR or change the file to run the delete command, then push the code
p

PePe Amengual

02/27/2023, 10:17 PM
change which file? the Atlantis.yaml?
l

Luiz Silva

02/27/2023, 10:54 PM
the terragrunt.hcl file, to create an “Delete Pull Request”
then merging to master
I think I will need some script to remove the files with a post_workflow hook
p

PePe Amengual

02/27/2023, 11:05 PM
I c ok, I’m not familiar with terragrunt but this in pure TF works fine
l

Luiz Silva

02/28/2023, 2:01 AM
Sounds cool, we’re running a few tests with atlantis and terragrunt, but the solution unlocked my work. Thanks PePe, anything you need, feel free to reach me out 🙂