From 317d1c75bc1bfd50084489a0d229fa75ad1db889 Mon Sep 17 00:00:00 2001 From: Tariq Mahmood Date: Mon, 16 Oct 2023 16:58:38 +0100 Subject: [PATCH] LAWS-3514: adding lambda funtion as a module - v1.00 --- terraform/environments/apex/lambda.tf | 108 ++---------------- .../environments/apex/module/lambda/main.tf | 100 ++++++++++++++++ .../apex/module/lambda/variables.tf | 40 +++++++ terraform/environments/apex/variables.tf | 5 + 4 files changed, 155 insertions(+), 98 deletions(-) create mode 100644 terraform/environments/apex/module/lambda/main.tf create mode 100644 terraform/environments/apex/module/lambda/variables.tf create mode 100644 terraform/environments/apex/variables.tf diff --git a/terraform/environments/apex/lambda.tf b/terraform/environments/apex/lambda.tf index 8b878c1e1a9..ffb213d1095 100644 --- a/terraform/environments/apex/lambda.tf +++ b/terraform/environments/apex/lambda.tf @@ -1,103 +1,15 @@ -data "aws_iam_policy_document" "assume_role" { - statement { - effect = "Allow" +module "lambda_backup" { + source = "./module/lambda" - principals { - type = "Service" - identifiers = ["lambda.amazonaws.com","ssm.amazonaws.com"] - } +backup_policy_name = "${local.application_name}-lambda-instance-policy" +source_file = "" +output_path = "" +filename = "" +function_name = "" +handler = "" - actions = ["sts:AssumeRole"] - } -} - -resource "aws_iam_role" "backuplambdarole" { - name = "backuplambdarole" - assume_role_policy = data.aws_iam_policy_document.assume_role.json -} - -resource "aws_iam_policy" "backuplambdapolicy" { #tfsec:ignore:aws-iam-no-policy-wildcards - name = "${local.application_name}-lambda-instance-policy" - tags = merge( + tags = merge( local.tags, - { - Name = "${local.application_name}-lambda-instance-policy" - } + { Name = "laa-${local.application_name}-${local.environment}-mp" } ) - policy = <