This message was deleted.
# atlantis-community
s
This message was deleted.
b
Simply remove the
aws_s3_bucket
from your
<http://xxx.tf|xxx.tf>
file and run an
atlantis apply
after it has planned for you, or you made it plan by using
atlantis plan
It would detect that the resource is removed from the
<http://xxxx.tf|xxxx.tf>
file and will destroy it.
When it comes to executing Terraform, Atlantis just simply uses the Terraform binary - so the Teraform behaviour between Atlantis and running a
terraform apply
is no different.
You should ideally never run
atlantis plan -- destroy
It's a best practice to always roll forward, meaning you just make use of
apply
and remove resources from the Terraform config files.
p
I removed the aws_s3_bucket from xxx.tf file, PR is pushed to bitbucket, there is an autoplan happening on the PR and it showed me
Plan: 0 to add, 0 to change, 3 to destroy
. I ran
atlantis apply
, but there was nothing happening
b
Can you take a look at the apply output?
It might be that you have an object in the bucket, and the bucket is not deleted due to objects being present in the S3 bucket.
And regarindg autoplan, this is something you can enable or disable yourself (either repo side or server side).
p
The bucket is empty. There is no apply output on the PR . I ran
atlantis apply -d dir
and there is nothing showing on the PR.
b
And if you simply run
atlantis apply
?
I would expect some output to be somewhere, if not on the PR - wherever you host it.
Perhaps the associated IAM role doesn't have the access to delete it (?)
It can be anything.
p
This is my workflow
Copy code
myworkflow:
    plan:
      steps:
        - run: terraform init
        - run: terraform plan -out plan.out
    apply:
      steps:
        - run: terraform apply "plan.out"
b
Aha
Can you try to change it to:
Copy code
myworkflow:
    plan:
      steps:
        - init
        - plan
    apply:
      steps:
        - apply
Atlantis has built-in support for not having to define your own
terraform <command>
commands.
p
I am able to successfully do atlantis apply for creating a resource with the worflow, but when I am trying to delete the resource, atlantis apply is not working. Why is there a need to change the workflow ?
b
1. That's likely not related to Atlantis - as Atlantis simply uses Terraform to manage the lifecycle of a resource. So again, please check the output of the apply and see if runs into any issues such as IAM permissions not being present to delete the resource. 2. There is no need to change your workflow, if you want to manage and run your own
terraform
statements, feel free to do so - but there's native built-in support for these statements. I would recommend to make use of such native built-in features to prevent managing more work on your side.
p
Following is the log when atlantis apply is run , It only shows the event is triggered, but terraform apply is not running
Copy code
{"level":"debug","ts":"2023-06-15T08:39:00.078Z","caller":"events/events_controller.go:120","msg":"handling Bitbucket Cloud post","json":{}}
{"level":"debug","ts":"2023-06-15T08:39:00.078Z","caller":"events/events_controller.go:218","msg":"handling as comment created event","json":{}}
{"level":"debug","ts":"2023-06-15T08:39:00.078Z","caller":"logging/simple_logger.go:157","msg":"Ignoring non-command comment: \"atlantis apply -d dir...\"","json":{}}
{"level":"debug","ts":"2023-06-15T08:39:00.078Z","caller":"server/middleware.go:72","msg":"POST /events – respond HTTP 200","json":{}}
{"level":"debug","ts":"2023-06-15T08:39:00.613Z","caller":"metrics/debug.go:47","msg":"gauge","json"{"name":"atlantis.scheduled.runtime.cpu.goroutines","value":8,"tags":{},"type":"gauge"}}
b
It seems like
atlantis apply -d dir
is just ignored.
p
While creating the s3 bucket resource
atlantis apply -d dir
works
r
I have added some custom config it will help you to destroy plan/apply. It works for me as expected. https://github.com/runatlantis/atlantis/issues/612#issuecomment-1681882532