Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 02f3104

Browse files
apigatewayv2-ws-sqs
1 parent 3ddbdde commit 02f3104

File tree

2 files changed

+41
-20
lines changed

2 files changed

+41
-20
lines changed

‎apigatewayv2-ws-sqs/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## WebSocket API with SQS
2+
3+
![LocalStack](https://img.shields.io/static/v1?label=Works&message=@LocalStack&color=purple&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKgAAACoABZrFArwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAALbSURBVHic7ZpNaxNRFIafczNTGIq0G2M7pXWRlRv3Lusf8AMFEQT3guDWhX9BcC/uFAr1B4igLgSF4EYDtsuQ3M5GYrTaj3Tmui2SpMnM3PlK3m1uzjnPw8xw50MoaNrttl+r1e4CNRv1jTG/+v3+c8dG8TSilHoAPLZVX0RYWlraUbYaJI2IuLZ7KKUWCisgq8wF5D1A3rF+EQyCYPHo6Ghh3BrP8wb1en3f9izDYlVAp9O5EkXRB8dxxl7QBoNBpLW+7fv+a5vzDIvVU0BELhpjJrmaK2NMw+YsIxunUaTZbLrdbveZ1vpmGvWyTOJToNlsuqurq1vAdWPMeSDzwzhJEh0Bp+FTmifzxBZQBXiIKaAq8BBDQJXgYUoBVYOHKQRUER4mFFBVeJhAQJXh4QwBVYeHMQJmAR5GCJgVeBgiYJbg4T8BswYPp+4GW63WwvLy8hZwLcd5TudvBj3+OFBIeA4PD596nvc1iiIrD21qtdr+ysrKR8cY42itCwUP0Gg0+sC27T5qb2/vMunB/0ipTmZxfN//orW+BCwmrGV6vd63BP9P2j9WxGbxbrd7B3g14fLfwFsROUlzBmNM33XdR6Meuxfp5eg54IYxJvXCx8fHL4F3w36blTdDI4/0WREwMnMBeQ+Qd+YC8h4g78wF5D1A3rEqwBiT6q4ubpRSI+ewuhP0PO/NwcHBExHJZZ8PICI/e73ep7z6zzNPwWP1djhuOp3OfRG5kLROFEXv19fXP49bU6TbYQDa7XZDRF6kUUtEtoFb49YUbh/gOM7YbwqnyG4URQ/PWlQ4ASllNwzDzY2NDX3WwioKmBgeqidgKnioloCp4aE6AmLBQzUExIaH8gtIBA/lFrCTFB7KK2AnDMOrSeGhnAJSg4fyCUgVHsolIHV4KI8AK/BQDgHW4KH4AqzCQwEfiIRheKKUAvjuuu7m2tpakPdMmcYYI1rre0EQ1LPo9w82qyNziMdZ3AAAAABJRU5ErkJggg==)
4+
![AWS](https://img.shields.io/static/v1?label=Works&message=@AWS&color=orange&logo=amazon)
5+
6+
This template creates a WebSocket API that forwards the request body to an SQS queue using integration type `AWS`
7+
8+
### Requirements
9+
10+
- [ ] Community
11+
- [x] Pro
12+
13+
### Run
14+
15+
```
16+
./run.sh
17+
```
18+
19+
## Notes
20+
21+
Use `tfswitch` or `tfenv` to install the required provider version

‎apigatewayv2-ws-sqs/main.tf‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ resource "aws_sqs_queue" "sqs_queue" {
4141
}
4242

4343
resource "aws_apigatewayv2_integration" "sqs_integration" {
44-
api_id = aws_apigatewayv2_api.websocket_api.id
45-
credentials_arn = aws_iam_role.execution_role.arn
46-
integration_type = "AWS"
44+
api_id = aws_apigatewayv2_api.websocket_api.id
45+
credentials_arn = aws_iam_role.execution_role.arn
46+
integration_type = "AWS"
4747
payload_format_version = "1.0"
48-
integration_method = "POST"
49-
integration_uri = "arn:aws:apigateway:${data.aws_region.current.name}:sqs:path/${data.aws_caller_identity.current.account_id}/${aws_sqs_queue.sqs_queue.name}"
50-
passthrough_behavior = "NEVER"
48+
integration_method = "POST"
49+
integration_uri = "arn:aws:apigateway:${data.aws_region.current.name}:sqs:path/${data.aws_caller_identity.current.account_id}/${aws_sqs_queue.sqs_queue.name}"
50+
passthrough_behavior = "NEVER"
5151
request_parameters = {
5252
"integration.request.header.Content-Type" = "'application/x-www-form-urlencoded'"
5353
}
@@ -72,13 +72,13 @@ EOF
7272
}
7373

7474
resource "aws_apigatewayv2_integration" "disconnect_sqs_integration" {
75-
api_id = aws_apigatewayv2_api.websocket_api.id
76-
credentials_arn = aws_iam_role.execution_role.arn
77-
integration_type = "AWS"
75+
api_id = aws_apigatewayv2_api.websocket_api.id
76+
credentials_arn = aws_iam_role.execution_role.arn
77+
integration_type = "AWS"
7878
payload_format_version = "1.0"
79-
integration_method = "POST"
80-
integration_uri = "arn:aws:apigateway:${data.aws_region.current.name}:sqs:path/${data.aws_caller_identity.current.account_id}/${aws_sqs_queue.sqs_queue.name}"
81-
passthrough_behavior = "NEVER"
79+
integration_method = "POST"
80+
integration_uri = "arn:aws:apigateway:${data.aws_region.current.name}:sqs:path/${data.aws_caller_identity.current.account_id}/${aws_sqs_queue.sqs_queue.name}"
81+
passthrough_behavior = "NEVER"
8282
request_parameters = {
8383
"integration.request.header.Content-Type" = "'application/x-www-form-urlencoded'"
8484
}
@@ -107,8 +107,8 @@ resource "aws_apigatewayv2_route" "disconnect_route" {
107107
}
108108

109109
resource "aws_apigatewayv2_route_response" "connect_route_response" {
110-
api_id = aws_apigatewayv2_api.websocket_api.id
111-
route_id = aws_apigatewayv2_route.connect_route.id
110+
api_id = aws_apigatewayv2_api.websocket_api.id
111+
route_id = aws_apigatewayv2_route.connect_route.id
112112
route_response_key = "$default"
113113
}
114114

@@ -122,8 +122,8 @@ resource "aws_apigatewayv2_integration_response" "mock_response" {
122122
}
123123

124124
resource "aws_apigatewayv2_route_response" "default_route_response" {
125-
api_id = aws_apigatewayv2_api.websocket_api.id
126-
route_id = aws_apigatewayv2_route.default_route.id
125+
api_id = aws_apigatewayv2_api.websocket_api.id
126+
route_id = aws_apigatewayv2_route.default_route.id
127127
route_response_key = "$default"
128128
}
129129

@@ -137,7 +137,7 @@ resource "aws_apigatewayv2_integration_response" "sqs_response" {
137137
}
138138

139139
resource "aws_cloudwatch_log_group" "apigw_logs" {
140-
name = "/aws/apigateway/${aws_apigatewayv2_api.websocket_api.name}"
140+
name = "/aws/apigateway/${aws_apigatewayv2_api.websocket_api.name}"
141141
retention_in_days = 1
142142
}
143143

@@ -168,13 +168,13 @@ EOF
168168
}
169169

170170
resource "aws_apigatewayv2_stage" "stage" {
171-
api_id = aws_apigatewayv2_api.websocket_api.id
172-
name = "dev"
171+
api_id = aws_apigatewayv2_api.websocket_api.id
172+
name = "dev"
173173
auto_deploy = true
174174

175175
access_log_settings {
176176
destination_arn = aws_cloudwatch_log_group.apigw_logs.arn
177-
format = "$context.identity.sourceIp $context.identity.caller $context.identity.user [$context.requestTime] \"$context.httpMethod $context.routeKey $context.protocol\" $context.status $context.responseLength $context.requestId"
177+
format = "$context.identity.sourceIp $context.identity.caller $context.identity.user [$context.requestTime] \"$context.httpMethod $context.routeKey $context.protocol\" $context.status $context.responseLength $context.requestId"
178178
}
179179
}
180180

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /