Skip to content

[datadog_compliance_custom_framework] Terraform Provider for Custom Frameworks #2975

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

Open
wants to merge 51 commits into
base: master
Choose a base branch
from

Conversation

nkonjeti
Copy link

@nkonjeti nkonjeti commented Apr 16, 2025

Motivation:

We wanted a terraform provider to interact with our Custom Framework APIs. The terraform resources will remain as the source of truth so whenever a resource is updated/created/deleted this will be reflected in the database and UI.

Testing

I built the Terrraform provider locally.

Tested the following:

Creating
Screenshot 2025-04-25 at 4 36 07 PM

Updating
Screenshot 2025-04-25 at 4 37 17 PM

Deleting/Destroying
Screenshot 2025-04-25 at 4 38 52 PM

Changing order of rules
Screenshot 2025-04-27 at 4 07 16 PM
no changes in state so no action taken

Terraform Provider Immutable Fields (Handle And Version)
Screenshot 2025-05-19 at 10 23 46 AM

  • if handle or version is changed in a framework this will delete the old framework and create a new one with the new handle and version
Screenshot 2025-05-19 at 10 16 40 AM
  • in this example, updating the version to 2 deleted the old framework (version 1) and created a new framework with version 2
Screenshot 2025-05-19 at 10 20 48 AM
  • in this example updating the handle and version deleted the old framework with the old handle and version, and created a new framework with the new handle and version

Testing Large Input
Created this Framework: https://dd.datad0g.com/security/compliance/home/custom/my-custom-framework-terraform-3/3.0.0?previousUrl=%2Fsecurity%2Fcompliance%2Fhome&timestamp=1747948011353&live=true
one control with over 200 rule ids (seconds to complete)

Commands:

cd examples/resources/datadog_custom_framework 
terraform init
terraform plan -var="datadog_api_key=<>" -var="datadog_app_key=<>"
terraform apply

also added unit tests!

@nkonjeti nkonjeti requested review from a team as code owners April 16, 2025 22:27
@nkonjeti nkonjeti changed the title provider for custom frameworks Terraform Provider for Custom Frameworks Apr 24, 2025
@nkonjeti nkonjeti force-pushed the neha.konjeti/framework-provider branch from ccaf302 to f8a90fe Compare April 25, 2025 18:59
@nkonjeti nkonjeti marked this pull request as draft April 25, 2025 20:34
@nkonjeti nkonjeti changed the title Terraform Provider for Custom Frameworks [K9VULN-4477]: Terraform Provider for Custom Frameworks Apr 30, 2025
@nkonjeti nkonjeti marked this pull request as ready for review May 1, 2025 21:14
@nkonjeti nkonjeti requested a review from a team as a code owner May 1, 2025 21:14
@nkonjeti nkonjeti changed the title [K9VULN-4477]: Terraform Provider for Custom Frameworks Terraform Provider for Custom Frameworks May 2, 2025
@nkonjeti nkonjeti force-pushed the neha.konjeti/framework-provider branch from ac03605 to e2e496e Compare May 14, 2025 17:25
@nkonjeti nkonjeti requested a review from vbarth2 May 14, 2025 17:37
@nkonjeti nkonjeti requested a review from vbarth2 May 16, 2025 17:50
@fpighi fpighi changed the title Terraform Provider for Custom Frameworks [datadog_compliance_custom_framework] Terraform Provider for Custom Frameworks May 19, 2025
apiReqMap := make(map[string]datadogV2.CustomFrameworkRequirement)
apiCtrlMap := make(map[string]map[string]datadogV2.CustomFrameworkControl)

for _, req := range data.GetData().Attributes.Requirements {
Copy link

Choose a reason for hiding this comment

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

NIT: this is very hard to read in github, could we extract some of the inner loops to their own methods so its more digestible? It also would make it easier to read in the editor

return v.Description(ctx)
}

func (v requirementNameValidator) ValidateList(ctx context.Context, req validator.ListRequest, resp *validator.ListResponse) {
Copy link

Choose a reason for hiding this comment

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

Is there a specific reason why we need two validators? the code looks pretty similar between these two (I am probably missing something)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants