UsagePlan

Provides an API Gateway Usage Plan.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var myapi = new Aws.ApiGateway.RestApi("myapi", new Aws.ApiGateway.RestApiArgs
        {
        });
        var dev = new Aws.ApiGateway.Deployment("dev", new Aws.ApiGateway.DeploymentArgs
        {
            RestApi = myapi.Id,
            StageName = "dev",
        });
        var prod = new Aws.ApiGateway.Deployment("prod", new Aws.ApiGateway.DeploymentArgs
        {
            RestApi = myapi.Id,
            StageName = "prod",
        });
        var myUsagePlan = new Aws.ApiGateway.UsagePlan("myUsagePlan", new Aws.ApiGateway.UsagePlanArgs
        {
            ApiStages = 
            {
                new Aws.ApiGateway.Inputs.UsagePlanApiStageArgs
                {
                    ApiId = myapi.Id,
                    Stage = dev.StageName,
                },
                new Aws.ApiGateway.Inputs.UsagePlanApiStageArgs
                {
                    ApiId = myapi.Id,
                    Stage = prod.StageName,
                },
            },
            Description = "my description",
            ProductCode = "MYCODE",
            QuotaSettings = new Aws.ApiGateway.Inputs.UsagePlanQuotaSettingsArgs
            {
                Limit = 20,
                Offset = 2,
                Period = "WEEK",
            },
            ThrottleSettings = new Aws.ApiGateway.Inputs.UsagePlanThrottleSettingsArgs
            {
                BurstLimit = 5,
                RateLimit = 10,
            },
        });
    }

}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        myapi, err := apigateway.NewRestApi(ctx, "myapi", nil)
        if err != nil {
            return err
        }
        dev, err := apigateway.NewDeployment(ctx, "dev", &apigateway.DeploymentArgs{
            RestApi:   myapi.ID(),
            StageName: pulumi.String("dev"),
        })
        if err != nil {
            return err
        }
        prod, err := apigateway.NewDeployment(ctx, "prod", &apigateway.DeploymentArgs{
            RestApi:   myapi.ID(),
            StageName: pulumi.String("prod"),
        })
        if err != nil {
            return err
        }
        _, err = apigateway.NewUsagePlan(ctx, "myUsagePlan", &apigateway.UsagePlanArgs{
            ApiStages: apigateway.UsagePlanApiStageArray{
                &apigateway.UsagePlanApiStageArgs{
                    ApiId: myapi.ID(),
                    Stage: dev.StageName,
                },
                &apigateway.UsagePlanApiStageArgs{
                    ApiId: myapi.ID(),
                    Stage: prod.StageName,
                },
            },
            Description: pulumi.String("my description"),
            ProductCode: pulumi.String("MYCODE"),
            QuotaSettings: &apigateway.UsagePlanQuotaSettingsArgs{
                Limit:  pulumi.Int(20),
                Offset: pulumi.Int(2),
                Period: pulumi.String("WEEK"),
            },
            ThrottleSettings: &apigateway.UsagePlanThrottleSettingsArgs{
                BurstLimit: pulumi.Int(5),
                RateLimit:  pulumi.Float64(10),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

myapi = aws.apigateway.RestApi("myapi")
dev = aws.apigateway.Deployment("dev",
    rest_api=myapi.id,
    stage_name="dev")
prod = aws.apigateway.Deployment("prod",
    rest_api=myapi.id,
    stage_name="prod")
my_usage_plan = aws.apigateway.UsagePlan("myUsagePlan",
    api_stages=[
        {
            "api_id": myapi.id,
            "stage": dev.stage_name,
        },
        {
            "api_id": myapi.id,
            "stage": prod.stage_name,
        },
    ],
    description="my description",
    product_code="MYCODE",
    quota_settings={
        "limit": 20,
        "offset": 2,
        "period": "WEEK",
    },
    throttle_settings={
        "burstLimit": 5,
        "rate_limit": 10,
    })
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const myapi = new aws.apigateway.RestApi("myapi", {});
const dev = new aws.apigateway.Deployment("dev", {
    restApi: myapi.id,
    stageName: "dev",
});
const prod = new aws.apigateway.Deployment("prod", {
    restApi: myapi.id,
    stageName: "prod",
});
const myUsagePlan = new aws.apigateway.UsagePlan("MyUsagePlan", {
    apiStages: [
        {
            apiId: myapi.id,
            stage: dev.stageName,
        },
        {
            apiId: myapi.id,
            stage: prod.stageName,
        },
    ],
    description: "my description",
    productCode: "MYCODE",
    quotaSettings: {
        limit: 20,
        offset: 2,
        period: "WEEK",
    },
    throttleSettings: {
        burstLimit: 5,
        rateLimit: 10,
    },
});

Create a UsagePlan Resource

def UsagePlan(resource_name, opts=None, api_stages=None, description=None, name=None, product_code=None, quota_settings=None, tags=None, throttle_settings=None, __props__=None);
func NewUsagePlan(ctx *Context, name string, args *UsagePlanArgs, opts ...ResourceOption) (*UsagePlan, error)
public UsagePlan(string name, UsagePlanArgs? args = null, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args UsagePlanArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args UsagePlanArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args UsagePlanArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

UsagePlan Resource Properties

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

Inputs

The UsagePlan resource accepts the following input properties:

ApiStages List<UsagePlanApiStageArgs>

The associated API stages of the usage plan.

Description string

The description of a usage plan.

Name string

The name of the usage plan.

ProductCode string

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

QuotaSettings UsagePlanQuotaSettingsArgs

The quota settings of the usage plan.

Tags Dictionary<string, string>

Key-value map of resource tags

ThrottleSettings UsagePlanThrottleSettingsArgs

The throttling limits of the usage plan.

ApiStages []UsagePlanApiStage

The associated API stages of the usage plan.

Description string

The description of a usage plan.

Name string

The name of the usage plan.

ProductCode string

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

QuotaSettings UsagePlanQuotaSettings

The quota settings of the usage plan.

Tags map[string]string

Key-value map of resource tags

ThrottleSettings UsagePlanThrottleSettings

The throttling limits of the usage plan.

apiStages UsagePlanApiStage[]

The associated API stages of the usage plan.

description string

The description of a usage plan.

name string

The name of the usage plan.

productCode string

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

quotaSettings UsagePlanQuotaSettings

The quota settings of the usage plan.

tags {[key: string]: string}

Key-value map of resource tags

throttleSettings UsagePlanThrottleSettings

The throttling limits of the usage plan.

api_stages List[UsagePlanApiStage]

The associated API stages of the usage plan.

description str

The description of a usage plan.

name str

The name of the usage plan.

product_code str

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

quota_settings Dict[UsagePlanQuotaSettings]

The quota settings of the usage plan.

tags Dict[str, str]

Key-value map of resource tags

throttle_settings Dict[UsagePlanThrottleSettings]

The throttling limits of the usage plan.

Outputs

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

Arn string

Amazon Resource Name (ARN)

Id string
The provider-assigned unique ID for this managed resource.
Arn string

Amazon Resource Name (ARN)

Id string
The provider-assigned unique ID for this managed resource.
arn string

Amazon Resource Name (ARN)

id string
The provider-assigned unique ID for this managed resource.
arn str

Amazon Resource Name (ARN)

id str
The provider-assigned unique ID for this managed resource.

Look up an Existing UsagePlan Resource

Get an existing UsagePlan 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?: UsagePlanState, opts?: CustomResourceOptions): UsagePlan
static get(resource_name, id, opts=None, api_stages=None, arn=None, description=None, name=None, product_code=None, quota_settings=None, tags=None, throttle_settings=None, __props__=None);
func GetUsagePlan(ctx *Context, name string, id IDInput, state *UsagePlanState, opts ...ResourceOption) (*UsagePlan, error)
public static UsagePlan Get(string name, Input<string> id, UsagePlanState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

ApiStages List<UsagePlanApiStageArgs>

The associated API stages of the usage plan.

Arn string

Amazon Resource Name (ARN)

Description string

The description of a usage plan.

Name string

The name of the usage plan.

ProductCode string

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

QuotaSettings UsagePlanQuotaSettingsArgs

The quota settings of the usage plan.

Tags Dictionary<string, string>

Key-value map of resource tags

ThrottleSettings UsagePlanThrottleSettingsArgs

The throttling limits of the usage plan.

ApiStages []UsagePlanApiStage

The associated API stages of the usage plan.

Arn string

Amazon Resource Name (ARN)

Description string

The description of a usage plan.

Name string

The name of the usage plan.

ProductCode string

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

QuotaSettings UsagePlanQuotaSettings

The quota settings of the usage plan.

Tags map[string]string

Key-value map of resource tags

ThrottleSettings UsagePlanThrottleSettings

The throttling limits of the usage plan.

apiStages UsagePlanApiStage[]

The associated API stages of the usage plan.

arn string

Amazon Resource Name (ARN)

description string

The description of a usage plan.

name string

The name of the usage plan.

productCode string

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

quotaSettings UsagePlanQuotaSettings

The quota settings of the usage plan.

tags {[key: string]: string}

Key-value map of resource tags

throttleSettings UsagePlanThrottleSettings

The throttling limits of the usage plan.

api_stages List[UsagePlanApiStage]

The associated API stages of the usage plan.

arn str

Amazon Resource Name (ARN)

description str

The description of a usage plan.

name str

The name of the usage plan.

product_code str

The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.

quota_settings Dict[UsagePlanQuotaSettings]

The quota settings of the usage plan.

tags Dict[str, str]

Key-value map of resource tags

throttle_settings Dict[UsagePlanThrottleSettings]

The throttling limits of the usage plan.

Supporting Types

UsagePlanApiStage

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

ApiId string

API Id of the associated API stage in a usage plan.

Stage string

API stage name of the associated API stage in a usage plan.

ApiId string

API Id of the associated API stage in a usage plan.

Stage string

API stage name of the associated API stage in a usage plan.

apiId string

API Id of the associated API stage in a usage plan.

stage string

API stage name of the associated API stage in a usage plan.

api_id str

API Id of the associated API stage in a usage plan.

stage str

API stage name of the associated API stage in a usage plan.

UsagePlanQuotaSettings

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Limit int

The maximum number of requests that can be made in a given time period.

Period string

The time period in which the limit applies. Valid values are “DAY”, “WEEK” or “MONTH”.

Offset int

The number of requests subtracted from the given limit in the initial time period.

Limit int

The maximum number of requests that can be made in a given time period.

Period string

The time period in which the limit applies. Valid values are “DAY”, “WEEK” or “MONTH”.

Offset int

The number of requests subtracted from the given limit in the initial time period.

limit number

The maximum number of requests that can be made in a given time period.

period string

The time period in which the limit applies. Valid values are “DAY”, “WEEK” or “MONTH”.

offset number

The number of requests subtracted from the given limit in the initial time period.

limit float

The maximum number of requests that can be made in a given time period.

period str

The time period in which the limit applies. Valid values are “DAY”, “WEEK” or “MONTH”.

offset float

The number of requests subtracted from the given limit in the initial time period.

UsagePlanThrottleSettings

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

BurstLimit int

The API request burst limit, the maximum rate limit over a time ranging from one to a few seconds, depending upon whether the underlying token bucket is at its full capacity.

RateLimit double

The API request steady-state rate limit.

BurstLimit int

The API request burst limit, the maximum rate limit over a time ranging from one to a few seconds, depending upon whether the underlying token bucket is at its full capacity.

RateLimit float64

The API request steady-state rate limit.

burstLimit number

The API request burst limit, the maximum rate limit over a time ranging from one to a few seconds, depending upon whether the underlying token bucket is at its full capacity.

rateLimit number

The API request steady-state rate limit.

burstLimit float

The API request burst limit, the maximum rate limit over a time ranging from one to a few seconds, depending upon whether the underlying token bucket is at its full capacity.

rate_limit float

The API request steady-state rate limit.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.