This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
generated from ministryofjustice/ap-terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol_panel_role.tf
50 lines (42 loc) · 1.75 KB
/
control_panel_role.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
###############################################################################
# Control panel EKS role
#
# This is the role that the control panel is associated with via IRSA. It's only
# purpose is to permit the the control panel to assume operation specific roles
# in the data account and the application cluster account.
###############################################################################
module "control_panel_role" {
source = "github.com/ministryofjustice/ap-terraform-iam-roles.git//eks-role?ref=v1.4.1"
role_name_prefix = "ControlPanelFederatedID"
role_description = "Role to identify the control panel for ${var.resource_prefix}"
provider_url = var.provider_url
role_policy_arns = [aws_iam_policy.allow_sts_policy.arn]
cluster_service_accounts = [var.control_panel_service_account]
tags = var.tags
providers = {
aws = aws.control_panel_account
}
}
###############################################################################
# Control panel EKS role policy
#
# This policy permits attempting to assume the data account and app account
# management roles.
###############################################################################
resource "aws_iam_policy" "allow_sts_policy" {
name_prefix = "AllowSTSControlPanel"
description = "Permit control panel for ${var.resource_prefix} to assume other roles"
policy = data.aws_iam_policy_document.allow_sts_policy.json
tags = var.tags
provider = aws.control_panel_account
}
data "aws_iam_policy_document" "allow_sts_policy" {
statement {
actions = ["sts:AssumeRole"]
resources = [
module.app_account_role.iam_role_arn,
module.data_account_role.iam_role_arn
]
effect = "Allow"
}
}