Skip to content

Commit

Permalink
Merge pull request #413 from jdno/downloads-archive-s3
Browse files Browse the repository at this point in the history
Create bucket to store downloads statistics
  • Loading branch information
jdno authored Jun 6, 2024
2 parents 828f8c1 + cbc9bfc commit c40794e
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 1 deletion.
4 changes: 4 additions & 0 deletions terragrunt/accounts/crates-io-prod/account.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"regions": [
{
"region": "us-west-1"
},
{
"region": "us-east-1",
"alias": "us-east-1"
}
]
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
source = "../../../..//terragrunt/modules/crates-io-downloads-archive"
}

include {
path = find_in_parent_folders()
merge_strategy = "deep"
}

inputs = {
downloads_archive_bucket_name = "crates-io-downloads-archive"
}
2 changes: 1 addition & 1 deletion terragrunt/accounts/crates-io-prod/deployed-ref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e081d07d9a9d2b6ae8db617275d0b626292ce5dc
555f7ecaaf8662f018b35ec81681cf0260bdb04f

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
source = "../../../..//terragrunt/modules/crates-io-downloads-archive"
}

include {
path = find_in_parent_folders()
merge_strategy = "deep"
}

inputs = {
downloads_archive_bucket_name = "staging-crates-io-downloads-archive"
}
12 changes: 12 additions & 0 deletions terragrunt/modules/crates-io-downloads-archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Archived Download Statistics for crates.io

This module creates the infrastructure that is used to archive download
statistics from [crates.io] for longer than 90 days. Currently, that is a single
S3 bucket that stores CSV files with daily download counts. A new bucket has
been created for this purpose, as the existing buckets for [crates.io] are
publicly accessible.

See [rust-lang/crates.io#3479] for details.

[crates.io]: https://crates.io
[rust-lang/crates.io#3479]: https://github.com/rust-lang/crates.io/issues/3479
10 changes: 10 additions & 0 deletions terragrunt/modules/crates-io-downloads-archive/_terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = "~> 1"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.32"
}
}
}
28 changes: 28 additions & 0 deletions terragrunt/modules/crates-io-downloads-archive/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
resource "aws_s3_bucket" "downloads_archive" {
provider = aws.us-east-1

bucket = var.downloads_archive_bucket_name
}

data "aws_iam_user" "heroku_access" {
user_name = "crates-io-heroku-access"
}

resource "aws_iam_user_policy" "downloads_archive_write" {
name = "downloads-archive-write"
user = data.aws_iam_user.heroku_access.user_name
policy = data.aws_iam_policy_document.downloads_archive_write.json
}

data "aws_iam_policy_document" "downloads_archive_write" {
statement {
sid = "WriteToDownloadsArchive"
effect = "Allow"

actions = [
"s3:PutObject",
]

resources = ["${aws_s3_bucket.downloads_archive.arn}/*"]
}
}
4 changes: 4 additions & 0 deletions terragrunt/modules/crates-io-downloads-archive/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
variable "downloads_archive_bucket_name" {
description = "The name of the S3 bucket to store the downloads archive"
type = string
}

0 comments on commit c40794e

Please sign in to comment.