terraform-provider-zitadel
terraform-provider-zitadel copied to clipboard
Zitadel provider fails to upload images using resource "zitadel_label_policy"
Preflight Checklist
- [X] I could not find a solution in the documentation, the existing issues or discussions
- [ ] I have joined the ZITADEL chat
Version
v1.0.5
ZITADEL Version
Any
Describe the problem caused by this bug
When configuring Zitadel provider with the jwt_profile_file
parameter, file upload fails for images on zitadel_label_policy
resource.
Configuration example of the Zitadel provider:
provider "zitadel" {
domain = "dev.example.org"
port = "443"
jwt_profile_file = "./terraform-sa.json"
}
Resource example:
resource "zitadel_label_policy" "label_policy" {
org_id = zitadel_org.org.id
hide_login_name_suffix = true
primary_color = "#578CAC"
background_color = "#D2D7DF"
warn_color = "#CF2C17"
font_color = "#313946"
primary_color_dark = "#9FC8E0"
background_color_dark = "#434E60"
warn_color_dark = "#F2988C"
font_color_dark = "#E5EAF0"
disable_watermark = true
set_active = true
logo_hash = filemd5("resources/images/logo-light-square.jpeg")
logo_path = "resources/images/logo-light-square.jpeg"
logo_dark_hash = filemd5("resources/images/logo-dark-square.jpeg")
logo_dark_path = "resources/images/logo-dark-square.jpeg"
icon_hash = filemd5("resources/images/logo-light-square.jpeg")
icon_path = "resources/images/logo-light-square.jpeg"
icon_dark_hash = filemd5("resources/images/logo-dark-square.jpeg")
icon_dark_path = "resources/images/logo-dark-square.jpeg"
# font_hash = filemd5("resources/fonts/noto-sans.ttf")
# font_path = "resources/fonts/noto-sans.ttf"
}
Received error:
Error: failed to upload logo: [{0 either 'jwt_profile_file' or 'jwt_profile_json' is required []}]
│
│ with module.organizations.zitadel_label_policy.ares_label_policy,
│ on modules/organizations/ares.tf line 147, in resource "zitadel_label_policy" "ares_label_policy":
│ 147: resource "zitadel_label_policy" "ares_label_policy" {
│
As a result configuration of images (Including their file upload) fails, not the configuration of colors and options.
To reproduce
Execute a terraform apply step with configuration described above
Screenshots
No response
Expected behavior
Should succeed with the file upload and creation/update of the related resource
Relevant Configuration
No response
Additional Context
There is, if not mistaken one line of code to change in file client.go
to get it work. The fix has been tested successfully (Replacing official plugin with a compiled one based on the most recent main branch commit).
Following condition :
else if jwtProfileFile != "" {
options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(jwtProfileFile)))
keyPath = token
}
should be changed to :
else if jwtProfileFile != "" {
options = append(options, zitadel.WithJWTProfileTokenSource(middleware.JWTProfileFromPath(jwtProfileFile)))
keyPath = jwtProfileFile
}
With keyPath set to jwtProfileFile
, file upload of the image is successful.