shiichan

Cloudflare's Terraform v5 provider clears out its backlog of bugs in v5.4.0!

Hey everyone, it's me, Shii-chan! Today's news is about Cloudflare's Terraform provider. It might sound like a dry topic, but if you're running Cloudflare through IaC, this is a genuinely welcome update.

Cloudflare Changelog developers.cloudflare.com

What was announced?

On the Cloudflare Changelog, the Terraform v5 provider's v5.4.0 release was announced. It's a bug-fix release that bundles up fixes for issues that had been piling up since the v5 provider launched earlier this year.

The story so far

Unlike earlier hand-written providers, the v5 provider is automatically generated from the OpenAPI schemas behind Cloudflare's REST APIs. After launch, though, an unexpectedly high number of issues came in from customers, impacting about 15% of all resources. Cloudflare pulled in teams from across the company to work through the backlog.

What changes

v5.4.0 bundles fixes for the reported issues. Here are the main changes.

  • Removes the worker_platforms_script_secret resource (a migration guide is provided for both Workers and Workers for Platforms)
  • Removes duplicated fields in cloudflare_cloud_connector_rules
  • Fixes cloudflare_workers_route id issues (GitHub issues #5134 and #5501)
  • Fixes cloudflare_workers_kv state refresh issues
  • Fixes defaults that made cloudflare_workers_script fail when using Assets
  • Fixes the Workers Logpush setting in cloudflare_workers_script mistakenly being read-only
  • Fixes cloudflare_pages_project breaking when using source

If you've been hitting these bugs on v5 already, upgrading the provider should clear up most of them.

Dive Deep

The two biggest chunks of fixes here are a bug where refreshing resources with unsupported response types would fail, and a bug where nested properties without computed values couldn't be configured.

The response-type refresh bug affected these resources.

  • cloudflare_certificate_pack
  • cloudflare_registrar_domain
  • cloudflare_stream_download
  • cloudflare_stream_webhook
  • cloudflare_user
  • cloudflare_workers_kv
  • cloudflare_workers_script

And the nested-property configurability bug spanned a full 33 resources.

  • cloudflare_account
  • cloudflare_account_dns_settings
  • cloudflare_account_token
  • cloudflare_api_token
  • cloudflare_cloud_connector_rules
  • cloudflare_custom_ssl
  • cloudflare_d1_database
  • cloudflare_dns_record
  • email_security_trusted_domains
  • cloudflare_hyperdrive_config
  • cloudflare_keyless_certificate
  • cloudflare_list_item
  • cloudflare_load_balancer
  • cloudflare_logpush_dataset_job
  • cloudflare_magic_network_monitoring_configuration
  • cloudflare_magic_transit_site
  • cloudflare_magic_transit_site_lan
  • cloudflare_magic_transit_site_wan
  • cloudflare_magic_wan_static_route
  • cloudflare_notification_policy
  • cloudflare_pages_project
  • cloudflare_queue
  • cloudflare_queue_consumer
  • cloudflare_r2_bucket_cors
  • cloudflare_r2_bucket_event_notification
  • cloudflare_r2_bucket_lifecycle
  • cloudflare_r2_bucket_lock
  • cloudflare_r2_bucket_sippy
  • cloudflare_ruleset
  • cloudflare_snippet_rules
  • cloudflare_snippets
  • cloudflare_spectrum_application
  • cloudflare_workers_deployment
  • cloudflare_zero_trust_access_application
  • cloudflare_zero_trust_access_group

That list spans DNS records, load balancers, R2 buckets, and Zero Trust resources, so it's a genuinely wide-reaching set of fixes. The full changelog is available in the v5.4.0 release notes on GitHub.

For anyone considering a move from v4 to v5, there's a migration guide along with automated migration scripts built on Grit. Those scripts don't support setups that use Terraform modules, though, so module users will need to migrate manually. Cloudflare also recommends running terraform plan to review the diff before applying.

Wrap-up

  • Cloudflare's Terraform v5 provider ships v5.4.0, bundling fixes for previously reported bugs
  • Removes the worker_platforms_script_secret resource, and fixes cloudflare_workers_route id issues and cloudflare_workers_kv state refresh problems, among others
  • Fixes a refresh bug affecting 7 resources and a nested-property configurability bug affecting 33 resources
  • Provides a migration guide and Grit-based automated scripts for v4-to-v5 migrations (manual migration still needed if you use Terraform modules)

If you're already running Cloudflare through Terraform, upgrading to v5.4.0 is worth doing!