-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
executable file
·54 lines (48 loc) · 1.06 KB
/
iam.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
53
54
data "aws_iam_policy" "logging" {
arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
resource "aws_iam_policy" "s3read" {
name = "S3ReadAccess"
path = "/service-role/"
policy = <<POLICY
{
"Statement": [
{
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::gunjantest"
}
],
"Version": "2012-10-17"
}
POLICY
}
resource "aws_iam_role_policy_attachment" "lambda_to_log" {
policy_arn = data.aws_iam_policy.logging.arn
role = aws_iam_role.lambda_role.name
}
resource "aws_iam_role_policy_attachment" "lambda_to_s3" {
policy_arn = aws_iam_policy.s3read.arn
role = aws_iam_role.lambda_role.name
}
resource "aws_iam_role" "lambda_role" {
name = "ro-s3"
path = "/service-role/"
assume_role_policy = <<POLICY
{
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
],
"Version": "2012-10-17"
}
POLICY
}