Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: chapter "Destroying one resource" doesn't make sense to me #8

Open
johanngyger opened this issue Oct 18, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@johanngyger
Copy link
Contributor

Contact Details

No response

Killercoda Scenario

getting-started/step6/desc.md

What happened?

If I destroy all resources in task 1, then there are no resources left. So this probably expects I haven't executed task 1, which is misleading because the scenario is not linear, i.e. I can't execute all the steps one after the other.

controlplane $ tofu apply -destroy
local_file.example: Refreshing state... [id=a60c4c70c5403cad1601874f0e93f09583a4a058]
local_file.morning: Refreshing state... [id=4bec4e60980f845c28d2ab3d7cbbaa65c06d36ec]

OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

OpenTofu will perform the following actions:

  # local_file.example will be destroyed
  - resource "local_file" "example" {
      - content              = "Hello, OpenTofu!" -> null
      - content_base64sha256 = "zGkKU5Te3UerJHPvQC81Jq3XYJcAq+s/ELTtftptZpg=" -> null
      - content_base64sha512 = "9nk37DKmYpBZV03vg4ZiMz4viIpKffUK+fhshHH+tXcK+dR3a0ySNZ+62ELEkFZcw+dHDHvojmDtG7rNiaDodw==" -> null
      - content_md5          = "4705ecc785039f9734f49bf28adb68c4" -> null
      - content_sha1         = "a60c4c70c5403cad1601874f0e93f09583a4a058" -> null
      - content_sha256       = "cc690a5394dedd47ab2473ef402f3526add7609700abeb3f10b4ed7eda6d6698" -> null
      - content_sha512       = "f67937ec32a6629059574def838662333e2f888a4a7df50af9f86c8471feb5770af9d4776b4c92359fbad842c490565cc3e7470c7be88e60ed1bbacd89a0e877" -> null
      - directory_permission = "0777" -> null
      - file_permission      = "0777" -> null
      - filename             = "./hello.txt" -> null
      - id                   = "a60c4c70c5403cad1601874f0e93f09583a4a058" -> null
    }

  # local_file.morning will be destroyed
  - resource "local_file" "morning" {
      - content              = "Good Morning, Terraform!" -> null
      - content_base64sha256 = "KauVw4+rKAlz+eS47aFiyQ2KRRKqTzS6HQlqyP6IPC0=" -> null
      - content_base64sha512 = "27AVd7TX/HOe5As/3SAWfoytG+73aouE3y8KOJ+/1N27qkQiFl3ZlwLHs9HCBt+wHW4tFvd/5Rdm8rc59B8t9w==" -> null
      - content_md5          = "86eabb462ca86386a7a7557b1a0f417c" -> null
      - content_sha1         = "4bec4e60980f845c28d2ab3d7cbbaa65c06d36ec" -> null
      - content_sha256       = "29ab95c38fab280973f9e4b8eda162c90d8a4512aa4f34ba1d096ac8fe883c2d" -> null
      - content_sha512       = "dbb01577b4d7fc739ee40b3fdd20167e8cad1beef76a8b84df2f0a389fbfd4ddbbaa4422165dd99702c7b3d1c206dfb01d6e2d16f77fe51766f2b739f41f2df7" -> null
      - directory_permission = "0777" -> null
      - file_permission      = "0777" -> null
      - filename             = "./morning.txt" -> null
      - id                   = "4bec4e60980f845c28d2ab3d7cbbaa65c06d36ec" -> null
    }

Plan: 0 to add, 0 to change, 2 to destroy.

Do you really want to destroy all resources?
  OpenTofu will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

local_file.morning: Destroying... [id=4bec4e60980f845c28d2ab3d7cbbaa65c06d36ec]
local_file.example: Destroying... [id=a60c4c70c5403cad1601874f0e93f09583a4a058]
local_file.morning: Destruction complete after 0s
local_file.example: Destruction complete after 0s

Apply complete! Resources: 0 added, 0 changed, 2 destroyed.
controlplane $  tofu plan -target="local_file.example" -out /root/destroy-plan

OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

OpenTofu will perform the following actions:

  # local_file.example will be created
  + resource "local_file" "example" {
      + content              = "Hello, OpenTofu!"
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "./hello.txt"
      + id                   = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Warning: Resource targeting is in effect
│ 
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the changes requested by the current
│ configuration.
│ 
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when OpenTofu
│ specifically suggests to use it as part of an error message.
╵

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Saved the plan to: /root/destroy-plan

To perform exactly these actions, run the following command to apply:
    tofu apply "/root/destroy-plan"
controlplane $ tofu state ls
controlplane $ tofu apply -destroy "/root/destroy-plan"
local_file.example: Creating...
local_file.example: Creation complete after 0s [id=a60c4c70c5403cad1601874f0e93f09583a4a058]
╷
│ Warning: Applied changes may be incomplete
│ 
│ The plan was created with the -target option in effect, so some changes requested in the configuration may have been ignored and the output values may not be
│ fully updated. Run the following command to verify that no other changes are pending:
│     tofu plan
│ 
│ Note that the -target option is not suitable for routine use, and is provided only for exceptional situations such as recovering from errors or mistakes, or when
│ OpenTofu specifically suggests to use it as part of an error message.
╵

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
controlplane $ tofu state ls
local_file.example
@johanngyger johanngyger added the bug Something isn't working label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants