Skip to content

chezmoi-sh/provider-cloudflare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Provider Cloudflare

provider-cloudflare is a Crossplane provider that is built using Upjet code generation tools and exposes XRM-conformant managed resources for the Cloudflare API.

Getting Started

Install the provider by using the following command after changing the image tag to the latest release:

up ctp provider install chezmoi-sh/provider-cloudflare:v0.1.0

Alternatively, you can use declarative installation:

cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-cloudflare
spec:
  package: chezmoi-sh/provider-cloudflare:v0.1.0
EOF

Notice that in this example Provider resource is referencing ControllerConfig with debug enabled.

You can see the API reference here.

Resources Reference and Status

Table below shows the resources that are currently supported by the provider, their relation with the Cloudflare Terraform provider and their status.

Note

Possible statuses are:

  • βœ…: Supported and automatically tested through E2E
  • πŸ›‚: Supported but manually tested
  • ⚠️: Supported but not tested
  • πŸ”²: Unsupported / Not implemented
  • 🚫: Deprecated
Status API Group Kind Terraform Equivalent
βœ… account.cloudflare.crossplane.io APIToken cloudflare_api_token
πŸ›‚ account.cloudflare.crossplane.io Account cloudflare_account
βœ… dns.cloudflare.crossplane.io DNSSEC cloudflare_zone_dnssec
βœ… dns.cloudflare.crossplane.io Record cloudflare_record
πŸ›‚ zone.cloudflare.crossplane.io Zone cloudflare_zone
πŸ”² cloudflare_access_rule
πŸ”² cloudflare_account_member
πŸ”² cloudflare_address_map
πŸ”² cloudflare_api_shield_operation_schema_validation_settings
πŸ”² cloudflare_api_shield_operation
πŸ”² cloudflare_api_shield_schema_validation_settings
πŸ”² cloudflare_api_shield_schema
πŸ”² cloudflare_api_shield
πŸ”² cloudflare_argo
πŸ”² cloudflare_authenticated_origin_pulls_certificate
πŸ”² cloudflare_authenticated_origin_pulls
πŸ”² cloudflare_bot_management
πŸ”² cloudflare_byo_ip_prefix
πŸ”² cloudflare_certificate_pack
πŸ”² cloudflare_cloud_connector_rules
πŸ”² cloudflare_custom_hostname_fallback_origin
πŸ”² cloudflare_custom_hostname
πŸ”² cloudflare_custom_pages
πŸ”² cloudflare_custom_ssl
πŸ”² cloudflare_d1_database
πŸ”² cloudflare_email_routing_address
πŸ”² cloudflare_email_routing_catch_all
πŸ”² cloudflare_email_routing_rule
πŸ”² cloudflare_email_routing_settings
πŸ”² cloudflare_healthcheck
πŸ”² cloudflare_hostname_tls_setting_ciphers
πŸ”² cloudflare_hostname_tls_setting
πŸ”² cloudflare_hyperdrive_config
πŸ”² cloudflare_infrastructure_access_target
πŸ”² cloudflare_keyless_certificate
πŸ”² cloudflare_list_item
πŸ”² cloudflare_list
πŸ”² cloudflare_load_balancer_monitor
πŸ”² cloudflare_load_balancer_pool
πŸ”² cloudflare_load_balancer
πŸ”² cloudflare_logpull_retention
πŸ”² cloudflare_logpush_job
πŸ”² cloudflare_logpush_ownership_challenge
πŸ”² cloudflare_magic_firewall_ruleset
πŸ”² cloudflare_magic_wan_gre_tunnel
πŸ”² cloudflare_magic_wan_ipsec_tunnel
πŸ”² cloudflare_magic_wan_static_route
πŸ”² cloudflare_managed_headers
πŸ”² cloudflare_mtls_certificate
πŸ”² cloudflare_notification_policy_webhooks
πŸ”² cloudflare_notification_policy
πŸ”² cloudflare_observatory_scheduled_test
πŸ”² cloudflare_origin_ca_certificate
πŸ”² cloudflare_page_rule
πŸ”² cloudflare_pages_domain
πŸ”² cloudflare_pages_project
πŸ”² cloudflare_queue
πŸ”² cloudflare_r2_bucket
πŸ”² cloudflare_regional_hostname
πŸ”² cloudflare_regional_tiered_cache
πŸ”² cloudflare_risk_behavior
πŸ”² cloudflare_ruleset
πŸ”² cloudflare_spectrum_application
πŸ”² cloudflare_tiered_cache
πŸ”² cloudflare_total_tls
πŸ”² cloudflare_turnstile_widget
πŸ”² cloudflare_url_normalization_settings
πŸ”² cloudflare_user_agent_blocking_rule
πŸ”² cloudflare_waiting_room_event
πŸ”² cloudflare_waiting_room_rules
πŸ”² cloudflare_waiting_room_settings
πŸ”² cloudflare_waiting_room
πŸ”² cloudflare_web3_hostname
πŸ”² cloudflare_web_analytics_rule
πŸ”² cloudflare_web_analytics_site
πŸ”² cloudflare_workers_cron_trigger
πŸ”² cloudflare_workers_domain
πŸ”² cloudflare_workers_for_platforms_dispatch_namespace
πŸ”² cloudflare_workers_for_platforms_namespace
πŸ”² cloudflare_workers_kv_namespace
πŸ”² cloudflare_workers_kv
πŸ”² cloudflare_workers_route
πŸ”² cloudflare_workers_script
πŸ”² cloudflare_workers_secret
πŸ”² cloudflare_zero_trust_access_application
πŸ”² cloudflare_zero_trust_access_custom_page
πŸ”² cloudflare_zero_trust_access_group
πŸ”² cloudflare_zero_trust_access_identity_provider
πŸ”² cloudflare_zero_trust_access_mtls_certificate
πŸ”² cloudflare_zero_trust_access_mtls_hostname_settings
πŸ”² cloudflare_zero_trust_access_organization
πŸ”² cloudflare_zero_trust_access_policy
πŸ”² cloudflare_zero_trust_access_service_token
πŸ”² cloudflare_zero_trust_access_short_lived_certificate
πŸ”² cloudflare_zero_trust_access_tag
πŸ”² cloudflare_zero_trust_device_certificates
πŸ”² cloudflare_zero_trust_device_managed_networks
πŸ”² cloudflare_zero_trust_device_posture_integration
πŸ”² cloudflare_zero_trust_device_posture_rule
πŸ”² cloudflare_zero_trust_device_profiles
πŸ”² cloudflare_zero_trust_dex_test
πŸ”² cloudflare_zero_trust_dlp_profile
πŸ”² cloudflare_zero_trust_dns_location
πŸ”² cloudflare_zero_trust_gateway_certificate
πŸ”² cloudflare_zero_trust_gateway_policy
πŸ”² cloudflare_zero_trust_gateway_proxy_endpoint
πŸ”² cloudflare_zero_trust_gateway_settings
πŸ”² cloudflare_zero_trust_key_access_key_configuration
πŸ”² cloudflare_zero_trust_list
πŸ”² cloudflare_zero_trust_local_fallback_domain
πŸ”² cloudflare_zero_trust_risk_behavior
πŸ”² cloudflare_zero_trust_risk_score_integration
πŸ”² cloudflare_zero_trust_split_tunnel
πŸ”² cloudflare_zero_trust_tunnel_cloudflared_config
πŸ”² cloudflare_zero_trust_tunnel_cloudflared
πŸ”² cloudflare_zero_trust_tunnel_route
πŸ”² cloudflare_zero_trust_tunnel_virtual_network
πŸ”² cloudflare_zone_cache_reserve
πŸ”² cloudflare_zone_cache_variants
πŸ”² cloudflare_zone_hold
πŸ”² cloudflare_zone_lockdown
πŸ”² cloudflare_zone_settings_override
🚫 cloudflare_access_application
🚫 cloudflare_access_ca_certificate
🚫 cloudflare_access_custom_page
🚫 cloudflare_access_group
🚫 cloudflare_access_identity_provider
🚫 cloudflare_access_keys_configuration
🚫 cloudflare_access_mutual_tls_certificate
🚫 cloudflare_access_mutual_tls_hostname_settings
🚫 cloudflare_access_organization
🚫 cloudflare_access_policy
🚫 cloudflare_access_service_token
🚫 cloudflare_access_tag
🚫 cloudflare_device_dex_test
🚫 cloudflare_device_managed_networks
🚫 cloudflare_device_policy_certificates
🚫 cloudflare_device_posture_integration
🚫 cloudflare_device_posture_rule
🚫 cloudflare_device_settings_policy
🚫 cloudflare_dlp_profile
🚫 cloudflare_fallback_domain
🚫 cloudflare_filter
🚫 cloudflare_firewall_rule
🚫 cloudflare_gre_tunnel
🚫 cloudflare_ipsec_tunnel
🚫 cloudflare_rate_limit
🚫 cloudflare_split_tunnel
🚫 cloudflare_static_route
🚫 cloudflare_teams_account
🚫 cloudflare_teams_list
🚫 cloudflare_teams_location
🚫 cloudflare_teams_proxy_endpoint
🚫 cloudflare_teams_rule
🚫 cloudflare_tunnel_config
🚫 cloudflare_tunnel_route
🚫 cloudflare_tunnel_virtual_network
🚫 cloudflare_tunnel
🚫 cloudflare_worker_cron_trigger
🚫 cloudflare_worker_domain
🚫 cloudflare_worker_route
🚫 cloudflare_worker_script
🚫 cloudflare_worker_secret

Contributing

In order to provide a better experience for the developers, this provider uses a Nix Flake to manage the development environment. If you are familiar with direnv and you have Nix installed, all you need is to allow the .envrc file to be loaded by direnv and everything will be set up for you.

Note

For other users, I will create a Devcontainer for this project in the future.

Here is a step-by-step guide to get you started:

# Clone the repository and go to the project directory
git clone https://github.com/chezmoi-sh/provider-cloudflare
cd provider-cloudflare

# Allow the .envrc file to be loaded (will be slow the first time)
direnv allow

# Install the dependencies
make submodules

Now, everything is set up and you can start developing.

How add a new resource

Like other Crossplane providers, this provider uses the Upjet code generation tools to generate the code for the resources, based on the Terraform provider.
However, because the Terraform provider for Cloudflare is a massive project (150+ resources), I decided to use an intermediate step to generate the code for the resources.

This intermediate step is a Go program that takes an inventory of resources and generates the Go code for all resources.

Important

As this program is not perfect, if a resource needs some customization, you will need to update the program to add the necessary logic.

So, here is a step-by-step guide to add a new resource:

  1. Add the resource to the inventory file, inside the supported section.
    NOTE: Everything we need to know about the structure of the resource is in the inventory file it-self, at the beginning of the file.
  2. Run make provider-cloudflare.generate to generate the Go files containing the resource configuration.
  3. Run make generate to generate the provider code.
  4. Add examples and tests for the new resource, inside the examples directory.
  5. Run make e2e to test the new resource.
  6. Update the Resources Reference and Status table in the README file.
  7. Create a pull request.

Important

This repository uses the Gitmoji convention for commit messages and uses Trunk to format and lint the code.

Note

I've tried to automate as much as possible without leaving the dev experience provided by Upjet and its documentation; apart from the Go code generation part, everything else follows the official documentation.

Roadmap

  • Publish the provider to the Crossplane marketplace through the Github Actions workflow
  • Make it publicly available in the Crossplane marketplace
  • Add Devcontainer for people who don't use Nix
  • Configure Renovate to improve how it updates the dependencies (grouping with logical changes, updating dependencies that are cross-referenced by the CI and the Makefile)
  • Add some checks to the CI to ensure that all changes follow the guidelines

Report a Bug

For filing bugs, suggesting improvements, or requesting new features, please open an issue.

Why another Cloudflare provider?

This provider is mainly inspired by the one created by cdloh, which is much more complete and feature-rich than this one (for now at least).
The main reason for creating this provider was to learn how to create a Crossplane provider and to have a provider that is more aligned with the way resources are displayed inside the Cloudflare dashboard. For example, the DNSSEC resource should be a DNS resource and not a zone resource.
The other reason is that I wanted to have a provider that is easier to maintain through code generation, which will simplify the migration from v4 to v5 of Cloudflare's official terraform provider.

License

This provider is released under the Apache 2.0 license. See the LICENSE file for more details.