terraform-provider-argocd
terraform-provider-argocd copied to clipboard
feature request to add UPSERT option
Currently:
argocd-cli has argocd app create has --upsert flag that allows soft update of the application declaration.
This terraform provider has no option to instruct the --upsert option in the manifest. This results in a complete recreation of the resource upon run, which in many cases undesirable behaviour and should be optionated.
Desired behaviour:
resource "argocd_application" "my_application" {
metadata {
name = local.name
....
.....
}
upsert = true
}
This is the behavior argocd_application is already using internally
Example if we make the following change to an existing resource :
parameter {
name = "image.tag"
- value = "6.2.4"
+ value = "6.2.5"
}
Terraform will perform the following actions:
# argocd_application.directory will be updated in-place
~ resource "argocd_application" "directory" {
id = "test-recurse"
# (2 unchanged attributes hidden)
~ spec {
# (2 unchanged attributes hidden)
~ source {
# (3 unchanged attributes hidden)
~ helm {
# (2 unchanged attributes hidden)
- parameter {
- force_string = false -> null
- name = "architecture" -> null
- value = "standalone" -> null
}
- parameter {
- force_string = false -> null
- name = "commonAnnotations.external-dns\\.alpha\\.kubernetes\\.io/hostname" -> null
- value = "plop" -> null
}
- parameter {
- force_string = false -> null
- name = "image.tag" -> null
- value = "6.2.4" -> null
}
+ parameter {
+ name = "architecture"
+ value = "standalone"
}
+ parameter {
+ name = "commonAnnotations.external-dns\\.alpha\\.kubernetes\\.io/hostname"
+ value = "plop"
}
+ parameter {
+ name = "image.tag"
+ value = "6.2.5"
}
}
}
# (2 unchanged blocks hidden)
}
The only parameters that require a complete recreation are .metadata.name and .metadata.namespace
Is there anything I could do for projects? Or is this a limitation on the Argo API?
│ rpc error: code = InvalidArgument desc = existing project spec is different; use upsert flag to force update; difference in keys
│ "Destinations,1,Server,Destinations,1,Namespace,Destinations,1,Name,Destinations,3,Server,Destinations,3,Namespace,Destinations,3,Name,Description"
Is there anything I could do for projects? Or is this a limitation on the Argo API?
What did the Terraform plan look like before this error?
@onematchfox nevermind, I just forgot to move the terraform resource after refactoring into modules 🤦🏼♂️
Basically it was around the lines of 1 to destroy, 0 to change, 1 to create, so it was trying to delete->create, or create->delete instead of upsert, there was just a collision
As per @MrLuje's comment, the provider will already update applications that are within Terraform state. If you are trying to onboard an existing application (that was created outside of Terraform) then you should first need to import the resource after which it will be updated by Terraform (rather than being recreated).