-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
52 lines (44 loc) · 1.11 KB
/
main.tf
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
locals {
stageTag = {
"Avst:Stage:Name" = var.stage
}
finalTags = merge(var.tags, local.stageTag)
}
data "aws_region" "current" {}
module "aws-lambda" {
source = "Adaptavist/aws-lambda/module"
version = "1.11.0"
function_name = var.lambda_name
description = "A lambda which generates a random string and sets it into a supplied SSM path"
lambda_code_dir = "${path.module}/typescript/dist"
handler = "app.handler"
runtime = "nodejs16.x"
timeout = "300"
namespace = var.namespace
stage = var.stage
tags = local.finalTags
aws_region = data.aws_region.current.name
}
resource "aws_iam_role_policy" "lambda_exec_role_policy" {
name = "secret_generator_lambda_role_policy"
role = module.aws-lambda.lambda_role_name
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:*",
"secretsmanager:GetRandomPassword",
"iam:Generate*",
"iam:Get*",
"iam:List*",
"logs:*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
EOF
}