Skip to content
v2.277.0

UsagePlanProps Struct ​

Example ​

ts
declare const integration: apigateway.LambdaIntegration;

const api = new apigateway.RestApi(this, 'hello-api');

const v1 = api.root.addResource('v1');
const echo = v1.addResource('echo');
const echoMethod = echo.addMethod('GET', integration, { apiKeyRequired: true });

const plan = api.addUsagePlan('UsagePlan', {
  name: 'Easy',
  throttle: {
    rateLimit: 10,
    burstLimit: 2
  }
});

const key = api.addApiKey('ApiKey');
plan.addApiKey(key);
python
# integration: apigateway.LambdaIntegration


api = apigateway.RestApi(self, "hello-api")

v1 = api.root.add_resource("v1")
echo = v1.add_resource("echo")
echo_method = echo.add_method("GET", integration, api_key_required=True)

plan = api.add_usage_plan("UsagePlan",
    name="Easy",
    throttle=apigateway.ThrottleSettings(
        rate_limit=10,
        burst_limit=2
    )
)

key = api.add_api_key("ApiKey")
plan.add_api_key(key)
java
LambdaIntegration integration;


RestApi api = new RestApi(this, "hello-api");

Resource v1 = api.root.addResource("v1");
Resource echo = v1.addResource("echo");
Method echoMethod = echo.addMethod("GET", integration, MethodOptions.builder().apiKeyRequired(true).build());

UsagePlan plan = api.addUsagePlan("UsagePlan", UsagePlanProps.builder()
        .name("Easy")
        .throttle(ThrottleSettings.builder()
                .rateLimit(10)
                .burstLimit(2)
                .build())
        .build());

IApiKey key = api.addApiKey("ApiKey");
plan.addApiKey(key);
csharp
// Install: dotnet add package Amazon.CDK.Lib
LambdaIntegration integration;


var api = new RestApi(this, "hello-api");

var v1 = api.Root.AddResource("v1");
var echo = v1.AddResource("echo");
var echoMethod = echo.AddMethod("GET", integration, new MethodOptions { ApiKeyRequired = true });

var plan = api.AddUsagePlan("UsagePlan", new UsagePlanProps {
    Name = "Easy",
    Throttle = new ThrottleSettings {
        RateLimit = 10,
        BurstLimit = 2
    }
});

var key = api.AddApiKey("ApiKey");
plan.AddApiKey(key);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var integration LambdaIntegration


api := apigateway.NewRestApi(this, jsii.String("hello-api"))

v1 := api.Root.AddResource(jsii.String("v1"))
echo := v1.AddResource(jsii.String("echo"))
echoMethod := echo.AddMethod(jsii.String("GET"), integration, &MethodOptions{
	ApiKeyRequired: jsii.Boolean(true),
})

plan := api.AddUsagePlan(jsii.String("UsagePlan"), &UsagePlanProps{
	Name: jsii.String("Easy"),
	Throttle: &ThrottleSettings{
		RateLimit: jsii.Number(10),
		BurstLimit: jsii.Number(2),
	},
})

key := api.AddApiKey(jsii.String("ApiKey"))
plan.addApiKey(key)

Properties ​

apiStagesoptionalUsagePlanPerApiStage[]api_stagesoptionaltyping.List[UsagePlanPerApiStage]apiStagesoptionalList<UsagePlanPerApiStage>ApiStagesoptionalUsagePlanPerApiStage[]ApiStagesoptional*[]UsagePlanPerApiStage= none#
API Stages to be associated with the usage plan.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string= none#
Represents usage plan purpose.
nameoptionalstringnameoptionalstrnameoptionalStringNameoptionalstringNameoptional*string= none#
Name for this usage plan.
quotaoptionalQuotaSettingsquotaoptionalQuotaSettingsquotaoptionalQuotaSettingsQuotaoptionalQuotaSettingsQuotaoptionalQuotaSettings= none#
Number of requests clients can make in a given time period.
throttleoptionalThrottleSettingsthrottleoptionalThrottleSettingsthrottleoptionalThrottleSettingsThrottleoptionalThrottleSettingsThrottleoptionalThrottleSettings= none#
Overall throttle settings for the API.