Skip to content

Conversation

@smakys
Copy link

@smakys smakys commented Sep 30, 2025

After cloudflare_zone_subscription import. The terraform plan will still an "update in-place" status with changes to frequency and rate plan. This is because frequency and rate plan will always return a key/value even if not in the request body.

  • Updated various fields to be computed_optional

  • Provide acceptance test for various states

  • [x ] I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

#5971

Additional context & links

stainless-app bot and others added 23 commits November 4, 2025 18:13
This change adds the token validation and schema validation acceptance tests to CI runner.
Acceptance test zone `terraform.cfapi.net` seems to already be entitled to utilize both services.

It also ensures that the schema validation tests can be executed in parallel without interferring with each other:
```
$ TF_ACC=1 go test ./internal/services/token_validation_* ./internal/services/schema_validation_* -run "^TestAccCloudflareTokenValidationConfig|TestAccCloudflareTokenValidationRules|TestAccCloudflarePerOperationSetting|TestAccCloudflareSchemaValidationSchemas|TestAccCloudflareSchemaValidationZoneSettings" -v -count 1
=== RUN   TestAccCloudflareTokenValidationConfig
--- PASS: TestAccCloudflareTokenValidationConfig (36.15s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/services/token_validation_config	37.827s
=== RUN   TestAccCloudflareTokenValidationRules
--- PASS: TestAccCloudflareTokenValidationRules (26.03s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/services/token_validation_rules	28.480s
=== RUN   TestAccCloudflarePerOperationSetting
--- PASS: TestAccCloudflarePerOperationSetting (15.87s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/services/schema_validation_operation_settings	21.278s
=== RUN   TestAccCloudflareSchemaValidationSchemas
--- PASS: TestAccCloudflareSchemaValidationSchemas (13.31s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/services/schema_validation_schemas	16.719s
=== RUN   TestAccCloudflareSchemaValidationZoneSettings
--- PASS: TestAccCloudflareSchemaValidationZoneSettings (18.18s)
PASS
ok  	github.com/cloudflare/terraform-provider-cloudflare/internal/services/schema_validation_settings	22.567s
```
* Add mcp portals acceptance tests

* Fix mcp portals acceptance tests

* Fix mcp portals acceptance tests
@mgirouard mgirouard force-pushed the sui/5971-fix-cloudflare-zone-subscription-update-in-place branch from f50cab7 to 4f5714b Compare November 5, 2025 15:46
@mgirouard
Copy link
Contributor

@smakys I've reset your branch so your commit is back on top of next. Here's what I'm seeing when running the tests for zone_subscription:

mgirouard@sixteen:~/src/terraform-provider-cloudflare$ TF_ACC=1 go test -v ./internal/services/zone_subscription/...
go: downloading github.com/cloudflare/cloudflare-go/v6 v6.2.1-0.20251105113648-556f4c6627fe
=== RUN   TestZoneSubscriptionDataSourceModelSchemaParity
=== PAUSE TestZoneSubscriptionDataSourceModelSchemaParity
=== RUN   TestAccCloudflareZoneSubscriptionDataSource_Basic
    data_source_test.go:17: error checking value for attribute at path: data.cloudflare_zone_subscription.hyhknhabqt.rate_plan.id, err: expected value cf_ent for StringExact check, got: enterprise

--- SKIP: TestAccCloudflareZoneSubscriptionDataSource_Basic (0.00s)
=== RUN   TestZoneSubscriptionModelSchemaParity
=== PAUSE TestZoneSubscriptionModelSchemaParity
=== RUN   TestAccCloudflareZoneSubscription_ImportNoChanges
--- PASS: TestAccCloudflareZoneSubscription_ImportNoChanges (7.58s)
=== RUN   TestAccCloudflareZoneSubscription_Basic
--- PASS: TestAccCloudflareZoneSubscription_Basic (9.79s)
=== RUN   TestAccCloudflareZoneSubscription_WithPlanChange
--- PASS: TestAccCloudflareZoneSubscription_WithPlanChange (22.74s)
=== RUN   TestAccCloudflareZoneSubscription_WithPlanAndComputedOptionalRatePlanFields
--- PASS: TestAccCloudflareZoneSubscription_WithPlanAndComputedOptionalRatePlanFields (12.91s)
=== RUN   TestAccCloudflareZoneSubscription_WithPlanThatReturnsNotApplicableFrequencyResultingInError
    resource_test.go:194: Step 3/3 error running import: ImportStateVerify attributes not equivalent. Difference is shown below. The - symbol indicates attributes missing after import.

          map[string]string{
        -       "rate_plan.public_name": "API Shield Website",
        +       "rate_plan.public_name": "Enterprise",
          }
--- FAIL: TestAccCloudflareZoneSubscription_WithPlanThatReturnsNotApplicableFrequencyResultingInError (12.77s)
=== CONT  TestZoneSubscriptionDataSourceModelSchemaParity
=== CONT  TestZoneSubscriptionModelSchemaParity
--- PASS: TestZoneSubscriptionDataSourceModelSchemaParity (0.00s)
=== NAME  TestZoneSubscriptionModelSchemaParity
    integrity.go:126: mismatch at "[email protected]": expected "computed_optional", received "frequency, computed_optional"
    integrity.go:129: If you are implementing a custom solution, you can suppress these warning(s) by adding the following to the test, as an example:
         + errs.Ignore("[email protected]")
--- FAIL: TestZoneSubscriptionModelSchemaParity (0.00s)
FAIL
FAIL    github.com/cloudflare/terraform-provider-cloudflare/internal/services/zone_subscription 65.800s
FAIL

@mgirouard
Copy link
Contributor

@smakys I looked more into the failure in TestAccCloudflareZoneSubscription_WithPlanThatReturnsNotApplicableFrequencyResultingInError

Create Request:

{
    "frequency": "monthly",
    "rate_plan": {
        "id": "enterprise"
    }
}

Create Response:
(note: the rate plan .id does not match the request)

{
    "errors": [],
    "messages": [],
    "result": {
        "account_id": "12946570",
        "cancel_at_period_end": false,
        "client_secrets": null,
        "component_values": [],
        "created_date": "2024-08-15T09:00:55Z",
        "currency": "USD",
        "frequency": "not-applicable",
        "handler": "stripe",
        "id": "afcacda4178f4fc09ae93be3ffed0500",
        "intent": "EMPLOYEE",
        "price": 0,
        "product": {
            "billing": "",
            "duration": 0,
            "name": "api_shield",
            "period": "",
            "public_name": "API Shield Website"
        },
        "rate_plan": {
            "currency": "USD",
            "externally_managed": false,
            "id": "api_shield_zone",
            "is_contract": true,
            "public_name": "API Shield Website",
            "scope": "zone",
            "sets": null
        },
        "state": "Paid",
        "trial": null,
        "zone": {
            "id": "0da42c8d2132a9ddaf714f9e7c920711",
            "internal_id": 140770369,
            "name": "terraform.cfapi.net"
        }
    },
    "success": true
}

Read Response:
(note: does not match Create response)

{
    "errors": [],
    "messages": [],
    "result": {
        "cancel_at_period_end": false,
        "client_secrets": null,
        "component_values": [
            {
                "default": 1,
                "name": "spectrum_bytes_transferred",
                "value": 1
            },
            {
                "name": "page_rules",
                "value": 125
            }
        ],
        "created_date": "2024-08-15T09:00:55Z",
        "currency": "USD",
        "frequency": "not-applicable",
        "handler": "stripe",
        "id": "ae519a85da7140dfb99192abd9722e84",
        "intent": "EMPLOYEE",
        "price": 0,
        "product": {
            "billing": "",
            "duration": 0,
            "name": "prod_cloudflare",
            "period": "",
            "public_name": "CloudFlare Services"
        },
        "rate_plan": {
            "currency": "USD",
            "externally_managed": false,
            "id": "enterprise",
            "is_contract": true,
            "public_name": "Enterprise",
            "scope": "zone",
            "sets": null
        },
        "state": "Paid",
        "trial": null,
        "zone": {
            "id": "0da42c8d2132a9ddaf714f9e7c920711",
            "name": "terraform.cfapi.net"
        }
    },
    "success": true
}

Fixes model/schema parity with `zone_subscription.frequency`. Struct tags can't
have spaces between tokens.
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.

9 participants