Skip to content

Commit be9a4cd

Browse files
committed
terraform 0.14 compat
1 parent 4f6d4f9 commit be9a4cd

File tree

3 files changed

+48
-53
lines changed

3 files changed

+48
-53
lines changed

main.tf

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ terraform {
99

1010
archive = {
1111
source = "hashicorp/archive"
12-
version = "~> 1.2"
12+
version = "~> 2.0"
1313
}
1414
}
1515
}
@@ -71,78 +71,73 @@ locals {
7171

7272
# HTTP API
7373

74-
resource aws_apigatewayv2_integration proxy {
74+
resource "aws_apigatewayv2_integration" "proxy" {
7575
api_id = local.http_api.id
7676
connection_type = "INTERNET"
7777
description = local.http_api.integration_description
7878
integration_method = "POST"
7979
integration_type = "AWS_PROXY"
8080
integration_uri = aws_lambda_function.api.invoke_arn
81-
passthrough_behavior = "WHEN_NO_MATCH"
8281
timeout_milliseconds = 3000
83-
84-
lifecycle {
85-
ignore_changes = [passthrough_behavior]
86-
}
8782
}
8883

89-
resource aws_apigatewayv2_route post_callbacks {
84+
resource "aws_apigatewayv2_route" "post_callbacks" {
9085
api_id = local.http_api.id
9186
route_key = "POST ${local.http_api.route_prefix}callbacks"
9287
authorization_type = "NONE"
9388
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
9489
}
9590

96-
resource aws_apigatewayv2_route post_events {
91+
resource "aws_apigatewayv2_route" "post_events" {
9792
api_id = local.http_api.id
9893
route_key = "POST ${local.http_api.route_prefix}events"
9994
authorization_type = "NONE"
10095
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
10196
}
10297

103-
resource aws_apigatewayv2_route get_health {
98+
resource "aws_apigatewayv2_route" "get_health" {
10499
api_id = local.http_api.id
105100
route_key = "GET ${local.http_api.route_prefix}health"
106101
authorization_type = "NONE"
107102
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
108103
}
109104

110-
resource aws_apigatewayv2_route get_install {
105+
resource "aws_apigatewayv2_route" "get_install" {
111106
api_id = local.http_api.id
112107
route_key = "GET ${local.http_api.route_prefix}install"
113108
authorization_type = "NONE"
114109
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
115110
}
116111

117-
resource aws_apigatewayv2_route head_install {
112+
resource "aws_apigatewayv2_route" "head_install" {
118113
api_id = local.http_api.id
119114
route_key = "HEAD ${local.http_api.route_prefix}install"
120115
authorization_type = "NONE"
121116
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
122117
}
123118

124-
resource aws_apigatewayv2_route head_health {
119+
resource "aws_apigatewayv2_route" "head_health" {
125120
api_id = local.http_api.id
126121
route_key = "HEAD ${local.http_api.route_prefix}health"
127122
authorization_type = "NONE"
128123
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
129124
}
130125

131-
resource aws_apigatewayv2_route get_oauth {
126+
resource "aws_apigatewayv2_route" "get_oauth" {
132127
api_id = local.http_api.id
133128
route_key = "GET ${local.http_api.route_prefix}oauth"
134129
authorization_type = "NONE"
135130
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
136131
}
137132

138-
resource aws_apigatewayv2_route get_oauth_v2 {
133+
resource "aws_apigatewayv2_route" "get_oauth_v2" {
139134
api_id = local.http_api.id
140135
route_key = "GET ${local.http_api.route_prefix}oauth/v2"
141136
authorization_type = "NONE"
142137
target = "integrations/${aws_apigatewayv2_integration.proxy.id}"
143138
}
144139

145-
resource aws_apigatewayv2_route post_slash_cmd {
140+
resource "aws_apigatewayv2_route" "post_slash_cmd" {
146141
api_id = local.http_api.id
147142
route_key = "POST ${local.http_api.route_prefix}slash/{proxy+}"
148143
authorization_type = "NONE"
@@ -151,15 +146,15 @@ resource aws_apigatewayv2_route post_slash_cmd {
151146

152147
# LOG GROUPS
153148

154-
resource aws_cloudwatch_log_group logs {
149+
resource "aws_cloudwatch_log_group" "logs" {
155150
name = "/aws/lambda/${aws_lambda_function.api.function_name}"
156151
retention_in_days = local.log_group.retention_in_days
157152
tags = local.log_group.tags
158153
}
159154

160155
# LAMBDA FUNCTIONS
161156

162-
resource aws_lambda_function api {
157+
resource "aws_lambda_function" "api" {
163158
description = local.lambda.description
164159
filename = local.lambda.filename
165160
function_name = local.lambda.function_name
@@ -185,17 +180,17 @@ resource aws_lambda_function api {
185180

186181
# SNS TOPIC
187182

188-
resource aws_sns_topic topic {
183+
resource "aws_sns_topic" "topic" {
189184
name = local.topic.name
190185
}
191186

192187
# IAM
193188

194-
data aws_secretsmanager_secret secret {
189+
data "aws_secretsmanager_secret" "secret" {
195190
name = local.secret.name
196191
}
197192

198-
data aws_iam_policy_document assume_role {
193+
data "aws_iam_policy_document" "assume_role" {
199194
statement {
200195
actions = ["sts:AssumeRole"]
201196

@@ -206,7 +201,7 @@ data aws_iam_policy_document assume_role {
206201
}
207202
}
208203

209-
data aws_iam_policy_document api {
204+
data "aws_iam_policy_document" "api" {
210205
statement {
211206
sid = "DecryptKmsKey"
212207
actions = ["kms:Decrypt"]
@@ -238,21 +233,21 @@ data aws_iam_policy_document api {
238233
}
239234
}
240235

241-
resource aws_iam_role role {
236+
resource "aws_iam_role" "role" {
242237
assume_role_policy = data.aws_iam_policy_document.assume_role.json
243238
description = local.role.description
244239
name = local.role.name
245240
path = local.role.path
246241
tags = local.role.tags
247242
}
248243

249-
resource aws_iam_role_policy api {
244+
resource "aws_iam_role_policy" "api" {
250245
name = "api"
251246
role = aws_iam_role.role.id
252247
policy = data.aws_iam_policy_document.api.json
253248
}
254249

255-
resource aws_lambda_permission invoke_api {
250+
resource "aws_lambda_permission" "invoke_api" {
256251
count = length(local.lambda.permissions)
257252
action = "lambda:InvokeFunction"
258253
function_name = aws_lambda_function.api.arn

outputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
output lambda {
1+
output "lambda" {
22
description = "API Gateway REST API proxy Lambda"
33
value = aws_lambda_function.api
44
}
55

6-
output role {
6+
output "role" {
77
description = "Lambda function role"
88
value = aws_iam_role.role
99
}
1010

11-
output secret {
11+
output "secret" {
1212
description = "SecretsManager secret"
1313
value = data.aws_secretsmanager_secret.secret
1414
}
1515

16-
output topic {
16+
output "topic" {
1717
description = "Slackbot SNS topic"
1818
value = aws_sns_topic.topic
1919
}

variables.tf

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,118 @@
1-
variable base_path {
1+
variable "base_path" {
22
description = "Slack API base path"
33
default = "/"
44
}
55

6-
variable debug {
6+
variable "debug" {
77
description = "Node debug logger config"
88
default = "slackend:*"
99
}
1010

11-
variable http_api_execution_arn {
11+
variable "http_api_execution_arn" {
1212
description = "API Gateway v2 HTTP API execution ARN"
1313
}
1414

15-
variable http_api_id {
15+
variable "http_api_id" {
1616
description = "API Gateway v2 HTTP API ID"
1717
}
1818

19-
variable http_api_integration_description {
19+
variable "http_api_integration_description" {
2020
description = "API Gateway v2 HTTP API integration description"
2121
default = "Slack request Lambda integration"
2222
}
2323

24-
variable http_api_route_prefix {
24+
variable "http_api_route_prefix" {
2525
description = "API Gateway v2 HTTP API route prefix"
2626
default = "/"
2727
}
2828

29-
variable lambda_description {
29+
variable "lambda_description" {
3030
description = "Lambda function description"
3131
default = "Slack request handler"
3232
}
3333

34-
variable lambda_function_name {
34+
variable "lambda_function_name" {
3535
description = "Lambda function name"
3636
}
3737

38-
variable lambda_handler {
38+
variable "lambda_handler" {
3939
description = "Lambda handler signature"
4040
default = "index.handler"
4141
}
4242

43-
variable lambda_kms_key_arn {
43+
variable "lambda_kms_key_arn" {
4444
description = "Lambda function KMS key ARN"
4545
default = null
4646
}
4747

48-
variable lambda_publish {
48+
variable "lambda_publish" {
4949
description = "Lambda publish flag"
5050
default = false
5151
type = bool
5252
}
5353

54-
variable lambda_memory_size {
54+
variable "lambda_memory_size" {
5555
description = "Lambda function memory size"
5656
default = 1024
5757
}
5858

59-
variable lambda_permissions {
59+
variable "lambda_permissions" {
6060
description = "Lambda permissions for API Gateway v2 HTTP API"
6161
type = list(string)
6262
default = []
6363
}
6464

65-
variable lambda_runtime {
65+
variable "lambda_runtime" {
6666
description = "Lambda function runtime"
6767
default = "nodejs12.x"
6868
}
6969

70-
variable lambda_tags {
70+
variable "lambda_tags" {
7171
description = "Lambda function resource tags"
7272
type = map(string)
7373
default = {}
7474
}
7575

76-
variable lambda_timeout {
76+
variable "lambda_timeout" {
7777
description = "Lambda function timeout in seconds"
7878
default = 3
7979
}
8080

81-
variable log_group_retention_in_days {
81+
variable "log_group_retention_in_days" {
8282
description = "CloudWatch log group retention in days"
8383
default = null
8484
}
8585

86-
variable log_group_tags {
86+
variable "log_group_tags" {
8787
description = "CloudWatch log group resource tags"
8888
type = map(string)
8989
default = {}
9090
}
9191

92-
variable role_description {
92+
variable "role_description" {
9393
description = "Lambda role description"
9494
default = "Slackbot resource access"
9595
}
9696

97-
variable role_name {
97+
variable "role_name" {
9898
description = "Lambda role name"
9999
}
100100

101-
variable role_path {
101+
variable "role_path" {
102102
description = "Lambda role path"
103103
default = null
104104
}
105105

106-
variable role_tags {
106+
variable "role_tags" {
107107
description = "Lambda role resource tags"
108108
type = map(string)
109109
default = {}
110110
}
111111

112-
variable secret_name {
112+
variable "secret_name" {
113113
description = "SecretsManager secret name"
114114
}
115115

116-
variable topic_name {
116+
variable "topic_name" {
117117
description = "SNS topic name"
118118
}

0 commit comments

Comments
 (0)