Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dmost714/3bd6397aaaa84cb30d2f1f4289ad254b to your computer and use it in GitHub Desktop.
Save dmost714/3bd6397aaaa84cb30d2f1f4289ad254b to your computer and use it in GitHub Desktop.
Custom resource(s) to add USAGE PLAN and KEYs for API GW REST endpoints
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"env": {
"Type": "String"
},
"apirestapiRootUrl": {
"Type": "String",
"Description": "Input parameter describing RootUrl attribute for api/restapi resource"
},
"apirestapiApiName": {
"Type": "String",
"Description": "Input parameter describing ApiName attribute for api/restapi resource"
},
"apirestapiApiId": {
"Type": "String",
"Description": "Input parameter describing ApiId attribute for api/restapi resource"
}
},
"Resources": {
"usagePlanCustomer": {
"Type": "AWS::ApiGateway::UsagePlan",
"Properties": {
"ApiStages": [
{
"ApiId": {
"Ref": "apirestapiApiId"
},
"Stage": {
"Ref": "env"
}
}
],
"Description": {
"Fn::Sub": [
"CUSTOMER Usage Plan-${stage}",
{
"stage": {
"Ref": "env"
}
}
]
},
"Quota": {
"Limit": 6000,
"Period": "DAY"
},
"Throttle": {
"BurstLimit": 240,
"RateLimit": 120
},
"UsagePlanName": {
"Fn::Sub": [
"Customer_Plan_${type}-${stage}",
{
"type": "SANDBOX",
"stage": {
"Ref": "env"
}
}
]
}
}
},
"apiKeyCustomerSandbox": {
"Type": "AWS::ApiGateway::ApiKey",
"Properties": {
"Name": {
"Fn::Sub": [
"CustomerSandboxApiKey-${env}",
{
"env": {
"Ref": "env"
}
}
]
},
"Description": "Customer Sandbox - CloudFormation API Key V1",
"Enabled": true
}
},
"apiKeyCustomerLive": {
"Type": "AWS::ApiGateway::ApiKey",
"Properties": {
"Name": {
"Fn::Sub": [
"CustomerLiveApiKey-${env}",
{
"env": {
"Ref": "env"
}
}
]
},
"Description": "Customer Live - CloudFormation API Key V1",
"Enabled": true
}
},
"usagePlanKeyCustomerSandbox": {
"Type": "AWS::ApiGateway::UsagePlanKey",
"DependsOn": [
"usagePlanCustomer",
"apiKeyCustomerSandbox"
],
"Properties": {
"KeyId": {
"Ref": "apiKeyCustomerSandbox"
},
"KeyType": "API_KEY",
"UsagePlanId": {
"Ref": "usagePlanCustomer"
}
}
},
"usagePlanKeyCustomerLive": {
"Type": "AWS::ApiGateway::UsagePlanKey",
"DependsOn": [
"usagePlanCustomer",
"apiKeyCustomerLive"
],
"Properties": {
"KeyId": {
"Ref": "apiKeyCustomerLive"
},
"KeyType": "API_KEY",
"UsagePlanId": {
"Ref": "usagePlanCustomer"
}
}
}
},
"Outputs": {},
"Description": "{\"createdOn\":\"Mac\",\"createdBy\":\"Amplify\",\"createdWith\":\"11.0.5\",\"stackType\":\"custom-customCloudformation\",\"metadata\":{}}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment