1. Packages
  2. AWS
  3. API Docs
  4. wafv2
  5. ApiKey
AWS v6.82.2 published on Thursday, Jun 12, 2025 by Pulumi

aws.wafv2.ApiKey

Explore with Pulumi AI

aws logo
AWS v6.82.2 published on Thursday, Jun 12, 2025 by Pulumi

    Provides an AWS WAFv2 API Key resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const example = new aws.wafv2.ApiKey("example", {
        scope: "REGIONAL",
        tokenDomains: ["example.com"],
    });
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.wafv2.ApiKey("example",
        scope="REGIONAL",
        token_domains=["example.com"])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafv2"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := wafv2.NewApiKey(ctx, "example", &wafv2.ApiKeyArgs{
    			Scope: pulumi.String("REGIONAL"),
    			TokenDomains: pulumi.StringArray{
    				pulumi.String("example.com"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.WafV2.ApiKey("example", new()
        {
            Scope = "REGIONAL",
            TokenDomains = new[]
            {
                "example.com",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.wafv2.ApiKey;
    import com.pulumi.aws.wafv2.ApiKeyArgs;
    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) {
            var example = new ApiKey("example", ApiKeyArgs.builder()
                .scope("REGIONAL")
                .tokenDomains("example.com")
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:wafv2:ApiKey
        properties:
          scope: REGIONAL
          tokenDomains:
            - example.com
    

    Create ApiKey Resource

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

    Constructor syntax

    new ApiKey(name: string, args: ApiKeyArgs, opts?: CustomResourceOptions);
    @overload
    def ApiKey(resource_name: str,
               args: ApiKeyArgs,
               opts: Optional[ResourceOptions] = None)
    
    @overload
    def ApiKey(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               scope: Optional[str] = None,
               token_domains: Optional[Sequence[str]] = None)
    func NewApiKey(ctx *Context, name string, args ApiKeyArgs, opts ...ResourceOption) (*ApiKey, error)
    public ApiKey(string name, ApiKeyArgs args, CustomResourceOptions? opts = null)
    public ApiKey(String name, ApiKeyArgs args)
    public ApiKey(String name, ApiKeyArgs args, CustomResourceOptions options)
    
    type: aws:wafv2:ApiKey
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args ApiKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ApiKeyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ApiKeyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ApiKeyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ApiKeyArgs
    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 exampleapiKeyResourceResourceFromWafv2apiKey = new Aws.WafV2.ApiKey("exampleapiKeyResourceResourceFromWafv2apiKey", new()
    {
        Scope = "string",
        TokenDomains = new[]
        {
            "string",
        },
    });
    
    example, err := wafv2.NewApiKey(ctx, "exampleapiKeyResourceResourceFromWafv2apiKey", &wafv2.ApiKeyArgs{
    	Scope: pulumi.String("string"),
    	TokenDomains: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    })
    
    var exampleapiKeyResourceResourceFromWafv2apiKey = new com.pulumi.aws.wafv2.ApiKey("exampleapiKeyResourceResourceFromWafv2apiKey", com.pulumi.aws.wafv2.ApiKeyArgs.builder()
        .scope("string")
        .tokenDomains("string")
        .build());
    
    exampleapi_key_resource_resource_from_wafv2api_key = aws.wafv2.ApiKey("exampleapiKeyResourceResourceFromWafv2apiKey",
        scope="string",
        token_domains=["string"])
    
    const exampleapiKeyResourceResourceFromWafv2apiKey = new aws.wafv2.ApiKey("exampleapiKeyResourceResourceFromWafv2apiKey", {
        scope: "string",
        tokenDomains: ["string"],
    });
    
    type: aws:wafv2:ApiKey
    properties:
        scope: string
        tokenDomains:
            - string
    

    ApiKey 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 ApiKey resource accepts the following input properties:

    Scope string
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    TokenDomains List<string>
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    Scope string
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    TokenDomains []string
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    scope String
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    tokenDomains List<String>
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    scope string
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    tokenDomains string[]
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    scope str
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    token_domains Sequence[str]
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    scope String
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    tokenDomains List<String>
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Key string
    The generated API key. This value is sensitive.
    ApiKey string
    The generated API key. This value is sensitive.
    Id string
    The provider-assigned unique ID for this managed resource.
    apiKey String
    The generated API key. This value is sensitive.
    id String
    The provider-assigned unique ID for this managed resource.
    apiKey string
    The generated API key. This value is sensitive.
    id string
    The provider-assigned unique ID for this managed resource.
    api_key str
    The generated API key. This value is sensitive.
    id str
    The provider-assigned unique ID for this managed resource.
    apiKey String
    The generated API key. This value is sensitive.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing ApiKey Resource

    Get an existing ApiKey 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?: ApiKeyState, opts?: CustomResourceOptions): ApiKey
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            api_key: Optional[str] = None,
            scope: Optional[str] = None,
            token_domains: Optional[Sequence[str]] = None) -> ApiKey
    func GetApiKey(ctx *Context, name string, id IDInput, state *ApiKeyState, opts ...ResourceOption) (*ApiKey, error)
    public static ApiKey Get(string name, Input<string> id, ApiKeyState? state, CustomResourceOptions? opts = null)
    public static ApiKey get(String name, Output<String> id, ApiKeyState state, CustomResourceOptions options)
    resources:  _:    type: aws:wafv2:ApiKey    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    Key string
    The generated API key. This value is sensitive.
    Scope string
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    TokenDomains List<string>
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    ApiKey string
    The generated API key. This value is sensitive.
    Scope string
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    TokenDomains []string
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    apiKey String
    The generated API key. This value is sensitive.
    scope String
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    tokenDomains List<String>
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    apiKey string
    The generated API key. This value is sensitive.
    scope string
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    tokenDomains string[]
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    api_key str
    The generated API key. This value is sensitive.
    scope str
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    token_domains Sequence[str]
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.
    apiKey String
    The generated API key. This value is sensitive.
    scope String
    Specifies whether this is for an AWS CloudFront distribution or for a regional application. Valid values are CLOUDFRONT or REGIONAL. Changing this forces a new resource to be created. NOTE: WAFv2 API Keys deployed for CLOUDFRONT must be created within the us-east-1 region.
    tokenDomains List<String>
    The domains that you want to be able to use the API key with, for example example.com. You can specify up to 5 domains. Changing this forces a new resource to be created.

    Import

    Using pulumi import, import WAFv2 API Key using api_key,scope. For example:

    $ pulumi import aws:wafv2/apiKey:ApiKey example a1b2c3d4-5678-90ab-cdef-EXAMPLE11111,REGIONAL
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo
    AWS v6.82.2 published on Thursday, Jun 12, 2025 by Pulumi