Cidaas / terraform-provider-cidaas

This provider helps you managing your cidaas instances in an automated way. It enables you to configure and maintain apps and registration fields as part of a Terraform deployment. Secure – Fast – And unrivaled Swabian.
https://registry.terraform.io/providers/Cidaas/cidaas/latest/docs
MIT License
3 stars 4 forks source link

Cannot refresh HostedPages #12

Closed sja closed 7 months ago

sja commented 8 months ago

I can provision Hosted Pages Group, but tf is never able to refresh it and therefore cannot update them.

module.hostedpages.module.LocalDev.cidaas_hosted_page.page: Refreshing state... [id=LocalDev]
module.apps.module.app_LocalCustomUI.cidaas_app.app: Refreshing state... [id=2ab69030-0393-40e2-xxxx-xxx]

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: failed to read hosted page LocalDev
│ 
│   with module.hostedpages.module.LocalDev.cidaas_hosted_page.page,
│   on ../../modules/hostedpages/pages.tf line 41, in resource "cidaas_hosted_page" "page":
│   41: resource "cidaas_hosted_page" "page" {
│ 
│ status code not 200. found 404, response body:
│ {"success":true,"status":404}
│ 
╵
error: Recipe `tf` failed on line 8 with exit code 1

For me it seems that the id is not used when fetching from cidaas API. When using the admin-ui and manually edit the HostedPages, i can see a successful call to /hostedpages-srv/hpgroup/LocalDev with the previously provisioned Hosted Page Group.

I'm using provider version 2.4.5, tf v1.6.6 on macOS.

sja commented 8 months ago

I created a minimal example:

provider "cidaas" {
  redirect_uri  = "https://<tennant>.cidaas.eu/user-profile/editprofile"
  base_url      = "https://<tennant>.cidaas.eu"
}

locals {
    pages = [
        { id = "register", uri = "/register" },
        { id = "register_success", uri = "/register" },
        { id = "login", uri = "/login" },
        { id = "login_success", uri = "/demo-app/redirect_uri" }
    ]
    locales = [ "de", "en-US", "en-GB", "en" ]
}

resource "cidaas_hosted_page" "page" {
    hosted_page_group_name = "TF-Test-LocalDev"
    default_locale         = "de"

    dynamic "hosted_pages" {
        for_each = setproduct(local.pages, local.locales)
        content {
            hosted_page_id = hosted_pages.value[0].id
            locale         = hosted_pages.value[1]
            url            = "http://localhost${hosted_pages.value[0].uri}"
        }
    }

}

On the first terraform apply, the hosted pages are added:

cidaas_hosted_page.page: Creating...
cidaas_hosted_page.page: Creation complete after 0s [id=TF-Test-LocalDev]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

On the second run I got this:

cidaas_hosted_page.page: Refreshing state... [id=TF-Test-LocalDev]
╷
│ Error: failed to read hosted page TF-Test-LocalDev
│ 
│   with cidaas_hosted_page.page,
│   on main.tf line 17, in resource "cidaas_hosted_page" "page":
│   17: resource "cidaas_hosted_page" "page" {
│ 
│ status code not 200. found 404, response body: {"success":true,"status":404}
│ 
tujit commented 7 months ago

Version 2.5.1 released with the fix. Thank you for informing us about the bug. Appreciate your support!!