Skip to content

Commit b3a937a

Browse files
committed
VED-500: Role, permissions and trustpolicies to push events to csoc's event bus
1 parent 9f6b8a1 commit b3a937a

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

terraform/csoc_cloudwatch.tf

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
resource "aws_iam_role" "eventbridge_forwarder_role" {
2+
name = "${local.short_prefix}-eventbridge-forwarder-role"
3+
assume_role_policy = jsonencode({
4+
Version : "2012-10-17",
5+
Statement = [{
6+
Sid = "TrustEventBridgeService",
7+
Effect = "Allow",
8+
Principal = { Service = "events.amazonaws.com" },
9+
Action = "sts:AssumeRole",
10+
Condition = {
11+
StringEquals = {
12+
"aws:SourceAccount" = var.immunisation_account_id
13+
}
14+
}
15+
}]
16+
})
17+
}
18+
19+
resource "aws_iam_role_policy" "eventbridge_forwarder_policy" {
20+
name = "${local.short_prefix}-eventbridge-forwarder-policy"
21+
role = aws_iam_role.eventbridge_forwarder_role.id
22+
23+
policy = jsonencode({
24+
Version = "2012-10-17",
25+
Statement = [{
26+
Sid = "ActionsForResource",
27+
Effect = "Allow",
28+
Action = ["events:PutEvents"],
29+
Resource = [
30+
"arn:aws:events:eu-west-2:693466633220:event-bus/shield-eventbus"
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+
resource "aws_iam_role" "dynamo_s3_access_role" {
63+
name = "${local.short_prefix}-dynamo-s3-access-role"
64+
assume_role_policy = jsonencode({
65+
Version : "2012-10-17",
66+
Statement : [
67+
{
68+
Effect : "Allow",
69+
Principal : {
70+
AWS : "arn:aws:iam::${var.dspp_core_account_id}:root"
71+
},
72+
Action : "sts:AssumeRole"
73+
}
74+
]
75+
})
76+
}
77+
78+
resource "aws_iam_role_policy" "dynamo_s3_access_policy" {
79+
name = "${local.short_prefix}-dynamo_s3_access-policy"
80+
role = aws_iam_role.dynamo_s3_access_role.id
81+
policy = jsonencode({
82+
Version = "2012-10-17",
83+
Statement = [
84+
{
85+
Effect = "Allow",
86+
Action = [
87+
"dynamodb:BatchGetItem",
88+
"dynamodb:GetItem",
89+
"dynamodb:Query"
90+
],
91+
Resource = [
92+
aws_dynamodb_table.delta-dynamodb-table.arn,
93+
"${aws_dynamodb_table.delta-dynamodb-table.arn}/index/*"
94+
]
95+
}
96+
]
97+
})
98+
}

0 commit comments

Comments
 (0)