Skip to content

Commit 48d4a08

Browse files
committed
feat: add service accounts, roles individual policies
1 parent f036df3 commit 48d4a08

File tree

8 files changed

+539
-54
lines changed

8 files changed

+539
-54
lines changed

main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ module "eks" {
180180
k8s_public_access_cidrs = var.k8s_public_access_cidrs
181181

182182
k8s_access_bedrock = var.k8s_access_bedrock
183-
bedrock_model_arn = var.bedrock_model_arn
184183
}
185184

186185
locals {

modules/eks/iam.tf

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,3 @@ resource "aws_iam_role_policy_attachment" "node_autoscaling" {
2929
policy_arn = aws_iam_policy.node_autoscaling.arn
3030
role = each.value.iam_role_name
3131
}
32-
33-
resource "aws_iam_policy" "bedrock_access_policy" {
34-
count = var.k8s_access_bedrock ? 1 : 0
35-
36-
name = "${var.deployment_name}-bedrock"
37-
description = "${var.deployment_name} bedrock access policy"
38-
39-
policy = jsonencode({
40-
Version = "2012-10-17"
41-
Statement = [
42-
{
43-
Action = [
44-
"bedrock:InvokeModel",
45-
]
46-
Effect = "Allow"
47-
Resource = var.bedrock_model_arn
48-
},
49-
]
50-
})
51-
52-
tags = var.tags
53-
}
54-

modules/eks/main.tf

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,6 @@ module "cluster_autoscaler_role" {
4343
}
4444
}
4545

46-
module "bedrock_invoker_role" {
47-
count = var.k8s_access_bedrock ? 1 : 0
48-
49-
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
50-
role_name = "${var.deployment_name}-bedrock-invoke-model"
51-
52-
role_policy_arns = {
53-
policy = aws_iam_policy.bedrock_access_policy[0].arn
54-
}
55-
56-
oidc_providers = {
57-
ex = {
58-
provider_arn = module.eks.oidc_provider_arn
59-
namespace_service_accounts = ["${var.deployment_name}:bedrock-invoke-model"]
60-
}
61-
}
62-
}
63-
6446
module "eks" {
6547
# https://github.com/terraform-aws-modules/terraform-aws-eks/tree/master/docs
6648

modules/eks/outputs.tf

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,124 @@ output "control_plane_security_group_id" {
1616

1717
output "cluster_endpoint" {
1818
value = module.eks.cluster_endpoint
19+
}
20+
21+
# dfshell
22+
output "dfshell_role_arn" {
23+
value = module.dfshell_role[0].iam_role_arn
24+
description = "The ARN of the AWS Bedrock role"
25+
}
26+
output "dfshell_service_account_name" {
27+
value = var.dfshell_service_account_name
28+
description = "The name of the service account for dfshell"
29+
}
30+
31+
# worker_portal
32+
output "worker_portal_role_arn" {
33+
value = module.worker_portal_role[0].iam_role_arn
34+
description = "The ARN of the AWS Bedrock role"
35+
}
36+
output "worker_portal_service_account_name" {
37+
value = var.worker_portal_service_account_name
38+
description = "The name of the service account for worker_portal"
39+
}
40+
41+
# operator
42+
output "operator_role_arn" {
43+
value = module.operator_role[0].iam_role_arn
44+
description = "The ARN of the AWS Bedrock role"
45+
}
46+
output "operator_service_account_name" {
47+
value = var.operator_service_account_name
48+
description = "The name of the service account for operator"
49+
}
50+
51+
# server
52+
output "server_role_arn" {
53+
value = module.server_role[0].iam_role_arn
54+
description = "The ARN of the AWS Bedrock role"
55+
}
56+
output "server_service_account_name" {
57+
value = var.server_service_account_name
58+
description = "The name of the service account for server"
59+
}
60+
61+
# scheduler
62+
output "scheduler_role_arn" {
63+
value = module.scheduler_role[0].iam_role_arn
64+
description = "The ARN of the AWS Bedrock role"
65+
}
66+
output "scheduler_service_account_name" {
67+
value = var.scheduler_service_account_name
68+
description = "The name of the service account for scheduler"
69+
}
70+
71+
# worker, worker1, worker2 etc.
72+
output "worker_role_arn" {
73+
value = module.worker_role[0].iam_role_arn
74+
description = "The ARN of the AWS Bedrock role"
75+
}
76+
output "worker_service_account_name" {
77+
value = var.worker_service_account_name
78+
description = "The name of the service account for worker"
79+
}
80+
81+
# worker_catalog
82+
output "worker_catalog_role_arn" {
83+
value = module.worker_catalog_role[0].iam_role_arn
84+
description = "The ARN of the AWS Bedrock role"
85+
}
86+
output "worker_catalog_service_account_name" {
87+
value = var.worker_catalog_service_account_name
88+
description = "The name of the service account for worker_catalog"
89+
}
90+
91+
# worker_interactive
92+
output "worker_interactive_role_arn" {
93+
value = module.worker_interactive_role[0].iam_role_arn
94+
description = "The ARN of the AWS Bedrock role"
95+
}
96+
output "worker_interactive_service_account_name" {
97+
value = var.worker_interactive_service_account_name
98+
description = "The name of the service account for worker_interactive"
99+
}
100+
101+
# worker_singletons
102+
output "worker_singletons_role_arn" {
103+
value = module.worker_singletons_role[0].iam_role_arn
104+
description = "The ARN of the AWS Bedrock role"
105+
}
106+
output "worker_singletons_service_account_name" {
107+
value = var.worker_singletons_service_account_name
108+
description = "The name of the service account for worker_singletons"
109+
}
110+
111+
# worker_lineage
112+
output "worker_lineage_role_arn" {
113+
value = module.worker_lineage_role[0].iam_role_arn
114+
description = "The ARN of the AWS Bedrock role"
115+
}
116+
output "worker_lineage_service_account_name" {
117+
value = var.worker_lineage_service_account_name
118+
description = "The name of the service account for worker_lineage"
119+
}
120+
121+
# worker_monitor
122+
output "worker_monitor_role_arn" {
123+
value = module.worker_monitor_role[0].iam_role_arn
124+
description = "The ARN of the AWS Bedrock role"
125+
}
126+
output "worker_monitor_service_account_name" {
127+
value = var.worker_monitor_service_account_name
128+
description = "The name of the service account for worker_monitor"
129+
}
130+
131+
# storage_worker
132+
output "storage_worker_role_arn" {
133+
value = module.storage_worker_role[0].iam_role_arn
134+
description = "The ARN of the AWS Bedrock role"
135+
}
136+
output "storage_worker_service_account_name" {
137+
value = var.storage_worker_service_account_name
138+
description = "The name of the service account for storage_worker"
19139
}

0 commit comments

Comments
 (0)