pulumi / pulumi-okta

An Okta Pulumi resource package, providing multi-language access to Okta
Apache License 2.0
9 stars 2 forks source link

Theme not working correctly #493

Closed tomburge closed 3 weeks ago

tomburge commented 9 months ago

What happened?

When I try to use Theme (https://www.pulumi.com/registry/packages/okta/api-docs/theme/) unless I put all the parameters, meaning nothing is optional, the stack creates successfully. When I try to change one parameter, Okta updates successfully but Pulumi reports an error.

Example

config:

    theme:
      # Required
      brand_id: bndcyf80bwlwrLLak5d7
      theme_id: thecyf80bx1G8OazH5d7
      # Optional
      bg_img: c:\\temp\\bg-image.png
      email_template: FULL_THEME # OKTA_DEFAULT, FULL_THEME
      end_user_dashboard: OKTA_DEFAULT # OKTA_DEFAULT, WHITE_LOGO_BACKGROUND, FULL_THEME, LOGO_ON_FULL_WHITE_BACKGROUND
      error_page: OKTA_DEFAULT # OKTA_DEFAULT, BACKGROUND_SECONDARY_COLOR, BACKGROUND_IMAGE
      favicon: c:\\temp\\favicon.ico
      logo: c:\\temp\\logo2.png
      pc_contrast: ffffff # 1662dd
      pc_hex: 1662dd
      sc_contrast: 000000 # ebebed
      sc_hex: ebebed
      signin_page: OKTA_DEFAULT # OKTA_DEFAULT, BACKGROUND_SECONDARY_COLOR, BACKGROUND_IMAGE

code:

def org_theme(theme):
    """
    Configures the Organization Theme in Customizations -> Branding
    """
    theme_config = Theme(
        resource_name="org_theme",
        background_image=theme.get("bg_img"),
        brand_id=theme.get("brand_id"),
        email_template_touch_point_variant=theme.get("email_template"),
        end_user_dashboard_touch_point_variant=theme.get("end_user_dashboard"),
        error_page_touch_point_variant=theme.get("error_page"),
        favicon=theme.get("favicon"),
        logo=theme.get("logo"),
        primary_color_contrast_hex=theme.get("pc_contrast"),
        primary_color_hex=theme.get("pc_hex"),
        secondary_color_contrast_hex=theme.get("sc_contrast"),
        secondary_color_hex=theme.get("sc_hex"),
        sign_in_page_touch_point_variant=theme.get("signin_page"),
        theme_id=theme.get("theme_id"),
    )
    return theme_config

Initial stack:

(venv) C:\repos\tom\okta\okta-pulumi>pulumi up
Previewing update (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/previews/a9ba5d2c-bb42-481d-95b4-24a3d6fde322

     Type                 Name              Plan
     pulumi:pulumi:Stack  okta-pulumi-okta
 +   └─ okta:index:Theme  org_theme         create
Resources:
    + 1 to create
    2 unchanged

Do you want to perform this update? yes
Updating (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/updates/47

     Type                 Name              Status
     pulumi:pulumi:Stack  okta-pulumi-okta
 +   └─ okta:index:Theme  org_theme         created (0.35s)
Resources:
    + 1 created
    2 unchanged

Duration: 3s

Stack change:

(venv) C:\repos\tom\okta\okta-pulumi>pulumi up
Previewing update (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/previews/a7e016de-8598-4005-9a01-30756938605f

     Type                 Name              Plan       Info
     pulumi:pulumi:Stack  okta-pulumi-okta
 ~   └─ okta:index:Theme  org_theme         update     [diff: +backgroundImage,favicon,logo~emailTemplateTouchPointVariant,primaryColorContrastHex,primaryColorHex,secondaryColorContrastHex,secondaryColorHex]
Resources:
    ~ 1 to update
    2 unchanged

Do you want to perform this update? yes
Updating (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/updates/48

     Type                 Name              Status                  Info
     pulumi:pulumi:Stack  okta-pulumi-okta  **failed**              1 error
 ~   └─ okta:index:Theme  org_theme         **updating failed**     [diff: +backgroundImage,favicon,logo~emailTemplateTouchPointVariant,primaryColorContrastHex,primaryColorHex,secondaryColorContrastHex,secondaryColorHex]; 1 error
Diagnostics:
  pulumi:pulumi:Stack (okta-pulumi-okta):
    error: update failed

  okta:index:Theme (org_theme):
    error: 1 error occurred:
        * updating urn:pulumi:okta::okta-pulumi::okta:index/theme:Theme::org_theme: 1 error occurred:
        * failed to update theme: 400 Bad Request

Resources:
    2 unchanged

Duration: 4s

Output of pulumi about

(venv) C:\repos\tom\okta\okta-pulumi>pulumi about
CLI
Version      3.99.0
Go Version   go1.21.5
Go Compiler  gc

Plugins
NAME    VERSION
okta    4.6.2
python  unknown

Host
OS       Microsoft Windows 10 Pro
Version  10.0.19045 Build 19045
Arch     x86_64

This project is written in python: executable='C:\repos\tom\okta\okta-pulumi\venv\Scripts\python.exe' version='3.11.4'

Current Stack: tomburge/okta-pulumi/okta

TYPE                                          URN
pulumi:pulumi:Stack                           urn:pulumi:okta::okta-pulumi::pulumi:pulumi:Stack::okta-pulumi-okta
pulumi:providers:okta                         urn:pulumi:okta::okta-pulumi::pulumi:providers:okta::default_4_6_2
okta:index/orgConfiguration:OrgConfiguration  urn:pulumi:okta::okta-pulumi::okta:index/orgConfiguration:OrgConfiguration::org_configuration
okta:index/theme:Theme                        urn:pulumi:okta::okta-pulumi::okta:index/theme:Theme::org_theme

Found no pending operations associated with okta

Backend
Name           pulumi.com
URL            https://app.pulumi.com/tomburge
User           tomburge
Organizations  tomburge
Token type     personal

Dependencies:
NAME         VERSION
pip          23.3.2
pulumi-okta  4.6.2
setuptools   69.0.3
wheel        0.42.0

Pulumi locates its logs in C:\Users\tom\AppData\Local\Temp by default

Additional context

This is an Okta developer instance. The config and function work successfully the first time, but if you try to change a parameter or you create with a single parameter such as logo with the brand id and theme id then the update errors.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

tomburge commented 9 months ago

After the initial stack creation and with no additional updates to code or config, there is a change to the background image, favicon, and logo when you do pulumi up. This results in a failure.

Failure

(venv) C:\repos\tom\okta\okta-pulumi>pulumi up
Previewing update (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/previews/3f233456-ba2d-4ffc-b5b7-0f3b55b683c3

     Type                 Name              Plan       Info
     pulumi:pulumi:Stack  okta-pulumi-okta
 ~   └─ okta:index:Theme  org_theme         update     [diff: +backgroundImage,favicon,logo~emailTemplateTouchPointVariant,primaryColorContrastHex,primaryColorHex,secondaryColorContrastHex,secondaryColorHex]
Resources:
    ~ 1 to update
    2 unchanged

Do you want to perform this update? yes
Updating (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/updates/51

     Type                 Name              Status                  Info
     pulumi:pulumi:Stack  okta-pulumi-okta  **failed**              1 error
 ~   └─ okta:index:Theme  org_theme         **updating failed**     [diff: +backgroundImage,favicon,logo~emailTemplateTouchPointVariant,primaryColorContrastHex,primaryColorHex,secondaryColorContrastHex,secondaryColorHex]; 1 error
Diagnostics:
  okta:index:Theme (org_theme):
    error: 1 error occurred:
        * updating urn:pulumi:okta::okta-pulumi::okta:index/theme:Theme::org_theme: 1 error occurred:
        * failed to update theme: 400 Bad Request

  pulumi:pulumi:Stack (okta-pulumi-okta):
    error: update failed

Resources:
    2 unchanged

Duration: 4s

Deleting the stack

(venv) C:\repos\tom\okta\okta-pulumi>pulumi up
Previewing update (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/previews/0681123b-abea-4960-9b09-03344441a09e

     Type                 Name              Plan
     pulumi:pulumi:Stack  okta-pulumi-okta
 -   └─ okta:index:Theme  org_theme         delete
Resources:
    - 1 to delete
    2 unchanged

Do you want to perform this update? yes
Updating (okta)

View in Browser (Ctrl+O): https://app.pulumi.com/tomburge/okta-pulumi/okta/updates/52

     Type                 Name              Status
     pulumi:pulumi:Stack  okta-pulumi-okta
 -   └─ okta:index:Theme  org_theme         deleted (0.31s)
Resources:
    - 1 deleted
    2 unchanged

Duration: 3s

The stack shows deleted but all of the customizations in Okta are not set to the defaults. I.E. the logo, favicon, background image, etc are still there.

iwahbe commented 9 months ago

Hi @tomburge. I'm sorry to hear that. It looks like this boils down to a documentation error. This should be attached to class Theme:

https://github.com/pulumi/pulumi-okta/blob/584c31beaf93b32d8bda49e5475df1ff35046eb9/sdk/python/pulumi_okta/theme.py#L528-L542

That explains the lack of a true create and delete semantic, as well as the weirdness for optional args.