-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.tf
69 lines (59 loc) · 1.88 KB
/
config.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
provider "aws" {
profile = "${var.aws_user_profile}"
region = "${var.aws_region}"
}
terraform {
required_version = ">= 0.12.9"
}
// IAM policy and role creation for our lambda instances
resource "aws_iam_role" "minigoodeed_lambda_role" {
name = "minigoodeed_lambda_role"
assume_role_policy = "${file("iam/assumerolepolicy.json")}"
}
resource "aws_iam_policy" "s3-policy" {
name = "s3-fullaccess-policy"
description = "Full access to s3"
policy = "${file("iam/policyS3.json")}"
}
resource "aws_iam_policy" "cloudwatch-policy" {
name = "cloudwatch-fullaccess-policy"
description = "Full access to cloudwatch"
policy = "${file("iam/policyCloudwatch.json")}"
}
resource "aws_iam_policy_attachment" "minigoodeed_lambda_role-attach-S3" {
name = "minigoodeed_lambda_role-attachment"
roles = ["${aws_iam_role.minigoodeed_lambda_role.name}"]
policy_arn = "${aws_iam_policy.s3-policy.arn}"
}
resource "aws_iam_policy_attachment" "minigoodeed_lambda_role-attach-Cloudwatch" {
name = "minigoodeed_lambda_role-attachment"
roles = ["${aws_iam_role.minigoodeed_lambda_role.name}"]
policy_arn = "${aws_iam_policy.cloudwatch-policy.arn}"
}
resource "aws_s3_bucket" "goodeed-bucket" {
bucket = "goodeed-bucket"
}
# resource "aws_s3_bucket_public_access_block" "goodeed-bucket" {
# bucket = "${aws_s3_bucket.goodeed-bucket.id}"
# block_public_acls = false
# block_public_policy = false
# }
resource "aws_s3_bucket_policy" "goodeed-bucket" {
bucket = "${aws_s3_bucket.goodeed-bucket.id}"
policy = <<POLICY
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::goodeed-bucket/*"
}
]
}
POLICY
}