$ 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
# 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",
]
}
...
...
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
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
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.
Webhook cannot be updated
terraform apply
The workaround is the next:
aws codepipeline list-webhooks --region "us-west-2"
aws codepipeline delete-webhook --region "us-west-2" --name "nirvana-dashboard-webhook"
terraform refresh
. More verbose command you can find hereAlso exists in in 0.12.5
You can use taint
to simplify the update process (forcing delete + recreate) - but yeah this seems like it should be handled by TF itself.
PR https://github.com/terraform-providers/terraform-provider-aws/pull/11387 submitted to fix this problem.
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. 👍
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!
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!
Most helpful comment
The workaround is the next:
aws codepipeline list-webhooks --region "us-west-2"
aws codepipeline delete-webhook --region "us-west-2" --name "nirvana-dashboard-webhook"
terraform refresh
. More verbose command you can find here