File tree 4 files changed +44
-4
lines changed
4 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -24,20 +24,23 @@ Note that this example may create resources which cost money. Run `terraform des
24
24
| ------| ---------|
25
25
| <a name =" requirement_terraform " ></a > [ terraform] ( #requirement\_ terraform ) | >= 0.13.1 |
26
26
| <a name =" requirement_aws " ></a > [ aws] ( #requirement\_ aws ) | >= 3.27 |
27
+ | <a name =" requirement_null " ></a > [ null] ( #requirement\_ null ) | >= 2 |
27
28
| <a name =" requirement_random " ></a > [ random] ( #requirement\_ random ) | >= 2 |
28
29
29
30
## Providers
30
31
31
32
| Name | Version |
32
33
| ------| ---------|
33
34
| <a name =" provider_aws " ></a > [ aws] ( #provider\_ aws ) | >= 3.27 |
35
+ | <a name =" provider_null " ></a > [ null] ( #provider\_ null ) | >= 2 |
34
36
| <a name =" provider_random " ></a > [ random] ( #provider\_ random ) | >= 2 |
35
37
36
38
## Modules
37
39
38
40
| Name | Source | Version |
39
41
| ------| --------| ---------|
40
42
| <a name =" module_disabled_step_function " ></a > [ disabled\_ step\_ function] ( #module\_ disabled\_ step\_ function ) | ../../ | n/a |
43
+ | <a name =" module_lambda_function " ></a > [ lambda\_ function] ( #module\_ lambda\_ function ) | terraform-aws-modules/lambda/aws | ~ > 2.0 |
41
44
| <a name =" module_step_function " ></a > [ step\_ function] ( #module\_ step\_ function ) | ../../ | n/a |
42
45
| <a name =" module_step_function_with_existing_log_group " ></a > [ step\_ function\_ with\_ existing\_ log\_ group] ( #module\_ step\_ function\_ with\_ existing\_ log\_ group ) | ../../ | n/a |
43
46
@@ -47,6 +50,7 @@ Note that this example may create resources which cost money. Run `terraform des
47
50
| ------| ------|
48
51
| [ aws_cloudwatch_log_group.external] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group ) | resource |
49
52
| [ aws_sqs_queue.queue] ( https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue ) | resource |
53
+ | [ null_resource.download_package] ( https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource ) | resource |
50
54
| [ random_pet.this] ( https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet ) | resource |
51
55
52
56
## Inputs
Original file line number Diff line number Diff line change @@ -58,7 +58,8 @@ module "step_function" {
58
58
}
59
59
60
60
lambda = {
61
- lambda = [" arn:aws:lambda:eu-west-1:123456789012:function:test1" , " arn:aws:lambda:eu-west-1:123456789012:function:test2" ]
61
+ lambda = [
62
+ module.lambda_function.lambda_function_arn, " arn:aws:lambda:eu-west-1:123456789012:function:test2" ]
62
63
}
63
64
64
65
xray = {
@@ -168,6 +169,40 @@ module "step_function_with_existing_log_group" {
168
169
depends_on = [aws_cloudwatch_log_group . external ]
169
170
}
170
171
172
+ # ############################################
173
+ # Using packaged function from Lambda module
174
+ # ############################################
175
+
176
+ locals {
177
+ package_url = " https://raw.githubusercontent.com/terraform-aws-modules/terraform-aws-lambda/master/examples/fixtures/python3.8-zip/existing_package.zip"
178
+ downloaded = " downloaded_package_${ md5 (local. package_url )} .zip"
179
+ }
180
+
181
+ resource "null_resource" "download_package" {
182
+ triggers = {
183
+ downloaded = local.downloaded
184
+ }
185
+
186
+ provisioner "local-exec" {
187
+ command = " curl -L -o ${ local . downloaded } ${ local . package_url } "
188
+ }
189
+ }
190
+
191
+ module "lambda_function" {
192
+ source = " terraform-aws-modules/lambda/aws"
193
+ version = " ~> 2.0"
194
+
195
+ function_name = " ${ random_pet . this . id } -lambda"
196
+ description = " My awesome lambda function"
197
+ handler = " index.lambda_handler"
198
+ runtime = " python3.8"
199
+
200
+ publish = true
201
+
202
+ create_package = false
203
+ local_existing_package = local. downloaded
204
+ }
205
+
171
206
# ##########
172
207
# Disabled
173
208
# ##########
Original file line number Diff line number Diff line change @@ -4,5 +4,6 @@ terraform {
4
4
required_providers {
5
5
aws = " >= 3.27"
6
6
random = " >= 2"
7
+ null = " >= 2"
7
8
}
8
9
}
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ resource "aws_iam_role" "this" {
82
82
# #############################
83
83
84
84
data "aws_iam_policy_document" "service" {
85
- for_each = local . create_role && var . attach_policies_for_integrations ? try ( tomap (var . service_integrations ), var. service_integrations ) : tomap ({})
85
+ for_each = { for k , v in var . service_integrations : k => v if local . create_role && var . attach_policies_for_integrations }
86
86
87
87
dynamic "statement" {
88
88
for_each = each. value
@@ -106,14 +106,14 @@ data "aws_iam_policy_document" "service" {
106
106
}
107
107
108
108
resource "aws_iam_policy" "service" {
109
- for_each = local . create_role && var . attach_policies_for_integrations ? try ( tomap (var . service_integrations ), var. service_integrations ) : tomap ({})
109
+ for_each = { for k , v in var . service_integrations : k => v if local . create_role && var . attach_policies_for_integrations }
110
110
111
111
name = " ${ local . role_name } -${ each . key } "
112
112
policy = data. aws_iam_policy_document . service [each . key ]. json
113
113
}
114
114
115
115
resource "aws_iam_policy_attachment" "service" {
116
- for_each = local . create_role && var . attach_policies_for_integrations ? try ( tomap (var . service_integrations ), var. service_integrations ) : tomap ({})
116
+ for_each = { for k , v in var . service_integrations : k => v if local . create_role && var . attach_policies_for_integrations }
117
117
118
118
name = " ${ local . role_name } -${ each . key } "
119
119
roles = [aws_iam_role . this [0 ]. name ]
You can’t perform that action at this time.
0 commit comments