1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. ApiToken
Cloudflare v5.49.1 published on Tuesday, Feb 18, 2025 by Pulumi

cloudflare.ApiToken

Explore with Pulumi AI

Provides a resource which manages Cloudflare API tokens.

Read more about permission groups and their applicable scopes in the developer documentation.

Create ApiToken Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ApiToken(name: string, args: ApiTokenArgs, opts?: CustomResourceOptions);
@overload
def ApiToken(resource_name: str,
             args: ApiTokenArgs,
             opts: Optional[ResourceOptions] = None)

@overload
def ApiToken(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             name: Optional[str] = None,
             policies: Optional[Sequence[ApiTokenPolicyArgs]] = None,
             condition: Optional[ApiTokenConditionArgs] = None,
             expires_on: Optional[str] = None,
             not_before: Optional[str] = None)
func NewApiToken(ctx *Context, name string, args ApiTokenArgs, opts ...ResourceOption) (*ApiToken, error)
public ApiToken(string name, ApiTokenArgs args, CustomResourceOptions? opts = null)
public ApiToken(String name, ApiTokenArgs args)
public ApiToken(String name, ApiTokenArgs args, CustomResourceOptions options)
type: cloudflare:ApiToken
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ApiTokenArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ApiTokenArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ApiTokenArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ApiTokenArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ApiTokenArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var apiTokenResource = new Cloudflare.ApiToken("apiTokenResource", new()
{
    Name = "string",
    Policies = new[]
    {
        new Cloudflare.Inputs.ApiTokenPolicyArgs
        {
            PermissionGroups = new[]
            {
                "string",
            },
            Resources = 
            {
                { "string", "string" },
            },
            Effect = "string",
        },
    },
    Condition = new Cloudflare.Inputs.ApiTokenConditionArgs
    {
        RequestIp = new Cloudflare.Inputs.ApiTokenConditionRequestIpArgs
        {
            Ins = new[]
            {
                "string",
            },
            NotIns = new[]
            {
                "string",
            },
        },
    },
    ExpiresOn = "string",
    NotBefore = "string",
});
Copy
example, err := cloudflare.NewApiToken(ctx, "apiTokenResource", &cloudflare.ApiTokenArgs{
	Name: pulumi.String("string"),
	Policies: cloudflare.ApiTokenPolicyArray{
		&cloudflare.ApiTokenPolicyArgs{
			PermissionGroups: pulumi.StringArray{
				pulumi.String("string"),
			},
			Resources: pulumi.StringMap{
				"string": pulumi.String("string"),
			},
			Effect: pulumi.String("string"),
		},
	},
	Condition: &cloudflare.ApiTokenConditionArgs{
		RequestIp: &cloudflare.ApiTokenConditionRequestIpArgs{
			Ins: pulumi.StringArray{
				pulumi.String("string"),
			},
			NotIns: pulumi.StringArray{
				pulumi.String("string"),
			},
		},
	},
	ExpiresOn: pulumi.String("string"),
	NotBefore: pulumi.String("string"),
})
Copy
var apiTokenResource = new ApiToken("apiTokenResource", ApiTokenArgs.builder()
    .name("string")
    .policies(ApiTokenPolicyArgs.builder()
        .permissionGroups("string")
        .resources(Map.of("string", "string"))
        .effect("string")
        .build())
    .condition(ApiTokenConditionArgs.builder()
        .requestIp(ApiTokenConditionRequestIpArgs.builder()
            .ins("string")
            .notIns("string")
            .build())
        .build())
    .expiresOn("string")
    .notBefore("string")
    .build());
Copy
api_token_resource = cloudflare.ApiToken("apiTokenResource",
    name="string",
    policies=[{
        "permission_groups": ["string"],
        "resources": {
            "string": "string",
        },
        "effect": "string",
    }],
    condition={
        "request_ip": {
            "ins": ["string"],
            "not_ins": ["string"],
        },
    },
    expires_on="string",
    not_before="string")
Copy
const apiTokenResource = new cloudflare.ApiToken("apiTokenResource", {
    name: "string",
    policies: [{
        permissionGroups: ["string"],
        resources: {
            string: "string",
        },
        effect: "string",
    }],
    condition: {
        requestIp: {
            ins: ["string"],
            notIns: ["string"],
        },
    },
    expiresOn: "string",
    notBefore: "string",
});
Copy
type: cloudflare:ApiToken
properties:
    condition:
        requestIp:
            ins:
                - string
            notIns:
                - string
    expiresOn: string
    name: string
    notBefore: string
    policies:
        - effect: string
          permissionGroups:
            - string
          resources:
            string: string
Copy

ApiToken Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ApiToken resource accepts the following input properties:

Name This property is required. string
Name of the API Token.
Policies This property is required. List<ApiTokenPolicy>
Permissions policy. Multiple policy blocks can be defined.
Condition ApiTokenCondition
Conditions under which the token should be considered valid.
ExpiresOn string
The expiration time on or after which the token MUST NOT be accepted for processing.
NotBefore string
The time before which the token MUST NOT be accepted for processing.
Name This property is required. string
Name of the API Token.
Policies This property is required. []ApiTokenPolicyArgs
Permissions policy. Multiple policy blocks can be defined.
Condition ApiTokenConditionArgs
Conditions under which the token should be considered valid.
ExpiresOn string
The expiration time on or after which the token MUST NOT be accepted for processing.
NotBefore string
The time before which the token MUST NOT be accepted for processing.
name This property is required. String
Name of the API Token.
policies This property is required. List<ApiTokenPolicy>
Permissions policy. Multiple policy blocks can be defined.
condition ApiTokenCondition
Conditions under which the token should be considered valid.
expiresOn String
The expiration time on or after which the token MUST NOT be accepted for processing.
notBefore String
The time before which the token MUST NOT be accepted for processing.
name This property is required. string
Name of the API Token.
policies This property is required. ApiTokenPolicy[]
Permissions policy. Multiple policy blocks can be defined.
condition ApiTokenCondition
Conditions under which the token should be considered valid.
expiresOn string
The expiration time on or after which the token MUST NOT be accepted for processing.
notBefore string
The time before which the token MUST NOT be accepted for processing.
name This property is required. str
Name of the API Token.
policies This property is required. Sequence[ApiTokenPolicyArgs]
Permissions policy. Multiple policy blocks can be defined.
condition ApiTokenConditionArgs
Conditions under which the token should be considered valid.
expires_on str
The expiration time on or after which the token MUST NOT be accepted for processing.
not_before str
The time before which the token MUST NOT be accepted for processing.
name This property is required. String
Name of the API Token.
policies This property is required. List<Property Map>
Permissions policy. Multiple policy blocks can be defined.
condition Property Map
Conditions under which the token should be considered valid.
expiresOn String
The expiration time on or after which the token MUST NOT be accepted for processing.
notBefore String
The time before which the token MUST NOT be accepted for processing.

Outputs

All input properties are implicitly available as output properties. Additionally, the ApiToken resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
IssuedOn string
Timestamp of when the token was issued.
ModifiedOn string
Timestamp of when the token was last modified.
Status string
Value string
The value of the API Token.
Id string
The provider-assigned unique ID for this managed resource.
IssuedOn string
Timestamp of when the token was issued.
ModifiedOn string
Timestamp of when the token was last modified.
Status string
Value string
The value of the API Token.
id String
The provider-assigned unique ID for this managed resource.
issuedOn String
Timestamp of when the token was issued.
modifiedOn String
Timestamp of when the token was last modified.
status String
value String
The value of the API Token.
id string
The provider-assigned unique ID for this managed resource.
issuedOn string
Timestamp of when the token was issued.
modifiedOn string
Timestamp of when the token was last modified.
status string
value string
The value of the API Token.
id str
The provider-assigned unique ID for this managed resource.
issued_on str
Timestamp of when the token was issued.
modified_on str
Timestamp of when the token was last modified.
status str
value str
The value of the API Token.
id String
The provider-assigned unique ID for this managed resource.
issuedOn String
Timestamp of when the token was issued.
modifiedOn String
Timestamp of when the token was last modified.
status String
value String
The value of the API Token.

Look up Existing ApiToken Resource

Get an existing ApiToken resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ApiTokenState, opts?: CustomResourceOptions): ApiToken
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        condition: Optional[ApiTokenConditionArgs] = None,
        expires_on: Optional[str] = None,
        issued_on: Optional[str] = None,
        modified_on: Optional[str] = None,
        name: Optional[str] = None,
        not_before: Optional[str] = None,
        policies: Optional[Sequence[ApiTokenPolicyArgs]] = None,
        status: Optional[str] = None,
        value: Optional[str] = None) -> ApiToken
func GetApiToken(ctx *Context, name string, id IDInput, state *ApiTokenState, opts ...ResourceOption) (*ApiToken, error)
public static ApiToken Get(string name, Input<string> id, ApiTokenState? state, CustomResourceOptions? opts = null)
public static ApiToken get(String name, Output<String> id, ApiTokenState state, CustomResourceOptions options)
resources:  _:    type: cloudflare:ApiToken    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Condition ApiTokenCondition
Conditions under which the token should be considered valid.
ExpiresOn string
The expiration time on or after which the token MUST NOT be accepted for processing.
IssuedOn string
Timestamp of when the token was issued.
ModifiedOn string
Timestamp of when the token was last modified.
Name string
Name of the API Token.
NotBefore string
The time before which the token MUST NOT be accepted for processing.
Policies List<ApiTokenPolicy>
Permissions policy. Multiple policy blocks can be defined.
Status string
Value string
The value of the API Token.
Condition ApiTokenConditionArgs
Conditions under which the token should be considered valid.
ExpiresOn string
The expiration time on or after which the token MUST NOT be accepted for processing.
IssuedOn string
Timestamp of when the token was issued.
ModifiedOn string
Timestamp of when the token was last modified.
Name string
Name of the API Token.
NotBefore string
The time before which the token MUST NOT be accepted for processing.
Policies []ApiTokenPolicyArgs
Permissions policy. Multiple policy blocks can be defined.
Status string
Value string
The value of the API Token.
condition ApiTokenCondition
Conditions under which the token should be considered valid.
expiresOn String
The expiration time on or after which the token MUST NOT be accepted for processing.
issuedOn String
Timestamp of when the token was issued.
modifiedOn String
Timestamp of when the token was last modified.
name String
Name of the API Token.
notBefore String
The time before which the token MUST NOT be accepted for processing.
policies List<ApiTokenPolicy>
Permissions policy. Multiple policy blocks can be defined.
status String
value String
The value of the API Token.
condition ApiTokenCondition
Conditions under which the token should be considered valid.
expiresOn string
The expiration time on or after which the token MUST NOT be accepted for processing.
issuedOn string
Timestamp of when the token was issued.
modifiedOn string
Timestamp of when the token was last modified.
name string
Name of the API Token.
notBefore string
The time before which the token MUST NOT be accepted for processing.
policies ApiTokenPolicy[]
Permissions policy. Multiple policy blocks can be defined.
status string
value string
The value of the API Token.
condition ApiTokenConditionArgs
Conditions under which the token should be considered valid.
expires_on str
The expiration time on or after which the token MUST NOT be accepted for processing.
issued_on str
Timestamp of when the token was issued.
modified_on str
Timestamp of when the token was last modified.
name str
Name of the API Token.
not_before str
The time before which the token MUST NOT be accepted for processing.
policies Sequence[ApiTokenPolicyArgs]
Permissions policy. Multiple policy blocks can be defined.
status str
value str
The value of the API Token.
condition Property Map
Conditions under which the token should be considered valid.
expiresOn String
The expiration time on or after which the token MUST NOT be accepted for processing.
issuedOn String
Timestamp of when the token was issued.
modifiedOn String
Timestamp of when the token was last modified.
name String
Name of the API Token.
notBefore String
The time before which the token MUST NOT be accepted for processing.
policies List<Property Map>
Permissions policy. Multiple policy blocks can be defined.
status String
value String
The value of the API Token.

Supporting Types

ApiTokenCondition
, ApiTokenConditionArgs

RequestIp ApiTokenConditionRequestIp
Request IP related conditions.
RequestIp ApiTokenConditionRequestIp
Request IP related conditions.
requestIp ApiTokenConditionRequestIp
Request IP related conditions.
requestIp ApiTokenConditionRequestIp
Request IP related conditions.
request_ip ApiTokenConditionRequestIp
Request IP related conditions.
requestIp Property Map
Request IP related conditions.

ApiTokenConditionRequestIp
, ApiTokenConditionRequestIpArgs

Ins List<string>
List of IP addresses or CIDR notation where the token may be used from. If not specified, the token will be valid for all IP addresses.
NotIns List<string>
List of IP addresses or CIDR notation where the token should not be used from.
Ins []string
List of IP addresses or CIDR notation where the token may be used from. If not specified, the token will be valid for all IP addresses.
NotIns []string
List of IP addresses or CIDR notation where the token should not be used from.
ins List<String>
List of IP addresses or CIDR notation where the token may be used from. If not specified, the token will be valid for all IP addresses.
notIns List<String>
List of IP addresses or CIDR notation where the token should not be used from.
ins string[]
List of IP addresses or CIDR notation where the token may be used from. If not specified, the token will be valid for all IP addresses.
notIns string[]
List of IP addresses or CIDR notation where the token should not be used from.
ins Sequence[str]
List of IP addresses or CIDR notation where the token may be used from. If not specified, the token will be valid for all IP addresses.
not_ins Sequence[str]
List of IP addresses or CIDR notation where the token should not be used from.
ins List<String>
List of IP addresses or CIDR notation where the token may be used from. If not specified, the token will be valid for all IP addresses.
notIns List<String>
List of IP addresses or CIDR notation where the token should not be used from.

ApiTokenPolicy
, ApiTokenPolicyArgs

PermissionGroups This property is required. List<string>
List of permissions groups IDs. See documentation for more information.
Resources This property is required. Dictionary<string, string>
Describes what operations against which resources are allowed or denied.
Effect string
Effect of the policy. Available values: allow, deny. Defaults to allow.
PermissionGroups This property is required. []string
List of permissions groups IDs. See documentation for more information.
Resources This property is required. map[string]string
Describes what operations against which resources are allowed or denied.
Effect string
Effect of the policy. Available values: allow, deny. Defaults to allow.
permissionGroups This property is required. List<String>
List of permissions groups IDs. See documentation for more information.
resources This property is required. Map<String,String>
Describes what operations against which resources are allowed or denied.
effect String
Effect of the policy. Available values: allow, deny. Defaults to allow.
permissionGroups This property is required. string[]
List of permissions groups IDs. See documentation for more information.
resources This property is required. {[key: string]: string}
Describes what operations against which resources are allowed or denied.
effect string
Effect of the policy. Available values: allow, deny. Defaults to allow.
permission_groups This property is required. Sequence[str]
List of permissions groups IDs. See documentation for more information.
resources This property is required. Mapping[str, str]
Describes what operations against which resources are allowed or denied.
effect str
Effect of the policy. Available values: allow, deny. Defaults to allow.
permissionGroups This property is required. List<String>
List of permissions groups IDs. See documentation for more information.
resources This property is required. Map<String>
Describes what operations against which resources are allowed or denied.
effect String
Effect of the policy. Available values: allow, deny. Defaults to allow.

Package Details

Repository
Cloudflare pulumi/pulumi-cloudflare
License
Apache-2.0
Notes
This Pulumi package is based on the cloudflare Terraform Provider.