Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apigw-websocket-api-sns-terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Important: this application uses various AWS services and there are costs associ

## How it works

This sample project demonstrates how to use WebSocket API to integrate with Amazon Simple Notification service (SNS) to send notifications. This pattern also implements data validation in WebSocket API using model in API Gateway. This template does not implement Authentication in WebSocket API to keep it simple. However, it is recommended to implement Authentication on WebSocket API.
This sample project demonstrates how to use WebSocket API to integrate with Amazon Simple Notification Service (SNS) to send notifications. This pattern also implements data validation in WebSocket API using model in Amazon API Gateway. This template does not implement Authentication in WebSocket API to keep it simple. However, it is recommended to implement Authentication on WebSocket API.
This pattern is utilizing native AWS Integration between WebSocket API Gateway and SNS. Request template is used in WebSocket integration to map the input to SNS payload.
This pattern is also a workaround to invoke AWS services in WebSocket API which requires Content-Type header to be application/x-www-form-urlencoded. By default, WebSocket APIs do not support overriding headers from AWS console and supports application/json in Content-Type header.

Expand Down Expand Up @@ -87,4 +87,4 @@ Once the application is deployed, retrieve the `websocket_URI` value from output
----
Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: MIT-0
SPDX-License-Identifier: MIT-0
6 changes: 3 additions & 3 deletions apigw-websocket-api-sns-terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0.0"
version = "~> 6.0"
}
random = {
source = "hashicorp/random"
Expand Down Expand Up @@ -158,7 +158,7 @@ resource "aws_apigatewayv2_integration_response" "disconnect_route_integration_r
resource "aws_apigatewayv2_integration" "send_order_route_integration" {
api_id = aws_apigatewayv2_api.web_socket_api.id
integration_type = "AWS"
integration_uri = "arn:aws:apigateway:${data.aws_region.current.name}:sns:action/Publish"
integration_uri = "arn:aws:apigateway:${data.aws_region.current.region}:sns:action/Publish"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

╷
│ Warning: Deprecated value used
│
│   with aws_apigatewayv2_integration.send_order_route_integration,
│   on main.tf line 161, in resource "aws_apigatewayv2_integration" "send_order_route_integration":
│  161:   integration_uri           = "arn:aws:apigateway:${data.aws_region.current.name}:sns:action/Publish"
│
│   The deprecation originates from data.aws_region.current.name
│
│ name is deprecated. Use region instead.
│
│ (and 3 more similar warnings elsewhere)

credentials_arn = aws_iam_role.apigw_sns_demo_functionrole.arn
integration_method = "POST"
content_handling_strategy = "CONVERT_TO_TEXT"
Expand Down Expand Up @@ -206,5 +206,5 @@ resource "aws_apigatewayv2_integration_response" "send_order_route_integration_r

output "api_endpoint" {
description = "API Gateway endpoint URL"
value = "wss://${aws_apigatewayv2_api.web_socket_api.id}.execute-api.${data.aws_region.current.name}.amazonaws.com/${var.api_stage_name}"
value = "wss://${aws_apigatewayv2_api.web_socket_api.id}.execute-api.${data.aws_region.current.region}.amazonaws.com/${var.api_stage_name}"
}