terraform-provider-okta icon indicating copy to clipboard operation
terraform-provider-okta copied to clipboard

Support multiple identity providers on the `okta_policy_rule_idp_discovery` resource

Open felixcolaci opened this issue 2 years ago • 3 comments

Hi. I noticed a shortcoming between the management ui and the okta_policy_rule_idp_disvovery. While it is possible to configure multiple identity providers for a given rule through the ui this is not possible through terraform yet.

UI

Bildschirmfoto 2022-07-21 um 10 47 48

Terraform

resource "okta_policy_rule_idp_discovery" "my_rule" {
  name      = "My Rule"
  policy_id = "some-policy-id"
  idp_id    = "some-idp-id"
  idp_type = "idp-type"
}

Changes

I suggest to add the possibility to configure multiple idps per discovery rule and use it in terraform like this:

resource "okta_policy_rule_idp_discovery" "my_rule" {
  name      = "My Rule"
  policy_id = "some-policy-id"

  idp {
    id   = okta_idp_social.google.id
    type = "GOOGLE"
  }
  idp {
    id   = okta_idp_social.facebook.id
    type = "FACEBOOK"
  }
}

I implemented this change in a backwards compatible way. If the legacy attributes idp_id and idp_type are set they will be used as before. However if the newly added idp {} list is used the list will take advantage over the legacy attributes. Let me know what you think! Cheers, Felix

felixcolaci avatar Jul 21 '22 09:07 felixcolaci

Thanks @felixcolaci , I'll review today/tomorrow.

monde avatar Jul 21 '22 18:07 monde

The resource test is failing on the first step. I need to spend some time looking into this. I'm going to triage into our internal work backlog.

TF_ACC=1 go test -tags unit -mod=readonly -test.v -run ^TestAccOktaPolicyRuleIdpDiscovery_crud$ ./okta 2>&1
=== RUN   TestAccOktaPolicyRuleIdpDiscovery_crud
    resource_okta_policy_rule_idp_discovery_test.go:28: Step 1/6 error: Error running apply: exit status 1

        Error: failed to set authentication policy for an SAML application: failed delete authentication policy: the API returned an error: The request was not valid: Invalid policy type specified.

          with okta_app_saml.test,
          on terraform_plugin_test.tf line 40, in resource "okta_app_saml" "test":
          40: resource "okta_app_saml" "test" {

--- FAIL: TestAccOktaPolicyRuleIdpDiscovery_crud (4.38s)
FAIL
FAIL    github.com/okta/terraform-provider-okta/okta    4.641s
FAIL

monde avatar Sep 14 '22 16:09 monde

Okta internal ref: https://oktainc.atlassian.net/browse/OKTA-532577

monde avatar Sep 14 '22 16:09 monde

I'll try to dedicate time to look at this in my current sprint.

monde avatar Oct 24 '22 19:10 monde

is there any way to support this funcionality with the current code?

ben-contreras avatar Feb 08 '24 17:02 ben-contreras