serverless / serverless/serverless

API gateway generated key name not prefixed with stage

Open
#6,458 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cat/aws-event-api-gateway enhancement
Dominant language
JavaScript
Stars
46.9k
Forks
5.7k
Avg merge
10h 7m
Merged PRs (30d)
57

Description

Context: https://serverless-contrib.slack.com/archives/CA4QT5VU3/p1564126720163800

The generated resource name for API gateway keys (e.g. "ApiGatewayApiKey1") doesn't contain service/stage, so it conflicts if you deploy your app to more than one stage

config:

apiKeys:
    - name: "${self:custom.stackName}-key1"
      value: 'blah blah'
      description: Api key description

name is not used for generating the resource name.
outputs:

    "ApiGatewayApiKey1": {
      "Type": "AWS::ApiGateway::ApiKey",
      "Properties": {
        "Enabled": true,
        "Name": "qc-dev-key1",
        "Value": "blah blah",
        "Description": "Api key description",
        "StageKeys": [
          {
            "RestApiId": {
              "Ref": "ApiGatewayRestApi"
            },
            "StageName": "dev"
          }

Error:

  An error occurred: ApiGatewayApiKey1 - API Key already exists (Service: AmazonApiGateway; Status Code: 409; Error Code: ConflictException;).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the API Gateway API key resource generation and reproduce the reported CloudFormation output for multiple stages. Verify that the generated resource name is stage-specific while the configured key Name, Value, Description, and StageKeys remain correct; done when deployments to different stages no longer conflict.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
api, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.