Skip to content

Commit e2cc2ef

Browse files
committed
bufstream demo
1 parent b595442 commit e2cc2ef

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

bufstream-shared-bucket.tf

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Shared Bufstream bucket accessible from all namespaces in the EKS cluster
2+
# Since all Kubernetes namespaces run on nodes that use the same node role,
3+
# attaching the policy to the node role gives access from all namespaces
4+
5+
# AWS S3 bucket for shared bufstream access
6+
resource "aws_s3_bucket" "bufstream_shared" {
7+
bucket = "${var.namespace}-bufstream-sa-demo"
8+
force_destroy = false
9+
10+
tags = {
11+
Namespace = var.namespace
12+
Role = "bufstream-shared-bucket"
13+
}
14+
}
15+
16+
# IAM Policy for S3 bucket access
17+
resource "aws_iam_policy" "bufstream_shared" {
18+
name = "${var.namespace}-bufstream-sa-demo-policy"
19+
description = "Policy for access to shared bufstream bucket from all namespaces"
20+
21+
policy = jsonencode({
22+
Version = "2012-10-17"
23+
Statement = [
24+
{
25+
Sid = "AllowAllS3ActionsOnSharedBufstreamBucket"
26+
Effect = "Allow"
27+
Action = [
28+
"s3:*"
29+
]
30+
Resource = [
31+
aws_s3_bucket.bufstream_shared.arn,
32+
"${aws_s3_bucket.bufstream_shared.arn}/*"
33+
]
34+
}
35+
]
36+
})
37+
38+
tags = {
39+
Namespace = var.namespace
40+
}
41+
}
42+
43+
# Attach policy to the node role (used by all pods across all namespaces)
44+
resource "aws_iam_role_policy_attachment" "bufstream_shared" {
45+
role = module.app_eks.node_role.name
46+
policy_arn = aws_iam_policy.bufstream_shared.arn
47+
}
48+
49+
# Outputs
50+
output "bufstream_shared_bucket" {
51+
description = "Shared bufstream S3 bucket"
52+
value = {
53+
id = aws_s3_bucket.bufstream_shared.id
54+
arn = aws_s3_bucket.bufstream_shared.arn
55+
bucket = aws_s3_bucket.bufstream_shared.bucket
56+
policy_arn = aws_iam_policy.bufstream_shared.arn
57+
}
58+
}

data.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ data "aws_sqs_queue" "file_storage" {
1010
}
1111

1212
data "aws_region" "current" {}
13+
14+
data "aws_caller_identity" "current" {}

0 commit comments

Comments
 (0)