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
258 stars 209 forks source link

okta_app_access_policy_assignment cannot be used with apps of sign-on mode "AWS IAM Role" #2092

Open sfrancis-splunk opened 2 months ago

sfrancis-splunk commented 2 months ago

Community Note

Terraform Version

Affected Resource(s)

Terraform Configuration Files

data "okta_app" "aws_govcloudtest1" {
  #label = "AWS: GovCloudTest1"
  id = "<id-of-AWS-okta-app>"
}

resource "okta_app_access_policy_assignment" "aws_govcloudtest1_assign" {
  app_id    = data.okta_app.aws_govcloudtest1.id
  policy_id = okta_app_signon_policy.any-two-factors.id
}

resource "okta_app_signon_policy" "any-two-factors" {
    name = "Any two factors"
    description = "Require two factors to access."
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

The resource should have been created linking the app access policy to the app specified in the data resource. The app specified is an amazon_aws app with the Sign On tab set to "AWS IAM Role" ("signOnMode": "AWS_IAM_ROLE" in app JSON output)

Can this be done in the Admin UI?

Yes, this is our workaround at present.

Can this be done in the actual API call?

Yes: there are no requirements in the App API docs for specific signOnMode types with linking access policies.

Actual Behavior

terraform plan reports that the resource will be created:

Terraform will perform the following actions:
# module.app_policy_module.okta_app_access_policy_assignment.aws_govcloudtest1_assign will be created
+ resource "okta_app_access_policy_assignment" "aws_govcloudtest1_assign" {
    + app_id    = "<id-of-aws-app>"
    + id        = (known after apply)
    + policy_id = "<id-of-policy>"
  }

terraform apply fails with:

β”‚ Error: issue with inner app response
β”‚ 
β”‚   with module.app_policy_module.okta_app_access_policy_assignment.aws_govcloudtest1_assign,
β”‚   on modules/app-policy/aws_govcloudtest1_assign.tf line 2, in resource "okta_app_access_policy_assignment" "aws_govcloudtest1_assign":
β”‚    2: resource "okta_app_access_policy_assignment" "aws_govcloudtest1_assign" {
β”‚ 
β”‚ okta list applications response does not contain a concrete app

Steps to Reproduce

  1. terraform plan
  2. terraform apply

Important Factoids

The error seems to stem from resource_okta_app_access_policy_assignment.go : concreteAppID only iterates through the main Okta SDK application types.

It's understandable that the SDK wouldn't support OIN-specific apps but since there is nothing in the Okta API preventing linking an access policy to an OIN app this feels like a bug.

References