forked from outerbounds/terraform-aws-metaflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam-eventbridge.tf
44 lines (37 loc) · 1.17 KB
/
iam-eventbridge.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
data "aws_iam_policy_document" "eventbridge_assume_role_policy" {
statement {
effect = "Allow"
principals {
identifiers = [
"events.amazonaws.com"
]
type = "Service"
}
actions = [
"sts:AssumeRole"
]
}
}
data "aws_iam_policy_document" "eventbridge_step_functions_policy" {
statement {
actions = [
"states:StartExecution"
]
resources = [
"arn:${var.iam_partition}:states:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:stateMachine:*"
]
}
}
resource "aws_iam_role" "eventbridge_role" {
count = var.active ? 1 : 0
name = "${var.resource_prefix}eventbridge_role${var.resource_suffix}"
description = "IAM role for Amazon EventBridge to access AWS Step Functions."
assume_role_policy = data.aws_iam_policy_document.eventbridge_assume_role_policy.json
tags = var.standard_tags
}
resource "aws_iam_role_policy" "eventbridge_step_functions_policy" {
count = var.active ? 1 : 0
name = "step_functions"
role = aws_iam_role.eventbridge_role[0].id
policy = data.aws_iam_policy_document.eventbridge_step_functions_policy.json
}