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,
});
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)
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
	})
}
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,
    });
});
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());
    }
}
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}
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 string
- The unique name of the resource.
- args UsagePlanKeyArgs
- 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 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 string
- The unique name of the resource.
- args UsagePlanKeyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UsagePlanKeyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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",
});
example, err := apigateway.NewUsagePlanKey(ctx, "usagePlanKeyResource", &apigateway.UsagePlanKeyArgs{
	KeyId:       pulumi.String("string"),
	KeyType:     pulumi.String("string"),
	UsagePlanId: pulumi.String("string"),
})
var usagePlanKeyResource = new UsagePlanKey("usagePlanKeyResource", UsagePlanKeyArgs.builder()
    .keyId("string")
    .keyType("string")
    .usagePlanId("string")
    .build());
usage_plan_key_resource = aws.apigateway.UsagePlanKey("usagePlanKeyResource",
    key_id="string",
    key_type="string",
    usage_plan_id="string")
const usagePlanKeyResource = new aws.apigateway.UsagePlanKey("usagePlanKeyResource", {
    keyId: "string",
    keyType: "string",
    usagePlanId: "string",
});
type: aws:apigateway:UsagePlanKey
properties:
    keyId: string
    keyType: string
    usagePlanId: string
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 string
- Identifier of the API key resource.
- KeyType string
- Type of the API key resource. Currently, the valid key type is API_KEY.
- UsagePlan stringId 
- Id of the usage plan resource representing to associate the key to.
- KeyId string
- Identifier of the API key resource.
- KeyType string
- Type of the API key resource. Currently, the valid key type is API_KEY.
- UsagePlan stringId 
- Id of the usage plan resource representing to associate the key to.
- keyId String
- Identifier of the API key resource.
- keyType String
- Type of the API key resource. Currently, the valid key type is API_KEY.
- usagePlan StringId 
- Id of the usage plan resource representing to associate the key to.
- keyId string
- Identifier of the API key resource.
- keyType string
- Type of the API key resource. Currently, the valid key type is API_KEY.
- usagePlan stringId 
- Id of the usage plan resource representing to associate the key to.
- key_id str
- Identifier of the API key resource.
- key_type str
- Type of the API key resource. Currently, the valid key type is API_KEY.
- usage_plan_ strid 
- Id of the usage plan resource representing to associate the key to.
- keyId String
- Identifier of the API key resource.
- keyType String
- Type of the API key resource. Currently, the valid key type is API_KEY.
- usagePlan StringId 
- 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:
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) -> UsagePlanKeyfunc 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
- 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.
- KeyId string
- Identifier of the API key resource.
- KeyType string
- Type of the API key resource. Currently, the valid key type is API_KEY.
- Name string
- Name of a usage plan key.
- UsagePlan stringId 
- Id of the usage plan resource representing to associate the key to.
- Value string
- Value of a usage plan key.
- KeyId string
- Identifier of the API key resource.
- KeyType string
- Type of the API key resource. Currently, the valid key type is API_KEY.
- Name string
- Name of a usage plan key.
- UsagePlan stringId 
- Id of the usage plan resource representing to associate the key to.
- Value string
- Value of a usage plan key.
- keyId String
- Identifier of the API key resource.
- keyType String
- Type of the API key resource. Currently, the valid key type is API_KEY.
- name String
- Name of a usage plan key.
- usagePlan StringId 
- Id of the usage plan resource representing to associate the key to.
- value String
- Value of a usage plan key.
- keyId string
- Identifier of the API key resource.
- keyType string
- Type of the API key resource. Currently, the valid key type is API_KEY.
- name string
- Name of a usage plan key.
- usagePlan stringId 
- Id of the usage plan resource representing to associate the key to.
- value string
- Value of a usage plan key.
- key_id str
- Identifier of the API key resource.
- key_type 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_ strid 
- Id of the usage plan resource representing to associate the key to.
- value str
- Value of a usage plan key.
- keyId String
- Identifier of the API key resource.
- keyType String
- Type of the API key resource. Currently, the valid key type is API_KEY.
- name String
- Name of a usage plan key.
- usagePlan StringId 
- 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
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 awsTerraform Provider.