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

allow bucket object listing #305

Merged
merged 2 commits into from
Nov 11, 2023
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
93 changes: 53 additions & 40 deletions terraform-iam/archeologist.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,66 @@ resource "aws_s3_bucket" "archeologist" {
bucket = "nix-archeologist"
}

data "aws_iam_policy_document" "archaeologist" {
statement {
# Read-only access and listing permissions
# To the cache and releases inventories,
# as well as the bucket where cache bucket logs end up in.
sid = "NixCacheLogsInventoryReadOnly"

actions = [
"s3:List*",
"s3:Get*"
]

resources = [
"arn:aws:s3:::nix-cache-inventory",
"arn:aws:s3:::nix-cache-inventory/*",
"arn:aws:s3:::nix-cache-log",
"arn:aws:s3:::nix-cache-log/*",
"arn:aws:s3:::nix-releases-inventory220231029182031496800000001",
"arn:aws:s3:::nix-releases-inventory220231029182031496800000001/*"
]
}

statement {
sid = "NixCacheLogsReadOnly"

actions = [
"s3:Get*"
]

resources = [
"arn:aws:s3:::nix-cache-log",
"arn:aws:s3:::nix-cache-log/*",
"arn:aws:s3:::nix-releases-inventory220231029182031496800000001",
"arn:aws:s3:::nix-releases-inventory220231029182031496800000001/*",
]
}

statement {
# Full access to the Archaeologist bucket
sid = "NixArchaeologistReadWrite"

actions = [
"s3:*"
]

resources = [
aws_s3_bucket.archeologist.arn,
"${aws_s3_bucket.archeologist.arn}/*"
]
}
}

# This is the role that is given to the AWS Identity Center users
resource "aws_iam_policy" "archologist" {
provider = aws.us

name = "archeologist"
description = "used by the S3 archeologists"

policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "NixCacheInventoryReadOnly",
"Effect": "Allow",
"Action": [
"s3:Get*"
],
"Resource": [
"arn:aws:s3:::nix-cache-inventory",
"arn:aws:s3:::nix-cache-inventory/*",
"arn:aws:s3:::nix-releases-inventory220231029182031496800000001",
"arn:aws:s3:::nix-releases-inventory220231029182031496800000001/*"
]
},
{
"Sid": "NixCacheLogsReadOnly",
"Effect": "Allow",
"Action": [
"s3:Get*"
],
"Resource": [
"arn:aws:s3:::nix-cache-log",
"arn:aws:s3:::nix-cache-log/*"
]
},
{
"Sid": "NixArcheologistReadWrite",
"Effect": "Allow",
"Action": [ "s3:*" ],
"Resource": [
"${aws_s3_bucket.archeologist.arn}",
"${aws_s3_bucket.archeologist.arn}/*"
]
}
]
}
EOF
policy = data.aws_iam_policy_document.archaeologist.json
}

# Prepare this role to be attached to the EC2 instance
Expand Down