|
1 |
| - |
2 |
| -terraform { |
3 |
| - required_version = ">= 0.12" |
4 |
| -} |
5 |
| - |
6 | 1 | locals {
|
7 | 2 | name = "new_account_iam_role_${random_string.id.result}"
|
8 | 3 | }
|
@@ -32,25 +27,32 @@ data "aws_iam_policy_document" "lambda" {
|
32 | 27 | }
|
33 | 28 |
|
34 | 29 | module "lambda" {
|
35 |
| - source = "git::https://github.com/plus3it/terraform-aws-lambda.git?ref=v1.3.0" |
| 30 | + source = "git::https://github.com/terraform-aws-modules/terraform-aws-lambda.git?ref=v4.1.1" |
36 | 31 |
|
37 | 32 | function_name = local.name
|
38 |
| - description = "Create new IAM Account Role" |
39 |
| - handler = "new_account_iam_role.lambda_handler" |
40 |
| - policy = data.aws_iam_policy_document.lambda |
41 |
| - runtime = "python3.8" |
42 |
| - source_path = "${path.module}/lambda/src" |
43 |
| - tags = var.tags |
44 |
| - timeout = 300 |
45 |
| - |
46 |
| - environment = { |
47 |
| - variables = { |
48 |
| - ASSUME_ROLE_NAME = var.assume_role_name |
49 |
| - ROLE_NAME = var.role_name |
50 |
| - PERMISSION_POLICY = var.role_permission_policy |
51 |
| - TRUST_POLICY_JSON = var.trust_policy_json |
52 |
| - LOG_LEVEL = var.log_level |
53 |
| - } |
| 33 | + |
| 34 | + description = "Create new IAM Account Role" |
| 35 | + handler = "new_account_iam_role.lambda_handler" |
| 36 | + runtime = "python3.8" |
| 37 | + timeout = 300 |
| 38 | + tags = var.tags |
| 39 | + |
| 40 | + attach_policy_json = true |
| 41 | + policy_json = data.aws_iam_policy_document.lambda.json |
| 42 | + |
| 43 | + source_path = "${path.module}/lambda/src" |
| 44 | + |
| 45 | + artifacts_dir = try(var.lambda.artifacts_dir, "builds") |
| 46 | + create_package = try(var.lambda.create_package, true) |
| 47 | + local_existing_package = try(var.lambda.local_existing_package, null) |
| 48 | + recreate_missing_package = try(var.lambda.recreate_missing_package, false) |
| 49 | + |
| 50 | + environment_variables = { |
| 51 | + ASSUME_ROLE_NAME = var.assume_role_name |
| 52 | + ROLE_NAME = var.role_name |
| 53 | + PERMISSION_POLICY = var.role_permission_policy |
| 54 | + TRUST_POLICY_JSON = var.trust_policy_json |
| 55 | + LOG_LEVEL = var.log_level |
54 | 56 | }
|
55 | 57 | }
|
56 | 58 |
|
@@ -81,12 +83,12 @@ resource "aws_cloudwatch_event_rule" "this" {
|
81 | 83 |
|
82 | 84 | resource "aws_cloudwatch_event_target" "this" {
|
83 | 85 | rule = aws_cloudwatch_event_rule.this.name
|
84 |
| - arn = module.lambda.function_arn |
| 86 | + arn = module.lambda.lambda_function_arn |
85 | 87 | }
|
86 | 88 |
|
87 | 89 | resource "aws_lambda_permission" "events" {
|
88 | 90 | action = "lambda:InvokeFunction"
|
89 |
| - function_name = module.lambda.function_name |
| 91 | + function_name = module.lambda.lambda_function_name |
90 | 92 | principal = "events.amazonaws.com"
|
91 | 93 | source_arn = aws_cloudwatch_event_rule.this.arn
|
92 | 94 | }
|
0 commit comments