Skip to content
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

Removing custom attributes from empty list on Access apps doesn't work #3986

Closed
3 tasks done
BSFishy opened this issue Sep 12, 2024 · 3 comments · Fixed by #3987
Closed
3 tasks done

Removing custom attributes from empty list on Access apps doesn't work #3986

BSFishy opened this issue Sep 12, 2024 · 3 comments · Fixed by #3987
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.
Milestone

Comments

@BSFishy
Copy link
Contributor

BSFishy commented Sep 12, 2024

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

❯ terraform -v
Terraform v1.9.3
on darwin_arm64
+ provider registry.terraform.io/cloudflare/cloudflare v4.41.0

Your version of Terraform is out of date! The latest version
is 1.9.5. You can update by downloading from https://www.terraform.io/downloads.html

Affected resource(s)

cloudflare_access_application

Terraform configuration files

terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "~> 4.0"
    }
  }
}

variable "account_id" {
  default = "[my account id]"
}

resource "cloudflare_access_application" "test" {
  name       = "TESTING"
  type       = "saas"
  account_id = var.account_id

  saas_app {
    name_id_format                   = "id"
    allow_pkce_without_client_secret = false

    # custom_attribute {
    #   friendly_name = "My custom attribute 2"
    #   name          = "attribute2"
    #   name_format   = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
    #   required      = false
    #   source {
    #     name        = "email"
    #     name_by_idp = {}
    #   }
    # }

    # custom_attribute {
    #   friendly_name = "My custom attribute 3"
    #   name          = "attribute3"
    #   name_format   = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"
    #   required      = false
    #   source {
    #     name        = "email"
    #     name_by_idp = {}
    #   }
    # }
  }
}

Link to debug output

https://gist.github.com/BSFishy/ee9a8dd363f2d7c84ec0d7aab1c5415c

Panic output

No response

Expected output

When there are no custom attributes (or custom claims for OIDC apps), the attributes or claims should be removed.

Actual output

The attributes/claims are not removed.

Steps to reproduce

  1. Copy and set a proper account ID in the provided config
  2. Apply
  3. Uncomment custom attributes
  4. Apply
  5. Comment custom attributes
  6. Apply
  7. Notice the attributes weren't deleted on the server

Additional factoids

The offending logic is found here:

if SaasConfig.CustomClaims == nil {
SaasConfig.CustomClaims = &[]cloudflare.OIDCClaimConfig{claim}
} else {
*SaasConfig.CustomClaims = append(*SaasConfig.CustomClaims, claim)
}

This logic was introduced in a PR (#3713) that updated cloudflare-go to a version where this issue may be resolved (providing nil doesn't touch the data, providing a slice sets the data to the slice), however this logic was originally misimplemented.

References

No response

@BSFishy BSFishy added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 12, 2024
Copy link
Contributor

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label Sep 12, 2024
@BSFishy
Copy link
Contributor Author

BSFishy commented Sep 12, 2024

I have fixed this bug locally and will submit a PR ASAP

Copy link
Contributor

This functionality has been released in v4.42.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant