okta / terraform-provider-okta

A Terraform provider to manage Okta resources, enabling infrastructure-as-code provisioning and management of users, groups, applications, and other Okta objects.
https://registry.terraform.io/providers/okta/okta
Mozilla Public License 2.0
256 stars 207 forks source link

UnPlanned changes - `okta_app*` - unexpected `authentication_policy` #1742

Closed exitcode0 closed 5 months ago

exitcode0 commented 1 year ago

Community Note

Affected Resource(s)

Terraform Configuration Files

resource "okta_app_bookmark" "example" {
  label  = "Example"
  url    = "https://example.com"
}

Expected Behavior

Terraform Plan should outline all changes that would result from executing Terraform Apply

Actual Behavior

When the upstream API chooses default behavior we don't expose this in the Terraform Plan

In this case the existing well known behavior is that omitting authentication_policy on okta_app* resources results in the default authentication policy being used This can unexpectedly replace a authentication policy that was click-ops provisioned to an application

I believe this has something to do with this API not supporting partial updates and assuming that an omitted value is equivalent to a null value

Steps to Reproduce

  1. terraform apply
  2. Click-Ops change Auth Policy
  3. terraform apply
  4. Auth Policy has now changed in a way that was not visible to IAC

Important Factoids

Most of our engineers expect that Terraform Plan will outline all changes that would result from executing Terraform Apply When this contract is broken, it understandably catches most engineers unaware and can cause outages

One of the benefits of Terraform is that it can be rolled out gradually because it does not attempt to modify resources that are not under management But in this case this is being undermined by default behaviors in the upstream API

Some ideas below for paths forward to more intuitive behavior Things within Okta Terraform's control

Things outside the Okta TF provider's control

duytiennguyen-okta commented 11 months ago

OKTA internal reference https://oktainc.atlassian.net/browse/OKTA-669839

duytiennguyen-okta commented 5 months ago

@exitcode0. I'm trying to understand what you're trying to fix. If your goals is just to surface the change of authentication_policy in terraform, then PR #1993 should also fixed that. Is there anything else you're trying to do?

exitcode0 commented 5 months ago

This is an old issue so my memory of it is vague It seems that I was concerned that the default behaviour of the upstream APIs is not properly surfaced in the provider This would be exceedingly difficult to address based on my current understanding, so not sure if this one is worth spending much thought on