-
Notifications
You must be signed in to change notification settings - Fork 113
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
ACL Auth Method is not updated correctly #240
Comments
I worked around the issue by including a hash in the name because that forces a replacement: locals {
# Needed to workaround https://github.com/hashicorp/terraform-provider-consul/issues/240
# We can't use random_id resource, because our keepers are sensitive
hash = substr(sha256(join("", [
var.k8s.kube_config.host,
var.k8s.kube_config.cluster_ca_certificate,
data.kubernetes_secret.consul-server-token.data["token"],
])), 0, 7)
}
//noinspection MissingProperty
resource "consul_acl_auth_method" "default" {
name = "${var.k8s.name}-${local.hash}"
type = "kubernetes"
config_json = jsonencode({
Host = var.k8s.kube_config.host
CACert = var.k8s.kube_config.cluster_ca_certificate
ServiceAccountJWT = data.kubernetes_secret.consul-server-token.data["token"]
})
} For me that's OK because all the places where I refer to that auth method by name are managed within the same terraform module, so they would be updated/replaced automatically as well. |
And I was only able to perform a valid update of any kind by forcing a full replacement. |
My workaround actually breaks all clients that are using a token that was issued by that auth method. The moment the auth method is deleted and re-created, all of the associated ACL tokens become invalid and will be rejected. |
The plan reports changes on the "config" property which I'm not even using. I'm using the "config_json" version because "config" is deprecated. But I saw that after the initial apply, terraform will still read "config" and detect incorrect changes. I tried to work around that by ignoring changes to "config". Maybe the handling of "config" vs "config_json" both in terraform and my usage of it might be the problem here. |
I debugged it a bit more and using config_json with an ignore changes on config will never cause an update. For some reason, there are no changes detected in config_json. resource "consul_acl_auth_method" "default" {
name = var.k8s.name
type = "kubernetes"
config_json = jsonencode({
Host = var.k8s.kube_config.host
CACert = var.k8s.kube_config.cluster_ca_certificate
ServiceAccountJWT = data.kubernetes_secret.consul-server-token.data["token"]
})
lifecycle {
# reports changes incorrectly
ignore_changes = [config]
}
} |
If I remove the ignore_changes/lifecycle block, then there will always changes be reported (always being changed to null) but never actually applied in a way that it can be observed in consul. |
Changing from config_json back to config causes:
|
So I tried two different ways, both starting from a clean state:
Both will plan a change and claim that they applied it but they never do. The jwt never updates and a new plan is always dirty, i.e. the change never happened. |
I guess the issue that changes to terraform-provider-consul/consul/resource_consul_acl_auth_method.go Lines 70 to 90 in 02b30eb
|
Closes #240 Co-authored-by: Rémi Lapeyre <[email protected]>
Hi @whiskeysierra, thanks for reporting the issue and looking into it. The In the meantime #244 should fix the diff suppression logic. This change should be released n the coming days. |
Hi there,
Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.
Terraform Version
Terraform v0.14.5
Affected Resource(s)
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Terraform Configuration Files
Debug Output
Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.
terraform plan output
Panic Output
If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the
crash.log
.Expected Behavior
What should have happened?
ServiceAccountJWT (or rather config_json as a whole) should have been updated.
Actual Behavior
What actually happened?
Update never happens. If I run
consul acl auth-method read -name <name>
afterterraform apply
it still shows the old JWT. Consequentiallyconsul login
fails with a 500.Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
(initial)terraform apply
Important Factoids
Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?
References
Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
The text was updated successfully, but these errors were encountered: