Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use user policies to grant read access across buckets #30

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions gfts-track-reconstruction/jupyterhub/tofu/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ locals {
region = "GRA11"
s3_region = "gra"
s3_endpoint = "s3.gra.perf.cloud.ovh.net"
s3_buckets = toset([
"gfts-ifremer",
"gfts-reference-data",
"destine-gfts-data-lake",
])
s3_users = toset([
"annefou",
"todaka",
Expand Down Expand Up @@ -124,7 +129,7 @@ resource "ovh_cloud_project_user_s3_credential" "s3_users" {
# this is another way to grant s3 super-user
# instead, use ACLs below
resource "ovh_cloud_project_user_s3_policy" "s3_admins" {
for_each = toset([]) # local.s3_admins
for_each = local.s3_admins
service_name = local.service_name
user_id = ovh_cloud_project_user.s3_users[each.key].id
policy = jsonencode({
Expand All @@ -139,25 +144,36 @@ resource "ovh_cloud_project_user_s3_policy" "s3_admins" {
"s3:AbortMultipartUpload", "s3:GetBucketLocation",
],
"Resource" : [
# "arn:aws:s3:::${aws_s3_bucket.gfts-data-lake.id}",
# "arn:aws:s3:::${aws_s3_bucket.gfts-data-lake.id}/*",
"arn:aws:s3:::*",
]
},
# {
# "Sid" : "deny-create-bucket",
# "Effect" : "Deny",
# "Action" : [
# "s3:CreateBucket",
# ],
# "Resource" : [
# "arn:aws:s3:::*",
# ]
# },
]
})
}

resource "ovh_cloud_project_user_s3_policy" "s3_users" {
for_each = local.s3_users
service_name = local.service_name
user_id = ovh_cloud_project_user.s3_users[each.key].id
policy = jsonencode({
"Statement" : [
{
"Sid" : "read",
"Effect" : "Allow",
"Action" : [
"s3:GetObject", "s3:ListBucket", "s3:GetBucketLocation",
],
"Resource" : [
"arn:aws:s3:::${aws_s3_bucket.gfts-data-lake.id}/*",
"arn:aws:s3:::${aws_s3_bucket.gfts-ifremer.id}/*",
"arn:aws:s3:::${aws_s3_bucket.gfts-reference-data.id}/*",
]
},
]
})
}


data "aws_canonical_user_id" "current" {}


Expand Down