Skip to content
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

resource/cloudflare_api_shield_schema_validation_settings #2841

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

djhworld
Copy link
Contributor

Adds new resource resource/cloudflare_api_shield_schema_validation_settings

Cloudflare-Go has been updated to include support for schema validation settings in API Shield Schema Validation 2.0

This PR updates the terraform provider to support managing these settings in API Shield

Depends on cloudflare/cloudflare-go#1418


### Read-Only

- `id` (String) The ID of this resource.
Copy link

Choose a reason for hiding this comment

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

Which ID are we talking about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is auto-generated from the docs,it's mapped to the zone ID

Required: true,
},
"validation_override_mitigation_action": {
Description: "When set, this overrides both zone level and operation level mitigation actions",
Copy link

Choose a reason for hiding this comment

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

Maybe add that this can only take values "none" and "disable_override" to kill SV 2.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather not encode this into here, the API rejects invalid values.

return nil
}

func resourceCloudflareAPIShieldSchemaValidationSettingsDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
Copy link

Choose a reason for hiding this comment

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

Why is this a delete? We are not deleting anything? Or do you have to give a delete-function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if a resource is removed from the terraform state, it deletes the resource - as we don't actually "delete" anything this just resets the state of the settings to default.

It could be argued there should be a DELETE endpoint on the API, however this implementation will achieve the same.

return fmt.Errorf("encountered error getting schema validation settings: %w", err)
}

if result.DefaultMitigationAction != "none" {
Copy link

Choose a reason for hiding this comment

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

If we want to verify that we receive the default-values, maybe compare against cloudflareAPIShieldSchemaValidationSettingsDefault().DefaultMitigationAction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed 671ce3c

@github-actions
Copy link
Contributor

changelog detected ✅

@djhworld djhworld force-pushed the dharper/APISHI-2362 branch 2 times, most recently from 671ce3c to 38b8624 Compare October 26, 2023 14:07
Adds new resource `resource/cloudflare_api_shield_schema_validation_settings`
@jacobbednarz
Copy link
Member

acceptance tests all looking good!

TF_ACC=1 go test ./internal/sdkv2provider -v -run "^TestAccCloudflareAPIShieldSchemaValidationSettings_" -count 1 -timeout 120m -parallel 1
=== RUN   TestAccCloudflareAPIShieldSchemaValidationSettings_Create
--- PASS: TestAccCloudflareAPIShieldSchemaValidationSettings_Create (14.01s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider	15.002s

thanks!

@jacobbednarz jacobbednarz merged commit 64e94e1 into cloudflare:master Oct 30, 2023
8 checks passed
@github-actions github-actions bot added this to the v4.18.0 milestone Oct 30, 2023
github-actions bot pushed a commit that referenced this pull request Oct 30, 2023
Copy link
Contributor

This functionality has been released in v4.18.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants