Skip to content

Commit 7ce8872

Browse files
committed
Grant crates.io access to CDN logs
We are working on using the logs from our CDNs to count crate downloads on crates.io. Whenever a log archive is uploaded to the bucket, a notification is sent to an SQS queue. crates.io then downloads the log, parses it, and updates the download counts. For this to work, crates.io needs access to the S3 bucket with the logs. This change grants read-only access to individual log archives. See #372 for details.
1 parent 8f23675 commit 7ce8872

File tree

1 file changed

+26
-0
lines changed
  • terragrunt/modules/crates-io

1 file changed

+26
-0
lines changed

terragrunt/modules/crates-io/iam.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,32 @@ resource "aws_iam_user_policy_attachment" "heroku_static_write" {
7070
policy_arn = aws_iam_policy.static_write.arn
7171
}
7272

73+
resource "aws_iam_policy" "cdn_logs_read" {
74+
name = "${var.iam_prefix}--cdn-logs-read"
75+
description = "Read access to the S3 bucket with CDN logs"
76+
77+
policy = jsonencode({
78+
Version = "2012-10-17"
79+
Statement = [
80+
{
81+
Sid = "CDNLogsRead"
82+
Effect = "Allow"
83+
Action = [
84+
"s3:GetObject",
85+
]
86+
Resource = [
87+
"${aws_s3_bucket.logs.arn}/*",
88+
]
89+
}
90+
]
91+
})
92+
}
93+
94+
resource "aws_iam_user_policy_attachment" "heroku_cdn_logs_read" {
95+
user = aws_iam_user.heroku.name
96+
policy_arn = aws_iam_policy.cdn_logs_read.arn
97+
}
98+
7399
resource "aws_iam_role" "s3_replication" {
74100
name = "${var.iam_prefix}--s3-replication"
75101

0 commit comments

Comments
 (0)