Cloudflare v6.1.2 published on Monday, Apr 28, 2025 by Pulumi
Cloudflare Provider: Installation & Configuration
Installation
The cloudflare provider is available as a package in all Pulumi languages:
- JavaScript/TypeScript:
@pulumi/cloudflare - Python:
pulumi-cloudflare - Go:
github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare - .NET:
Pulumi.Cloudflare - Java:
com.pulumi/cloudflare
The Cloudflare provider is used to interact with resources supported by Cloudflare. The provider needs to be configured with the proper credentials before it can be used.
Example Usage
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: nodejs
config:
cloudflare:apiToken:
value: 'TODO: var.cloudflare_api_token'
import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";
// Create a record
const www = new cloudflare.Record("www", {});
// Create a page rule
const wwwPageRule = new cloudflare.PageRule("www", {});
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
cloudflare:apiToken:
value: 'TODO: var.cloudflare_api_token'
import pulumi
import pulumi_cloudflare as cloudflare
# Create a record
www = cloudflare.Record("www")
# Create a page rule
www_page_rule = cloudflare.PageRule("www")
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
cloudflare:apiToken:
value: 'TODO: var.cloudflare_api_token'
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;
return await Deployment.RunAsync(() =>
{
// Create a record
var www = new Cloudflare.Record("www");
// Create a page rule
var wwwPageRule = new Cloudflare.PageRule("www");
});
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
cloudflare:apiToken:
value: 'TODO: var.cloudflare_api_token'
package main
import (
"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create a record
_, err := cloudflare.NewRecord(ctx, "www", nil)
if err != nil {
return err
}
// Create a page rule
_, err = cloudflare.NewPageRule(ctx, "www", nil)
if err != nil {
return err
}
return nil
})
}
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
cloudflare:apiToken:
value: 'TODO: var.cloudflare_api_token'
resources:
# Create a record
www:
type: cloudflare:Record
# Create a page rule
wwwPageRule:
type: cloudflare:PageRule
name: www
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
cloudflare:apiToken:
value: 'TODO: var.cloudflare_api_token'
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudflare.Record;
import com.pulumi.cloudflare.PageRule;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// Create a record
var www = new Record("www");
// Create a page rule
var wwwPageRule = new PageRule("wwwPageRule");
}
}
Schema
Optional
apiBasePath(String) Configure the base path used by the API client. Alternatively, can be configured using theCLOUDFLARE_API_BASE_PATHenvironment variable.apiClientLogging(Boolean) Whether to print logs from the API client (using the default log library logger). Alternatively, can be configured using theCLOUDFLARE_API_CLIENT_LOGGINGenvironment variable.apiHostname(String) Configure the hostname used by the API client. Alternatively, can be configured using theCLOUDFLARE_API_HOSTNAMEenvironment variable.apiKey(String) The API key for operations. Alternatively, can be configured using theCLOUDFLARE_API_KEYenvironment variable. API keys are now considered legacy by Cloudflare, API tokens should be used instead. Must provide only one ofapiKey,apiToken,apiUserServiceKey.apiToken(String) The API Token for operations. Alternatively, can be configured using theCLOUDFLARE_API_TOKENenvironment variable. Must provide only one ofapiKey,apiToken,apiUserServiceKey.apiUserServiceKey(String) A special Cloudflare API key good for a restricted set of endpoints. Alternatively, can be configured using theCLOUDFLARE_API_USER_SERVICE_KEYenvironment variable. Must provide only one ofapiKey,apiToken,apiUserServiceKey.email(String) A registered Cloudflare email address. Alternatively, can be configured using theCLOUDFLARE_EMAILenvironment variable. Required when usingapiKey. Conflicts withapiToken.maxBackoff(Number) Maximum backoff period in seconds after failed API calls. Alternatively, can be configured using theCLOUDFLARE_MAX_BACKOFFenvironment variable.minBackoff(Number) Minimum backoff period in seconds after failed API calls. Alternatively, can be configured using theCLOUDFLARE_MIN_BACKOFFenvironment variable.retries(Number) Maximum number of retries to perform when an API request fails. Alternatively, can be configured using theCLOUDFLARE_RETRIESenvironment variable.rps(Number) RPS limit to apply when making calls to the API. Alternatively, can be configured using theCLOUDFLARE_RPSenvironment variable.userAgentOperatorSuffix(String) A value to append to the HTTP User Agent for all API calls. This value is not something most users need to modify however, if you are using a non-standard provider or operator configuration, this is recommended to assist in uniquely identifying your traffic. Setting this value will remove the Pulumi version from the HTTP User Agent string and may have unintended consequences. Alternatively, can be configured using theCLOUDFLARE_USER_AGENT_OPERATOR_SUFFIXenvironment variable.