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_bot_managment: add Bot Management resource #2672

Merged

Conversation

cwlowder
Copy link

@cwlowder cwlowder commented Aug 8, 2023

Cloudflare-Go has been updated to include bot_management, we should update terraform to also include this change.

Depends on cloudflare/cloudflare-go#1363

Closes #693

@cwlowder cwlowder marked this pull request as draft August 8, 2023 21:00
@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

This project handles dependency version bumps (including upstream changes from cloudflare-go) independently of the standard PR process using automation. This allows the dependency upgrades to land without causing merge conflicts in multiple branches and handled in a consistent way. The exception to this is security related dependency upgrades but they should be co-ordinated with the maintainer team privately.

Please remove the changes to the go.mod or go.sum files from this PR in order to proceed with review and merging.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

changelog detected ✅

@cwlowder cwlowder force-pushed the cwlowder/add-bot-management-resource branch 2 times, most recently from 64e00a0 to 4d4df86 Compare August 8, 2023 22:04
@cwlowder cwlowder marked this pull request as ready for review August 8, 2023 22:04
@jacobbednarz jacobbednarz added the workflow/pending-upstream-library Indicates an issue or PR requires changes from an upstream library. label Aug 9, 2023
@cwlowder cwlowder force-pushed the cwlowder/add-bot-management-resource branch from 4d4df86 to 5053b26 Compare August 15, 2023 22:27
@cwlowder cwlowder force-pushed the cwlowder/add-bot-management-resource branch from 5053b26 to e96a4a8 Compare August 15, 2023 22:47
@cwlowder
Copy link
Author

Cloudflare-go was updated, decided to do some more testing. Had to update the PR, but I keep getting this error when I run terraform apply in my test setup locally:

cloudflare_bot_management.bm_bots_config: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to cloudflare_bot_management.bm_bots_config, provider "provider[\"registry.terraform.io/cloudflare/cloudflare\"]" produced an
│ unexpected new value: Root resource was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

@jacobbednarz thoughts?

@jacobbednarz
Copy link
Member

@cwlowder that looks like it removed the resource due to it missing from the provider. i just bumped the Go library here so you should be able to re-run these tests now and have them work. otherwise, i can take a look shortly.

@jacobbednarz jacobbednarz removed the workflow/pending-upstream-library Indicates an issue or PR requires changes from an upstream library. label Aug 15, 2023
@jacobbednarz
Copy link
Member

ah, i can see a couple of issues here:

  • your test cases are referencing cloudflare_api_shield
  • you're missing a d.SetId call which is used as a lookup anchor (tfproviderlint is also complaining about this) and why the test cannot find the resource despite it actually being created.

i'll push up a couple of commits addressing this and you can take a look if you'd like :)

@jacobbednarz jacobbednarz force-pushed the cwlowder/add-bot-management-resource branch from a80131f to bbfefe7 Compare August 16, 2023 04:31
@jacobbednarz
Copy link
Member

@cwlowder i went ahead and pushed up those fixes. would you mind eyeballing the unentitled test case as i think i know what you were trying to achieve there but do want to be sure before we merge it that was the intention.

acceptance tests are passing

TF_ACC=1 go test ./internal/sdkv2provider -v -run "^TestAccCloudflareBotManagement_" -count 1 -timeout 120m -parallel 1
=== RUN   TestAccCloudflareBotManagement_SBFM
--- PASS: TestAccCloudflareBotManagement_SBFM (19.36s)
=== RUN   TestAccCloudflareBotManagement_Unentitled
--- PASS: TestAccCloudflareBotManagement_Unentitled (7.19s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider	27.512s

@jacobbednarz jacobbednarz force-pushed the cwlowder/add-bot-management-resource branch from bbfefe7 to 0f45ad9 Compare August 16, 2023 04:42
@cwlowder
Copy link
Author

My intention is that some zones, like a free zone, will not be able to turn on SBFM or disable auto updating of the ml model. When you attempt to do so, the API will return an error. I want to test that behavior.

@jacobbednarz
Copy link
Member

perfect. that is the behaviour I accounted for here so I think we're good to merge.

thanks!

@jacobbednarz jacobbednarz merged commit 2770081 into cloudflare:master Aug 16, 2023
9 checks passed
@github-actions github-actions bot added this to the v4.13.0 milestone Aug 16, 2023
github-actions bot pushed a commit that referenced this pull request Aug 16, 2023
@github-actions
Copy link
Contributor

This functionality has been released in v4.13.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 Aug 23, 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.

Add support for Cloudflare Bot Management
2 participants