Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you create Usage Plan with Cloud Formation?

just like in the title. I can deploy stuff on AWS using only Cloud Formation. Now I try to secure my API Gateway with API Keys and looks like I need a Usage Plan for it. It doesn't seem to be covered by the documentation right here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-apikey.html

Have any of you had a similar problem and if yes, how did you solved it?

like image 914
greg Avatar asked Jan 06 '23 06:01

greg


1 Answers

AWS has today released the ability to create AWS::ApiGateway::UsagePlan using cloud formation templates

Now AWS::ApiGateway::UsagePlanKey can be created using CloudFormation.

This snippet demonstrates how you might use a UsagePlan and UsagePlanKey, along with an APIKey in a CloudFormation Template

UsagePlan:
  Type: 'AWS::ApiGateway::UsagePlan'
  Properties:
    ApiStages:
      - ApiId: !Ref MyRestApi
        Stage: !Ref Prod
    Description: Customer ABCs usage plan
    Quota:
      Limit: 5000
      Period: MONTH
    Throttle:
      BurstLimit: 200
      RateLimit: 100
    UsagePlanName: Plan_ABC

ApiKey:
  Type: 'AWS::ApiGateway::ApiKey'
  Properties:
    Name: TestApiKey
    Description: CloudFormation API Key V1
    Enabled: 'true'

UsagePlanKey:
  Type: 'AWS::ApiGateway::UsagePlanKey'
  Properties:
    KeyId: !Ref ApiKey
    KeyType: API_KEY
    UsagePlanId: !Ref UsagePlan
like image 138
georgealton Avatar answered Jan 13 '23 10:01

georgealton