Project: KICS (Provisioning / Security & Compliance)
File: 783860a3-6dca-4c8b-81d0-7b62769ccbca.md

title: API Gateway Deployment Without API Gateway UsagePlan Associated hide: toc: true navigation: true <style> .highlight .hll { background-color: #ff171742; } .md-content { max-width: 1100px; margin: 0 auto; } </style> Query id: 783860a3-6dca-4c8b-81d0-7b62769ccbca Query name: API Gateway Deployment Without API Gateway UsagePlan Associated Platform: CloudFormation Severity: <span style="color:#edd57e">Low</span> Category: Observability URL: API Gateway Deployment should have API Gateway UsagePlan defined and associated.<br> ```yaml title="Positive test num. 1 - yaml file" hl_lines="4" AWSTemplateFormatVersion: "2010-09-09" Description: "Router53" Resources: Deployment: Type: 'AWS::ApiGateway::Deployment' Properties: RestApiId: !Ref MyRestApi Description: My deployment StageName: Prod ``` ```yaml title="Positive test num. 2 - yaml file" hl_lines="4" AWSTemplateFormatVersion: "2010-09-09" Description: "Router53" Resources: Deployment1: Type: 'AWS::ApiGateway::Deployment' Properties: RestApiId: !Ref MyRestApi Description: My deployment StageName: Prod usagePlan1: Type: 'AWS::ApiGateway::UsagePlan' Properties: ApiStages: ApiId: !Ref MyRestApi Stage: !Ref Prod1 Description: Customer ABC's usage plan Quota: Limit: 5000 Period: MONTH Throttle: BurstLimit: 200 RateLimit: 100 UsagePlanName: Plan_ABC ``` ```yaml title="Positive test num. 3 - yaml file" hl_lines="4" AWSTemplateFormatVersion: "2010-09-09" Description: "Router53" Resources: Deployment2: Type: 'AWS::ApiGateway::Deployment' Properties: RestApiId: !Ref MyRestApi Description: My deployment StageName: Prod1 usagePlan2: Type: 'AWS::ApiGateway::UsagePlan' Properties: ApiStages: ApiId: !Ref MyRestApi Stage: !Ref Prod Description: Customer ABC's usage plan Quota: Limit: 5000 Period: MONTH Throttle: BurstLimit: 200 RateLimit: 100 UsagePlanName: Plan_ABC ``` <details><summary>Positive test num. 4 - json file</summary> ```json hl_lines="5" { "AWSTemplateFormatVersion": "2010-09-09", "Description": "Router53", "Resources": { "Deployment": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "StageName": "Prod", "RestApiId": "MyRestApi", "Description": "My deployment" } } } } ``` </details> <details><summary>Positive test num. 5 - json file</summary> ```json hl_lines="5" { "AWSTemplateFormatVersion": "2010-09-09", "Description": "Router53", "Resources": { "Deployment1": { "Properties": { "RestApiId": "MyRestApi", "Description": "My deployment", "StageName": "Prod" }, "Type": "AWS::ApiGateway::Deployment" }, "usagePlan1": { "Properties": { "Quota": { "Limit": 5000, "Period": "MONTH" }, "Throttle": { "BurstLimit": 200, "RateLimit": 100 }, "UsagePlanName": "Plan_ABC", "ApiStages": [ { "ApiId": "MyRestApi", "Stage": "Prod1" } ], "Description": "Customer ABC's usage plan" }, "Type": "AWS::ApiGateway::UsagePlan" } } } ``` </details> <details><summary>Positive test num. 6 - json file</summary> ```json hl_lines="5" { "AWSTemplateFormatVersion": "2010-09-09", "Description": "Router53", "Resources": { "Deployment2": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": "MyRestApi", "Description": "My deployment", "StageName": "Prod1" } }, "usagePlan2": { "Type": "AWS::ApiGateway::UsagePlan", "Properties": { "ApiStages": [ { "ApiId": "MyRestApi", "Stage": "Prod" } ], "Description": "Customer ABC's usage plan", "Quota": { "Limit": 5000, "Period": "MONTH" }, "Throttle": { "BurstLimit": 200, "RateLimit": 100 }, "UsagePlanName": "Plan_ABC" } } } } ``` </details> ```yaml title="Negative test num. 1 - yaml file" AWSTemplateFormatVersion: "2010-09-09" Description: "Router53" Resources: Deployment: Type: 'AWS::ApiGateway::Deployment' Properties: RestApiId: !Ref MyRestApi Description: My deployment StageName: Prod usagePlan: Type: 'AWS::ApiGateway::UsagePlan' Properties: ApiStages: ApiId: !Ref MyRestApi Stage: !Ref Prod Description: Customer ABC's usage plan Quota: Limit: 5000 Period: MONTH Throttle: BurstLimit: 200 RateLimit: 100 UsagePlanName: Plan_ABC ``` ```json title="Negative test num. 2 - json file" { "AWSTemplateFormatVersion": "2010-09-09", "Description": "Router53", "Resources": { "Deployment": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": "MyRestApi", "Description": "My deployment", "StageName": "Prod" } }, "usagePlan": { "Type": "AWS::ApiGateway::UsagePlan", "Properties": { "ApiStages": [ { "ApiId": "MyRestApi", "Stage": "Prod" } ], "Description": "Customer ABC's usage plan", "Quota": { "Limit": 5000, "Period": "MONTH" }, "Throttle": { "RateLimit": 100, "BurstLimit": 200 }, "UsagePlanName": "Plan_ABC" } } } } ```