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

secret_text_bindings on cloudflare_worker_script are not removed from the worker #2393

Open
2 tasks done
ecclesm opened this issue Apr 21, 2023 · 3 comments
Open
2 tasks done
Labels
kind/bug Categorizes issue or PR as related to a bug. service/workers Categorizes issue or PR as related to the Workers service. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. workflow/synced

Comments

@ecclesm
Copy link

ecclesm commented Apr 21, 2023

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.4.5
on darwin_arm64

cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.3.0"
}

Affected resource(s)

  • cloudflare_worker_script (secret_text_bindings)

Terraform configuration files

FIRST RUN

resource "cloudflare_worker_script" "helloworld" {
  account_id = var.cloudflare_account_id
  name       = "${var.environment}-helloworld"
  content    = file("functions/helloworld/index.js")
  compatibility_date = "2023-03-27"

  plain_text_binding {
    name = "PLAIN_1"
    text = "pt1"
  }
  plain_text_binding {
    name = "PLAIN_2"
    text = "pt2"
  }

  secret_text_binding {
    name = "secret_1"
    text = "secretOne"
  }
  secret_text_binding {
    name = "secret_2"
    text = "secretTwo"
  }
}


SECOND RUN

resource "cloudflare_worker_script" "helloworld" {
  account_id = var.cloudflare_account_id
  name       = "${var.environment}-helloworld"
  content    = file("functions/helloworld/index.js")
  compatibility_date = "2023-03-27"

  plain_text_binding {
    name = "PLAIN_1"
    text = "pt1"
  }
  
  secret_text_binding {
    name = "secret_1"
    text = "secretOne"
  }
}

Link to debug output

https://gist.github.com/ecclesm/b513a3109a5723d8dfaff36822efb88f

Panic output

No response

Expected output

On each deploy, if am existing secret_text_binding is not included, terraform will remove it from the worker.

This expected behaviour is seen on a plain text binding.

Actual output

It looks like terraform recognises the binding needs to be removed, however the secret binding is still present on the worker after deploy.

For the below the 4 bindings were created on the initial deploy. On the following deploy I removed the second of each type, but only the plain text binding was removed.

First Run
Screenshot 2023-04-20 at 10 05 31

Second Run
Screenshot 2023-04-20 at 09 23 27

Screenshot 2023-04-20 at 09 22 36

Steps to reproduce

  1. Do an initial deployment with a secret text binding on the worker
  2. Remove the secret binding, deploy again and observe in the workers console that the secret binding is still present.

Additional factoids

No response

References

No response

@ecclesm ecclesm added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 21, 2023
@github-actions
Copy link
Contributor

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label Apr 21, 2023
@ecclesm
Copy link
Author

ecclesm commented May 25, 2023

Is there any update with regards to this issue?

@jacobbednarz jacobbednarz added triage/accepted Indicates an issue or PR is ready to be actively worked on. service/workers Categorizes issue or PR as related to the Workers service. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 26, 2023
@Nmishin
Copy link
Contributor

Nmishin commented Jun 15, 2023

also sad that 'ignore_changes' isn't works
for example, if I set

 lifecycle {
    ignore_changes = [
     secret_text_binding
    ]
  }

I will get the error:

cloudflare_worker_script.main["test"]: Modifying... [id=hello_world2]
╷
│ Error: error updating worker script: Text for binding "SECRET" cannot be empty
│ 
│   with cloudflare_worker_script.main["test"],
│   on main.tf line 21, in resource "cloudflare_worker_script" "main":
│   21: resource "cloudflare_worker_script" "main" {

this is because terraform can't read secret value (because of API changed)
and function inside cloudflare-go failed - https://github.com/cloudflare/cloudflare-go/blob/5237e486f2a39aa4432b185af29e860fa30704f9/workers_bindings.go#L231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. service/workers Categorizes issue or PR as related to the Workers service. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. workflow/synced
Projects
None yet
Development

No branches or pull requests

3 participants