-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
400 lines (331 loc) · 12.4 KB
/
Copy pathvariables.tf
File metadata and controls
400 lines (331 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
variable "name" {
description = "The name of this Lambda Function"
type = string
}
variable "description" {
description = "Description of your Lambda Function"
type = string
default = ""
}
variable "handler" {
description = "Lambda Function entrypoint in your code"
type = string
default = "index.lambda_handler"
}
variable "runtime" {
description = "Lambda Function runtime"
type = string
default = "python3.9"
}
variable "architectures" {
description = "(Optional) Instruction set architecture for your Lambda function. Valid architectures are x86_64 (default) and arm64."
type = list(string)
default = ["x86_64"]
}
variable "publish" {
description = "Whether to publish creation/change as new Lambda Function Version."
type = bool
default = true
}
variable "ephemeral_storage_size" {
description = "mount of ephemeral storage (/tmp) in MB your Lambda Function can use at runtime. Valid values are between 512 MB to 10,240 MB (10 GB)."
type = number
default = 512
validation {
condition = var.ephemeral_storage_size >= 512 && var.ephemeral_storage_size <= 10240
error_message = "ephemeral_storage_size must be in the range of 512 to 10240 inclusive."
}
}
variable "environment_variables" {
description = "A map that defines environment variables for the Lambda Function."
type = map(string)
default = {}
}
variable "memory_size" {
description = "Amount of memory in MB your Lambda Function can use at runtime. Valid values are between 128 MB to 10,240 MB (10 GB), in 64 MB increments."
type = number
default = 128
validation {
condition = var.memory_size >= 128 && var.memory_size <= 10240 && var.memory_size % 64 == 0
error_message = "memory_size must be between 128 and 10240 inclusive and divisible by 64."
}
}
variable "timeout" {
description = "The amount of time your Lambda Function has to run in seconds. The maximum lifetime of a Lambda function execution is 15 minutes (900 seconds)."
type = number
default = 3
validation {
condition = var.timeout >= 1 && var.timeout <= 900
error_message = "timeout must be between 1 and 900 inclusive."
}
}
# Packaging®ca
variable "create_package" {
description = "Controls whether Lambda package should be created"
type = bool
default = false
}
variable "source_path" {
description = "The absolute path to a local file or directory containing your Lambda source code. Only valid if `create_package` is set to `true`."
type = any
default = null
}
variable "zip_file_path" {
description = "Path of the source zip file with respect to module root"
type = string
default = null
}
variable "store_on_s3" {
description = "Whether to store produced artifacts on S3 or locally."
type = bool
default = false
}
variable "s3_existing_package" {
description = "The S3 bucket object with keys bucket, key, version pointing to an existing zip-file to use. Only valid if `create_package` is set to `false`."
type = map(string)
default = null
}
variable "s3_bucket" {
description = "S3 bucket to store artifacts. Required if `store_on_s3` is set to `true`, ignored otherwise."
type = string
default = null
}
variable "s3_prefix" {
description = "Directory name where artifacts should be stored in the S3 bucket. Defaults to `builds`. Required if `store_on_s3` is set to `true`, ignored otherwise."
type = string
default = "builds"
}
variable "layers" {
description = "List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function."
type = list(string)
default = null
validation {
condition = var.layers == null ? true : length(var.layers) <= 5
error_message = "Lambda Function layer attachment allows a maximum of 5 layers."
}
}
variable "hash_extra" {
description = "The string to add into hashing function. Useful when building same source path for different functions."
type = string
default = ""
}
variable "ignore_source_code_hash" {
description = "Whether to ignore changes to the function's source code hash. Set to true if you manage infrastructure and code deployments separately."
type = bool
default = false
}
# Function URL
variable "authorization_type" {
description = "The type of authentication that the Lambda Function URL uses. Set to `AWS_IAM` to restrict access to authenticated IAM users only. Set to `NONE` to bypass IAM authentication and create a public endpoint (default)."
type = string
default = "NONE"
}
variable "cors" {
description = "CORS settings to be used by the Lambda Function URL"
type = object({
allow_credentials = optional(bool, false)
allow_headers = optional(list(string), null)
allow_methods = optional(list(string), null)
allow_origins = optional(list(string), null)
expose_headers = optional(list(string), null)
max_age = optional(number, 0)
})
default = {}
}
variable "create_lambda_function_url" {
description = "Whether the Lambda Function URL resource should be created (default true)."
type = bool
default = true
}
variable "invoke_mode" {
description = "Invoke mode of the Lambda Function URL. Valid values are `BUFFERED` (default) and `RESPONSE_STREAM`."
type = string
default = "BUFFERED"
}
# Policy
variable "attach_policy_statements" {
description = "Controls whether `policy_statements` should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "policy_statements" {
description = "Map of dynamic policy statements to attach to Lambda Function role"
type = any
default = {}
}
variable "attach_policy" {
description = "Controls whether `policy` should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "policy" {
description = "Policy statement ARN to attach to Lambda Function role"
type = string
default = null
}
variable "attach_policies" {
description = "Controls whether `policies` should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "policies" {
description = "List of policy statement ARNs to attach to Lambda Function role"
type = list(string)
default = []
}
variable "attach_policy_json" {
description = "Controls whether `policy_json` should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "policy_json" {
description = "An additional policy document as JSON to attach to the Lambda Function role"
type = string
default = null
}
variable "attach_policy_jsons" {
description = "Controls whether `policy_jsons` should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "policy_jsons" {
description = "An additional policy documents as JSON to attach to the Lambda Function role"
type = list(string)
default = []
}
variable "attach_dead_letter_policy" {
description = "Controls whether SNS/SQS dead letter notification policy should be added to IAM role for Lambda Function. Defaults to `false`."
type = bool
default = false
}
variable "dead_letter_target_arn" {
description = "The ARN of an SNS topic or SQS queue to notify when an invocation fails."
type = string
default = null
}
variable "attach_network_policy" {
description = "Controls whether VPC/network policy should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "attach_async_event_policy" {
description = "Controls whether async event policy should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "attach_tracing_policy" {
description = "Controls whether X-Ray tracing policy should be added to IAM role for Lambda Function"
type = bool
default = false
}
variable "assume_role_policy_statements" {
description = "Map of dynamic policy statements for assuming Lambda Function role (trust relationship)"
type = map(string)
default = {}
}
variable "trusted_entities" {
description = "List of additional trusted entities for assuming Lambda Function role (trust relationship)"
type = any
default = []
}
variable "allowed_triggers" {
description = "Map of allowed triggers to create Lambda permissions"
type = map(any)
default = {}
}
# Logging
variable "attach_cloudwatch_logs_policy" {
description = "Controls whether CloudWatch Logs policy should be added to IAM role for Lambda Function"
type = bool
default = true
}
variable "attach_create_log_group_permission" {
description = "Controls whether to add the create log group permission to the CloudWatch logs policy"
type = bool
default = true
}
variable "cloudwatch_logs_kms_key_id" {
description = "The ARN of the KMS Key to use when encrypting log data."
type = string
default = null
}
variable "cloudwatch_logs_log_group_class" {
description = "Specified the log class of the log group. Possible values are: `STANDARD` (default) or `INFREQUENT_ACCESS`"
type = string
default = "STANDARD"
validation {
condition = contains(["STANDARD", "INFREQUENT_ACCESS"], var.cloudwatch_logs_log_group_class)
error_message = "cloudwatch_logs_log_group_class must be one of STANDARD, INFREQUENT_ACCESS"
}
}
variable "cloudwatch_logs_retention_in_days" {
description = "Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. Defaults to 30."
type = number
default = 30
validation {
condition = contains([0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, 3653], var.cloudwatch_logs_retention_in_days)
error_message = "cloudwatch_logs_retention_in_days must be one of 0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, 3653"
}
}
variable "cloudwatch_logs_skip_destroy" {
description = "Whether to keep the log group (and any logs it may contain) at destroy time. Defaults to false."
type = bool
default = false
}
variable "cloudwatch_logs_tags" {
description = "A map of tags to assign to the logs resource."
type = map(string)
default = {}
}
variable "tracing_mode" {
description = "Tracing mode of the Lambda Function. Valid value can be either PassThrough (default) or Active."
type = string
default = "PassThrough"
validation {
condition = contains(["PassThrough", "Active"], var.tracing_mode)
error_message = "tracing_mode must be one of PassThrough, Active"
}
}
# VPC Settings
variable "vpc_security_group_ids" {
description = "List of security group ids when Lambda Function should run in the VPC."
type = list(string)
default = null
}
variable "vpc_subnet_ids" {
description = "List of subnet ids when Lambda Function should run in the VPC. Usually private or intra subnets."
type = list(string)
default = null
}
# Lambda@Edge
variable "lambda_at_edge" {
description = "Set this to true if using Lambda@Edge, to enable publishing, limit the timeout, and allow edgelambda.amazonaws.com to invoke the function"
type = bool
default = false
}
variable "lambda_at_edge_logs_all_regions" {
description = "Whether to specify a wildcard in IAM policy used by Lambda@Edge to allow logging in all regions"
type = bool
default = true
}
variable "tags" {
description = "Map of tags to apply to this resource."
type = map(string)
default = {}
}
variable "create" {
description = " Controls whether resources should be created."
type = bool
default = false
}