Bird
Raised Fist0
AWScloud~10 mins

API keys and usage plans in AWS - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - API keys and usage plans
Create API Key
↓
Create Usage Plan
↓
Associate API Key with Usage Plan
↓
Client uses API Key
↓
API Gateway checks Usage Plan limits
↓
Within Limits
↓
Allow Request
This flow shows how an API key is created, linked to a usage plan with limits, and how API Gateway checks these limits when a client makes a request.
Execution Sample
AWS
1. Create API Key 'Key123'
2. Create Usage Plan 'PlanA' with 1000 requests/day
3. Link 'Key123' to 'PlanA'
4. Client sends request with 'Key123'
5. API Gateway checks if usage < 1000
6. If yes, allow; else reject
This example shows creating an API key, a usage plan with limits, linking them, and how API Gateway enforces the limits on requests.
Process Table
StepActionAPI Key Usage CountUsage Plan LimitCheck ResultRequest Outcome
1Create API Key 'Key123'0N/AN/AAPI Key created
2Create Usage Plan 'PlanA' with 1000 requests/day01000N/AUsage Plan created
3Associate 'Key123' with 'PlanA'01000N/AAssociation done
4Client sends request with 'Key123'01000Check usage < limitProceed to check
5API Gateway checks usage count010000 < 1000 is TrueRequest allowed
6Increment usage count11000N/AUsage count updated
7Repeat requests until usage reaches 10009991000999 < 1000 is TrueRequest allowed
8Client sends request after limit reached100010001000 < 1000 is FalseRequest rejected
💡 Requests stop being allowed once usage count reaches the usage plan limit of 1000.
Status Tracker
VariableStartAfter Step 4After Step 6After Step 7Final
API Key Usage Count0019991000
Usage Plan LimitN/A1000100010001000
Request OutcomeN/APendingAllowedAllowedRejected
Key Moments - 3 Insights
Why does the request get rejected at step 8 even though usage count equals the limit?
Because the usage plan limit is a maximum allowed number of requests. When usage count reaches the limit, further requests are blocked as shown in execution_table row 8.
What happens if a client sends a request without an API key?
The request is rejected immediately because API Gateway requires a valid API key associated with a usage plan to track and enforce limits. This is implied before step 4.
Does the usage count reset automatically each day?
Yes, usage plans typically reset usage counts daily or per configured period, allowing clients to make new requests within limits. This is part of usage plan behavior beyond the shown steps.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 5, what is the check result for usage count 0 and limit 1000?
AUsage count equals limit
B0 < 1000 is True
C0 < 1000 is False
DCheck not performed
💡 Hint
Refer to execution_table row 5 under 'Check Result' column.
At which step does the request start getting rejected due to exceeding the usage plan limit?
AStep 4
BStep 6
CStep 8
DStep 3
💡 Hint
Check execution_table rows 7 and 8 under 'Request Outcome' column.
If the usage plan limit was increased to 2000, how would the request outcome at step 8 change?
ARequest would be allowed
BRequest would still be rejected
CAPI key would be deleted
DUsage count would reset
💡 Hint
Look at usage plan limit and request outcome in execution_table rows 7 and 8.
Concept Snapshot
API keys identify clients.
Usage plans set request limits.
Link API keys to usage plans.
API Gateway checks usage on each request.
Requests over limit are rejected.
Usage resets periodically.
Full Transcript
This visual execution shows how API keys and usage plans work together in AWS API Gateway. First, an API key is created. Then a usage plan is created with a request limit, for example 1000 requests per day. The API key is linked to the usage plan. When a client sends a request with the API key, API Gateway checks if the usage count is below the limit. If yes, the request is allowed and usage count increments. If usage reaches the limit, further requests are rejected until usage resets. This ensures fair use and protects the API from overuse.

Practice

(1/5)
1. What is the main purpose of an API key in AWS API Gateway?
easy
A. To monitor server CPU usage
B. To store user data securely
C. To encrypt API responses
D. To identify and control who can access the API

Solution

  1. Step 1: Understand API key role

    An API key is used to identify the client calling the API.
  2. Step 2: Identify purpose in AWS API Gateway

    It helps control and track who can access the API, not data storage or encryption.
  3. Final Answer:

    To identify and control who can access the API -> Option D
  4. Quick Check:

    API key = identify and control access [OK]
Hint: API keys identify users, not store or encrypt data [OK]
Common Mistakes:
  • Confusing API keys with encryption keys
  • Thinking API keys store user data
  • Assuming API keys monitor server metrics
2. Which of the following is the correct way to associate an API key with a usage plan in AWS API Gateway?
easy
A. Create a usage plan, then add the API key to it
B. Create an API key, then add a usage plan to it
C. Create a usage plan and API key separately without linking
D. Create an API key inside the usage plan settings

Solution

  1. Step 1: Understand usage plan and API key relationship

    Usage plans define limits and must have API keys linked to enforce them.
  2. Step 2: Correct linking process

    You create a usage plan first, then add API keys to it to apply limits.
  3. Final Answer:

    Create a usage plan, then add the API key to it -> Option A
  4. Quick Check:

    Usage plan first, then add API key [OK]
Hint: Link API keys by adding them to usage plans [OK]
Common Mistakes:
  • Trying to add usage plans to API keys
  • Not linking keys and plans at all
  • Assuming API keys are created inside usage plans
3. Given this AWS CLI command output showing usage plan limits:
{"throttle": {"rateLimit": 100, "burstLimit": 200}, "quota": {"limit": 1000, "period": "DAY"}}

What does this usage plan enforce?
medium
A. Max 1000 requests per second, burst up to 200, and 100 requests per day
B. Max 200 requests per second, burst up to 100, and 1000 requests per day
C. Max 100 requests per second, burst up to 200, and 1000 requests per day
D. No limits on requests per second or daily quota

Solution

  1. Step 1: Interpret throttle limits

    RateLimit 100 means 100 requests per second max, burstLimit 200 allows short bursts up to 200 requests.
  2. Step 2: Interpret quota limits

    Quota limit 1000 per DAY means max 1000 requests allowed in one day.
  3. Final Answer:

    Max 100 requests per second, burst up to 200, and 1000 requests per day -> Option C
  4. Quick Check:

    Throttle = 100/sec + 200 burst, Quota = 1000/day [OK]
Hint: Throttle = per second, quota = daily limit [OK]
Common Mistakes:
  • Mixing burstLimit with rateLimit
  • Confusing quota limit with per second limit
  • Ignoring the quota period
4. You created an API key and a usage plan, but API calls with the key are not limited by the usage plan. What is the most likely cause?
medium
A. The usage plan has no throttle or quota limits set
B. The API key is not associated with the usage plan
C. The API key is expired
D. The API Gateway stage is not deployed

Solution

  1. Step 1: Check API key and usage plan link

    Usage plans only apply limits if the API key is linked to them.
  2. Step 2: Verify other causes

    While no limits or deployment can cause issues, the key not linked means no limits apply.
  3. Final Answer:

    The API key is not associated with the usage plan -> Option B
  4. Quick Check:

    Key must be linked to usage plan for limits [OK]
Hint: Check if API key is linked to usage plan [OK]
Common Mistakes:
  • Assuming usage plan limits apply without linking keys
  • Ignoring deployment status
  • Confusing expired keys with unlinked keys
5. You want to create a usage plan that limits users to 5000 requests per month and 50 requests per second with a burst of 100. You also want to track usage per API key. Which steps correctly achieve this?
hard
A. Create usage plan with quota 5000/month and throttle 50/sec burst 100, then add API keys to the plan
B. Create API keys with limits, then assign usage plan to each key
C. Create usage plan with limits, deploy API, no need to link API keys
D. Set limits on API Gateway stage, then create API keys without usage plan

Solution

  1. Step 1: Define usage plan with required limits

    Set quota to 5000 per month and throttle to 50 requests per second with burst 100.
  2. Step 2: Link API keys to usage plan

    Adding API keys to the usage plan enables tracking and enforcement of limits per key.
  3. Final Answer:

    Create usage plan with quota 5000/month and throttle 50/sec burst 100, then add API keys to the plan -> Option A
  4. Quick Check:

    Usage plan sets limits + keys linked for tracking [OK]
Hint: Set limits in usage plan, then add API keys [OK]
Common Mistakes:
  • Trying to set limits on API keys directly
  • Not linking API keys to usage plan
  • Setting limits only on API Gateway stage
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard