terraform-aws-modules / terraform-aws-apigateway-v2

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket) 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/apigateway-v2/aws
Apache License 2.0
151 stars 203 forks source link

stage_domain_name output for websocket api returns wss protocol and stage_id #117

Closed acormier-maia closed 3 months ago

acormier-maia commented 3 months ago

Description

When creating a websocket API, the output stage_domain_name contains the wss:// protocol and the stage_id prefix. This is due to the regex in the output value not matching the wss protocol.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

Reproduction Code [Required]

module "api_gateway" {
  source  = "terraform-aws-modules/apigateway-v2/aws"
  version = "5.0.0"

  name          = "websocket"
  description   = "Websocket API"
  protocol_type = "WEBSOCKET"
  route_selection_expression = "$request.body.action"

  create_domain_name = false

  stage_name = "ws-router"

  stage_default_route_settings = {
    logging_level            = "INFO"
  }

  routes = {
    "$connect" = {
      operation_name = "ConnectRoute"

      integration = {
        uri = var.websocket_connect_fn_arn
      }
    }
  }
}

output "stage_domain_name" {
    value = module.api_gateway.stage_domain_name
}

Steps to reproduce the behavior:

Run Terraform apply,

Expected behavior

Should only be the domain name.

Actual behavior

The stage_domain_name output starts with the wss:// protocol and ends with the stage_id.

bryantbiggs commented 3 months ago

what is the use case for this?

acormier-maia commented 3 months ago

I need to pass the domain name into Cloudfront. This way we have a single domain name which proxies S3, API Gateway. I am putting up a PR now.

antonbabenko commented 3 months ago

This issue has been resolved in version 5.1.3 :tada:

github-actions[bot] commented 2 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.