generated from ministryofjustice/cloud-platform-terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
44 lines (37 loc) · 1.04 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
resource "aws_iam_role" "canary" {
name = "cp-canary-${var.canary_name}"
path = "/"
assume_role_policy = data.aws_iam_policy_document.canary_assume.json
}
resource "aws_iam_role_policy_attachment" "canary" {
role = aws_iam_role.canary.name
policy_arn = aws_iam_policy.canary.arn
}
data "aws_iam_policy_document" "canary_assume" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
resource "aws_iam_policy" "canary" {
name = "cp-canary-${var.canary_name}"
description = "Synthetics Canary policy"
policy = data.aws_iam_policy_document.canary.json
}
data "aws_iam_policy_document" "canary" {
statement {
sid = ""
effect = "Allow"
resources = ["arn:aws:s3:::${var.canary_bucket}"]
actions = ["s3:PutObject"]
}
statement {
sid = ""
effect = "Allow"
resources = ["arn:aws:s3:::${var.canary_bucket}"]
actions = ["s3:GetBucketLocation"]
}
}