A CloudFormation template for creating API Gateway usage plan.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: "2010-09-09" | |
Description: "API Gateway - usage plan template." | |
Parameters: | |
TargetApiId: | |
Type: String | |
Resources: | |
UsagePlan: | |
Type: "AWS::ApiGateway::UsagePlan" | |
Properties: | |
ApiStages: | |
- ApiId: !Ref TargetApiId | |
Stage: api | |
Description: Usage plan for API | |
UsagePlanName: ApiUsagePlan | |
Outputs: | |
UsagePlanID: | |
Description: ID of created usage plan | |
Value: !Ref UsagePlan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CHANGESET_OPTION="--no-execute-changeset" | |
if [ $# = 1 ] && [ $1 = "deploy" ]; then | |
echo "deploy mode" | |
CHANGESET_OPTION="" | |
fi | |
CFN_TEMPLATE="$(dirname $0)/api-usage-plan.yml" | |
CFN_STACK_NAME=ApiUsagePlan | |
aws cloudformation deploy --stack-name ${CFN_STACK_NAME} --template-file ${CFN_TEMPLATE} --parameter-overrides ChaliceDeployedApi=${TARGET_API_ID} ${CHANGESET_OPTION} | |
if [ $# = 1 ] && [ $1 = "deploy" ]; then | |
echo "\n----------------------------------------------\n" | |
echo "Following string is ID of created usage plan. Use it for creating api key belongs to an usage plan.\n" | |
aws cloudformation describe-stacks --stack-name ${CFN_STACK_NAME} | jq ".Stacks[0].Outputs[0].OutputValue" | sed -E "s/\"//g" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment