Skip to content

Add terraform support to Okta ML Policy#675

Closed
harshampatel-sysdig wants to merge 7 commits intosysdiglabs:masterfrom
harshampatel-sysdig:feature-oktaml-terraform
Closed

Add terraform support to Okta ML Policy#675
harshampatel-sysdig wants to merge 7 commits intosysdiglabs:masterfrom
harshampatel-sysdig:feature-oktaml-terraform

Conversation

@harshampatel-sysdig
Copy link
Copy Markdown
Collaborator

@harshampatel-sysdig harshampatel-sysdig commented Oct 30, 2025

Key changes:

  • Added resource and data source for sysdig_secure_okta_ml_policy
  • Implemented CRUD operations with proper error handling
  • Added tests and documentation

@harshampatel-sysdig harshampatel-sysdig marked this pull request as draft October 30, 2025 00:51
@harshampatel-sysdig harshampatel-sysdig marked this pull request as ready for review October 30, 2025 01:15
Copy link
Copy Markdown

@daniel-almeida daniel-almeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments. I'll let someone else look at the implication of the changes as I don't have any experience with this repo.

Comment thread .vscode/launch.json Outdated
@@ -0,0 +1,15 @@
{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to push this. If you can, please add it to gitignore so this isn't tracked in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to delete it from your local machine and push once to remove it from here

Comment thread sysdig/tfresource.go Outdated
Comment on lines +709 to +710
// TODO: Iterate over a list of rules instead of hard-coding the index values
// TODO: Should we assume that only a single Malware rule can be attached to a policy?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These TODOs are intentionally kept to match the AWS ML implementation pattern. Both AWS ML and Okta ML policies currently support a single rule per policy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now yes the behavior is 1 rule per policy for these non-Falco types like malware, drift and ML ones. So we can remove the comment if needed

Comment thread sysdig/tfresource.go Outdated
})
}

_ = d.Set("rule", rules)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an error being ignored? We should handle it if so.

}

func oktaMLPolicyFromResourceData(d *schema.ResourceData) (v2.PolicyRulesComposite, error) {
policy := &v2.PolicyRulesComposite{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there's similar code for other types, but I think it makes more sense to avoid the pointer in this function and pass &policy to oktaMLPolicyReducer, which is where a pointer is actually needed.

return diag.FromErr(err)
}

id, _ := strconv.Atoi(d.Id())
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's handle the error here.

Copy link
Copy Markdown
Contributor

@ombellare ombellare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some minor comments. Let me know if you want me to add it to your other branch that you plan to merge

Comment thread .vscode/launch.json Outdated
@@ -0,0 +1,15 @@
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to delete it from your local machine and push once to remove it from here

Comment thread sysdig/tfresource.go Outdated
Comment on lines +709 to +710
// TODO: Iterate over a list of rules instead of hard-coding the index values
// TODO: Should we assume that only a single Malware rule can be attached to a policy?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now yes the behavior is 1 rule per policy for these non-Falco types like malware, drift and ML ones. So we can remove the comment if needed

Comment thread website/docs/d/secure_okta_ml_policy.md Outdated

* `anomalous_console_login` - Anomaly detection settings for logins.
* `enabled` - Whether anomaly detection is enabled.
* `threshold` - Confidence level threshold for triggering alerts.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add that only supported values for the threshold are 1, 2 and 3 please? If you would like you can update for the other ML types as well (I think they were missed there too)

Comment thread website/docs/r/secure_okta_ml_policy.md Outdated

* `description` - (Required) Rule description.
* `anomalous_console_login` - (Required) This attribute allows you to activate anomaly detection for logins and adjust its settings.
* `threshold` - (Required) Trigger at or above confidence level.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be an enabled field here too similar to how you have on your data source.

Changed threshold value descriptions from 'High/Medium/Low' to 'Default/High/Higher' for ML policies
@tembleking
Copy link
Copy Markdown
Member

Closed as duplicate of #676, since this is a PR from a fork and secrets will not be passed to the CI.

@tembleking tembleking closed this Nov 3, 2025
harshampatel-sysdig added a commit that referenced this pull request Nov 18, 2025
Key changes:

- Added resource and data source for sysdig_secure_okta_ml_policy
- Implemented CRUD operations with proper error handling
- Added tests and documentation

Similar open PR:
#675 (I'll
close this once new one merged)

---------

Co-authored-by: Fede Barcelona <fede_rico_94@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants