1. Packages
  2. AWS
  3. API Docs
  4. apigateway
  5. UsagePlanKey
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.apigateway.UsagePlanKey

Explore with Pulumi AI

Provides an API Gateway Usage Plan Key.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const test = new aws.apigateway.RestApi("test", {name: "MyDemoAPI"});
// ...
const myusageplan = new aws.apigateway.UsagePlan("myusageplan", {
    name: "my_usage_plan",
    apiStages: [{
        apiId: test.id,
        stage: foo.stageName,
    }],
});
const mykey = new aws.apigateway.ApiKey("mykey", {name: "my_key"});
const main = new aws.apigateway.UsagePlanKey("main", {
    keyId: mykey.id,
    keyType: "API_KEY",
    usagePlanId: myusageplan.id,
});
Copy
import pulumi
import pulumi_aws as aws

test = aws.apigateway.RestApi("test", name="MyDemoAPI")
# ...
myusageplan = aws.apigateway.UsagePlan("myusageplan",
    name="my_usage_plan",
    api_stages=[{
        "api_id": test.id,
        "stage": foo["stageName"],
    }])
mykey = aws.apigateway.ApiKey("mykey", name="my_key")
main = aws.apigateway.UsagePlanKey("main",
    key_id=mykey.id,
    key_type="API_KEY",
    usage_plan_id=myusageplan.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		test, err := apigateway.NewRestApi(ctx, "test", &apigateway.RestApiArgs{
			Name: pulumi.String("MyDemoAPI"),
		})
		if err != nil {
			return err
		}
		// ...
		myusageplan, err := apigateway.NewUsagePlan(ctx, "myusageplan", &apigateway.UsagePlanArgs{
			Name: pulumi.String("my_usage_plan"),
			ApiStages: apigateway.UsagePlanApiStageArray{
				&apigateway.UsagePlanApiStageArgs{
					ApiId: test.ID(),
					Stage: pulumi.Any(foo.StageName),
				},
			},
		})
		if err != nil {
			return err
		}
		mykey, err := apigateway.NewApiKey(ctx, "mykey", &apigateway.ApiKeyArgs{
			Name: pulumi.String("my_key"),
		})
		if err != nil {
			return err
		}
		_, err = apigateway.NewUsagePlanKey(ctx, "main", &apigateway.UsagePlanKeyArgs{
			KeyId:       mykey.ID(),
			KeyType:     pulumi.String("API_KEY"),
			UsagePlanId: myusageplan.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var test = new Aws.ApiGateway.RestApi("test", new()
    {
        Name = "MyDemoAPI",
    });

    // ...
    var myusageplan = new Aws.ApiGateway.UsagePlan("myusageplan", new()
    {
        Name = "my_usage_plan",
        ApiStages = new[]
        {
            new Aws.ApiGateway.Inputs.UsagePlanApiStageArgs
            {
                ApiId = test.Id,
                Stage = foo.StageName,
            },
        },
    });

    var mykey = new Aws.ApiGateway.ApiKey("mykey", new()
    {
        Name = "my_key",
    });

    var main = new Aws.ApiGateway.UsagePlanKey("main", new()
    {
        KeyId = mykey.Id,
        KeyType = "API_KEY",
        UsagePlanId = myusageplan.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.RestApi;
import com.pulumi.aws.apigateway.RestApiArgs;
import com.pulumi.aws.apigateway.UsagePlan;
import com.pulumi.aws.apigateway.UsagePlanArgs;
import com.pulumi.aws.apigateway.inputs.UsagePlanApiStageArgs;
import com.pulumi.aws.apigateway.ApiKey;
import com.pulumi.aws.apigateway.ApiKeyArgs;
import com.pulumi.aws.apigateway.UsagePlanKey;
import com.pulumi.aws.apigateway.UsagePlanKeyArgs;
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 test = new RestApi("test", RestApiArgs.builder()
            .name("MyDemoAPI")
            .build());

        // ...
        var myusageplan = new UsagePlan("myusageplan", UsagePlanArgs.builder()
            .name("my_usage_plan")
            .apiStages(UsagePlanApiStageArgs.builder()
                .apiId(test.id())
                .stage(foo.stageName())
                .build())
            .build());

        var mykey = new ApiKey("mykey", ApiKeyArgs.builder()
            .name("my_key")
            .build());

        var main = new UsagePlanKey("main", UsagePlanKeyArgs.builder()
            .keyId(mykey.id())
            .keyType("API_KEY")
            .usagePlanId(myusageplan.id())
            .build());

    }
}
Copy
resources:
  test:
    type: aws:apigateway:RestApi
    properties:
      name: MyDemoAPI
  # ...
  myusageplan:
    type: aws:apigateway:UsagePlan
    properties:
      name: my_usage_plan
      apiStages:
        - apiId: ${test.id}
          stage: ${foo.stageName}
  mykey:
    type: aws:apigateway:ApiKey
    properties:
      name: my_key
  main:
    type: aws:apigateway:UsagePlanKey
    properties:
      keyId: ${mykey.id}
      keyType: API_KEY
      usagePlanId: ${myusageplan.id}
Copy

Create UsagePlanKey Resource

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

Constructor syntax

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

@overload
def UsagePlanKey(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 key_id: Optional[str] = None,
                 key_type: Optional[str] = None,
                 usage_plan_id: Optional[str] = None)
func NewUsagePlanKey(ctx *Context, name string, args UsagePlanKeyArgs, opts ...ResourceOption) (*UsagePlanKey, error)
public UsagePlanKey(string name, UsagePlanKeyArgs args, CustomResourceOptions? opts = null)
public UsagePlanKey(String name, UsagePlanKeyArgs args)
public UsagePlanKey(String name, UsagePlanKeyArgs args, CustomResourceOptions options)
type: aws:apigateway:UsagePlanKey
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. UsagePlanKeyArgs
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. UsagePlanKeyArgs
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. UsagePlanKeyArgs
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. UsagePlanKeyArgs
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. UsagePlanKeyArgs
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 usagePlanKeyResource = new Aws.ApiGateway.UsagePlanKey("usagePlanKeyResource", new()
{
    KeyId = "string",
    KeyType = "string",
    UsagePlanId = "string",
});
Copy
example, err := apigateway.NewUsagePlanKey(ctx, "usagePlanKeyResource", &apigateway.UsagePlanKeyArgs{
	KeyId:       pulumi.String("string"),
	KeyType:     pulumi.String("string"),
	UsagePlanId: pulumi.String("string"),
})
Copy
var usagePlanKeyResource = new UsagePlanKey("usagePlanKeyResource", UsagePlanKeyArgs.builder()
    .keyId("string")
    .keyType("string")
    .usagePlanId("string")
    .build());
Copy
usage_plan_key_resource = aws.apigateway.UsagePlanKey("usagePlanKeyResource",
    key_id="string",
    key_type="string",
    usage_plan_id="string")
Copy
const usagePlanKeyResource = new aws.apigateway.UsagePlanKey("usagePlanKeyResource", {
    keyId: "string",
    keyType: "string",
    usagePlanId: "string",
});
Copy
type: aws:apigateway:UsagePlanKey
properties:
    keyId: string
    keyType: string
    usagePlanId: string
Copy

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

KeyId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of the API key resource.
KeyType
This property is required.
Changes to this property will trigger replacement.
string
Type of the API key resource. Currently, the valid key type is API_KEY.
UsagePlanId
This property is required.
Changes to this property will trigger replacement.
string
Id of the usage plan resource representing to associate the key to.
KeyId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of the API key resource.
KeyType
This property is required.
Changes to this property will trigger replacement.
string
Type of the API key resource. Currently, the valid key type is API_KEY.
UsagePlanId
This property is required.
Changes to this property will trigger replacement.
string
Id of the usage plan resource representing to associate the key to.
keyId
This property is required.
Changes to this property will trigger replacement.
String
Identifier of the API key resource.
keyType
This property is required.
Changes to this property will trigger replacement.
String
Type of the API key resource. Currently, the valid key type is API_KEY.
usagePlanId
This property is required.
Changes to this property will trigger replacement.
String
Id of the usage plan resource representing to associate the key to.
keyId
This property is required.
Changes to this property will trigger replacement.
string
Identifier of the API key resource.
keyType
This property is required.
Changes to this property will trigger replacement.
string
Type of the API key resource. Currently, the valid key type is API_KEY.
usagePlanId
This property is required.
Changes to this property will trigger replacement.
string
Id of the usage plan resource representing to associate the key to.
key_id
This property is required.
Changes to this property will trigger replacement.
str
Identifier of the API key resource.
key_type
This property is required.
Changes to this property will trigger replacement.
str
Type of the API key resource. Currently, the valid key type is API_KEY.
usage_plan_id
This property is required.
Changes to this property will trigger replacement.
str
Id of the usage plan resource representing to associate the key to.
keyId
This property is required.
Changes to this property will trigger replacement.
String
Identifier of the API key resource.
keyType
This property is required.
Changes to this property will trigger replacement.
String
Type of the API key resource. Currently, the valid key type is API_KEY.
usagePlanId
This property is required.
Changes to this property will trigger replacement.
String
Id of the usage plan resource representing to associate the key to.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Name string
Name of a usage plan key.
Value string
Value of a usage plan key.
Id string
The provider-assigned unique ID for this managed resource.
Name string
Name of a usage plan key.
Value string
Value of a usage plan key.
id String
The provider-assigned unique ID for this managed resource.
name String
Name of a usage plan key.
value String
Value of a usage plan key.
id string
The provider-assigned unique ID for this managed resource.
name string
Name of a usage plan key.
value string
Value of a usage plan key.
id str
The provider-assigned unique ID for this managed resource.
name str
Name of a usage plan key.
value str
Value of a usage plan key.
id String
The provider-assigned unique ID for this managed resource.
name String
Name of a usage plan key.
value String
Value of a usage plan key.

Look up Existing UsagePlanKey Resource

Get an existing UsagePlanKey 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?: UsagePlanKeyState, opts?: CustomResourceOptions): UsagePlanKey
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        key_id: Optional[str] = None,
        key_type: Optional[str] = None,
        name: Optional[str] = None,
        usage_plan_id: Optional[str] = None,
        value: Optional[str] = None) -> UsagePlanKey
func GetUsagePlanKey(ctx *Context, name string, id IDInput, state *UsagePlanKeyState, opts ...ResourceOption) (*UsagePlanKey, error)
public static UsagePlanKey Get(string name, Input<string> id, UsagePlanKeyState? state, CustomResourceOptions? opts = null)
public static UsagePlanKey get(String name, Output<String> id, UsagePlanKeyState state, CustomResourceOptions options)
resources:  _:    type: aws:apigateway:UsagePlanKey    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:
KeyId Changes to this property will trigger replacement. string
Identifier of the API key resource.
KeyType Changes to this property will trigger replacement. string
Type of the API key resource. Currently, the valid key type is API_KEY.
Name string
Name of a usage plan key.
UsagePlanId Changes to this property will trigger replacement. string
Id of the usage plan resource representing to associate the key to.
Value string
Value of a usage plan key.
KeyId Changes to this property will trigger replacement. string
Identifier of the API key resource.
KeyType Changes to this property will trigger replacement. string
Type of the API key resource. Currently, the valid key type is API_KEY.
Name string
Name of a usage plan key.
UsagePlanId Changes to this property will trigger replacement. string
Id of the usage plan resource representing to associate the key to.
Value string
Value of a usage plan key.
keyId Changes to this property will trigger replacement. String
Identifier of the API key resource.
keyType Changes to this property will trigger replacement. String
Type of the API key resource. Currently, the valid key type is API_KEY.
name String
Name of a usage plan key.
usagePlanId Changes to this property will trigger replacement. String
Id of the usage plan resource representing to associate the key to.
value String
Value of a usage plan key.
keyId Changes to this property will trigger replacement. string
Identifier of the API key resource.
keyType Changes to this property will trigger replacement. string
Type of the API key resource. Currently, the valid key type is API_KEY.
name string
Name of a usage plan key.
usagePlanId Changes to this property will trigger replacement. string
Id of the usage plan resource representing to associate the key to.
value string
Value of a usage plan key.
key_id Changes to this property will trigger replacement. str
Identifier of the API key resource.
key_type Changes to this property will trigger replacement. str
Type of the API key resource. Currently, the valid key type is API_KEY.
name str
Name of a usage plan key.
usage_plan_id Changes to this property will trigger replacement. str
Id of the usage plan resource representing to associate the key to.
value str
Value of a usage plan key.
keyId Changes to this property will trigger replacement. String
Identifier of the API key resource.
keyType Changes to this property will trigger replacement. String
Type of the API key resource. Currently, the valid key type is API_KEY.
name String
Name of a usage plan key.
usagePlanId Changes to this property will trigger replacement. String
Id of the usage plan resource representing to associate the key to.
value String
Value of a usage plan key.

Import

Using pulumi import, import AWS API Gateway Usage Plan Key using the USAGE-PLAN-ID/USAGE-PLAN-KEY-ID. For example:

$ pulumi import aws:apigateway/usagePlanKey:UsagePlanKey key 12345abcde/zzz
Copy

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.