Last active
July 31, 2019 11:26
-
-
Save tminussi/a2a4a897cd2377f67f188612cb009944 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iam_role | |
resource "aws_iam_role" "iam_role" { | |
name = "iam-role" | |
assume_role_policy = templatefile("${path.module}/templates/lambda-base-policy.tpl", {}) | |
} | |
#content of lambda-base-policy.tpl | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, | |
"Effect": "Allow", | |
"Sid": "" | |
} | |
] | |
} | |
#iam_policy | |
resource "aws_iam_policy" "policy" { | |
name = "policy" | |
policy = templatefile("${path.module}/templates/cloudwatch-policy.tpl", {}) | |
} | |
#content of cloudwatch-policy.tpl | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", | |
"logs:PutLogEvents" | |
], | |
"Resource": "*" | |
} | |
] | |
} | |
#iam_policy_attachment | |
resource "aws_iam_policy_attachment" "policy_attachment" { | |
name = "attachment" | |
roles = ["${aws_iam_role.iam_role.name}"] | |
policy_arn = "${aws_iam_policy.policy.arn}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment