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

aws_codepipeline_webhook doesn't support update #8017

Closed
zentavr opened this issue Mar 19, 2019 · 7 comments · Fixed by #11387
Closed

aws_codepipeline_webhook doesn't support update #8017

zentavr opened this issue Mar 19, 2019 · 7 comments · Fixed by #11387
Labels
bug Addresses a defect in current functionality. service/codepipeline Issues and PRs that pertain to the codepipeline service.
Milestone

Comments

@zentavr
Copy link

zentavr commented Mar 19, 2019

Terraform Version

$ terraform -v
Terraform v0.11.11
+ provider.aws v2.2.0
+ provider.github v1.3.0
+ provider.local v1.1.0
+ provider.null v2.1.0
+ provider.random v2.0.0
+ provider.template v1.0.0

Your version of Terraform is out of date! The latest version
is 0.11.13. You can update by downloading from www.terraform.io/downloads.html

Affected Resource(s)

  • aws_codepipeline_webhook

Terraform Configuration Files

# Create a Hook URL in Codepipeline
resource "aws_codepipeline_webhook" "github" {
  name  = "${var.app_environment}-${var.service_name}-webhook"
  count = "${var.enable_hooks}"

  # We are fetching the stage name dynamically
  #   The name of the action in a pipeline you want to connect to the webhook.
  #   The action must be from the source (first) stage of the pipeline.
  target_action = "${aws_codepipeline.pipeline.stage.0.action.0.name}"

  target_pipeline = "${aws_codepipeline.pipeline.name}"

  authentication = "GITHUB_HMAC"

  authentication_configuration {
    secret_token = "${sha1("${lookup(var.github, "branch")}+${lookup(var.github, "token")}")}"
  }

  filter {
    json_path    = "$.ref"
    match_equals = "refs/heads/{Branch}"
  }
}

# Wire the CodePipeline webhook into a GitHub repository.
resource "github_repository_webhook" "dashboard" {
  count      = "${var.enable_hooks}"
  repository = "${var.github["repo"]}"
  name       = "web"

  configuration {
    url          = "${aws_codepipeline_webhook.github.0.url}"
    content_type = "json"
    insecure_ssl = false
    secret       = "${sha1("${lookup(var.github, "branch")}+${lookup(var.github, "token")}")}"
  }

  events = [
    "push",
  ]
}

Debug Output

...
...
Do you want to perform these actions in workspace "nirvana"?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes
...
...
module.codepipeline_dashboard.aws_codepipeline_webhook.github: Modifying... (ID: arn:aws:codepipeline:us-west-2:203867187697:webhook:nirvana-dashboard-webhook)
  authentication_configuration.0.secret_token: "<sensitive>" => "<sensitive>"
2019/03/20 01:18:43 [ERROR] root.codepipeline_dashboard: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* aws_codepipeline_webhook.github: doesn't support update
2019/03/20 01:18:43 [ERROR] root.codepipeline_dashboard: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* aws_codepipeline_webhook.github: doesn't support update

Panic Output

Error: Error applying plan:

1 error(s) occurred:
* module.codepipeline_dashboard.aws_codepipeline_webhook.github: 1 error(s) occurred:
* aws_codepipeline_webhook.github: doesn't support update

Expected Behavior

A webhook should be updated or re-created (deleted/created again). If this is not possible - update the doc and tell the audience that the secret is not changable.

Actual Behavior

Webhook cannot be updated

Steps to Reproduce

  1. Set up the secret
  2. terraform apply
  3. Change the secret
  4. ...have an error ...
@zentavr
Copy link
Author

zentavr commented Mar 19, 2019

The workaround is the next:

  1. List the webhooks:
    aws codepipeline list-webhooks --region "us-west-2"
  2. Find yours and delete that. Be very careful!!!
    aws codepipeline delete-webhook --region "us-west-2" --name "nirvana-dashboard-webhook"
  3. Refresh the state file with terraform refresh. More verbose command you can find here
  4. Try to re-apply.

@bflad bflad added bug Addresses a defect in current functionality. service/codepipeline Issues and PRs that pertain to the codepipeline service. labels Mar 20, 2019
@russmac
Copy link

russmac commented Aug 1, 2019

Also exists in in 0.12.5

@mwarkentin
Copy link
Contributor

You can use taint to simplify the update process (forcing delete + recreate) - but yeah this seems like it should be handled by TF itself.

@ewbankkit
Copy link
Contributor

PR #11387 submitted to fix this problem.

@bflad bflad added this to the v2.45.0 milestone Jan 11, 2020
@bflad
Copy link
Contributor

bflad commented Jan 11, 2020

The fix for this has been merged and will release with version 2.45.0 of the Terraform AWS Provider, Thursday next week. Thanks to @ewbankkit for the implementation. 👍

@ghost
Copy link

ghost commented Jan 17, 2020

This has been released in version 2.45.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Mar 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/codepipeline Issues and PRs that pertain to the codepipeline service.
Projects
None yet
5 participants