Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: TITLE"Invalid API identifier specified" when attaching resources to an existing AWS::ApiGatewayV2::Api #7030

Closed
ctabeckey opened this issue May 6, 2024 · 2 comments
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Comments

@ctabeckey
Copy link

ctabeckey commented May 6, 2024

Description:

Creating any resource which references an existing API Gateway V2 fails when trying to find the existing gateway. The following example uses an AWS:ApiGatewayV2::Stage as an example but the same issue occurs with:

  • AWS:ApiGatewayV2::Stage
  • AWS::ApiGatewayV2::ApiMapping
  • AWS::ApiGateway::Resource
  • AWS::ApiGatewayV2::Integration

Steps to reproduce:

Given this snippet in a template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: api_gw

Parameters:
  Stage:
    Type: String
  NotificationApi:
    Type: String

  StatusWebSocketAPIStage:
    Type: AWS::ApiGatewayV2::Stage
    Properties:
      StageName: !Ref Stage
      ApiId: !Ref NotificationApi
      AutoDeploy: true

and a samconfig.toml file containing the following:

[local.deploy.parameters]
...
parameter_overrides = [
    "Stage=local",
    "NotificationApi=bwop0s66op"
]

Running SAM ClI with:
sam deploy --config-env local

results in an error:
Invalid API identifier specified 665192190199:bwop0s66op (Service: AmazonApiGatewayV2; Status Code: 404; Error Code: NotFoundException; Request ID: 4722191c-c190-49e8-a6f2-cc014110bc21; Proxy: null)
where '665192190199' is the account number and 'bwop0s66op' is the ID of an existing APIGateway

Running the following aws command, which is logically equivalent to the SAM invocation succeeds:
aws apigatewayv2 create-stage --api-id bwop0s66op --stage-name local --auto-deploy

Observed result:

CREATE_FAILED AWS::ApiGatewayV2::Stage OCRStatusWebSocketAPIStage Invalid API identifier specified 665192190199:bwop0s66op (Service: AmazonApiGatewayV2; Status Code: 404; Error Code: NotFoundException; Request ID: 4c498551-bb24-4e63-b7be-a0541ecffbbf; Proxy: null)

Expected result:

The Stage/Mapping/Integration/Resource would be created and correctly reference the given ApiGateway

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)\

{
  "version": "1.116.0",
  "system": {
    "python": "3.8.13",
    "os": "macOS-14.4.1-x86_64-i386-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "Not available",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}
@ctabeckey ctabeckey added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label May 6, 2024
@ctabeckey
Copy link
Author

Bypassing SAM, i.e. running this template:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: spi_api_gw
Parameters:
  NotificationApi:
    Description: The Identifier of the WebSocket APIGateway
    Type: String
Resources:
  OCRStatusWebSocketAPIStage:
    # Each stage is a named reference to a deployment of the API
    Type: AWS::ApiGatewayV2::Stage
    Properties:
      StageName: 'local'
      ApiId: !Ref NotificationApi
      AutoDeploy: true

with this CLI command:
aws cloudformation deploy --template-file src/stage_template.yaml --stack-name spi-api-gw-local --parameter-overrides NotificationApi=bwop0s66gg
succeeds

Copy link
Contributor

github-actions bot commented May 6, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.
Projects
None yet
Development

No branches or pull requests

1 participant