Skip to content

Commit 30afce5

Browse files
committed
Send S3 notifications in staging environment
The S3 bucket with the CDN logs for crates.io now sends S3 notifications to an SQS queue. This enables crates.io to start counting downloads in the background and not as part of the request-response cycle.
1 parent a440669 commit 30afce5

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

terragrunt/accounts/legacy/crates-io-staging/crates-io/terragrunt.hcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ inputs = {
2727
static_fastly_weight = 100
2828

2929
fastly_customer_id_ssm_parameter = "/staging/crates-io/fastly/customer-id"
30+
31+
cdn_log_event_queue_arn = "arn:aws:sqs:us-west-1:359172468976:cdn-log-event-queue"
3032
}

terragrunt/modules/crates-io/_terraform.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,9 @@ variable "fastly_aws_account_id" {
102102
description = "The AWS account ID that Fastly uses to write logs"
103103
default = "717331877981"
104104
}
105+
106+
variable "cdn_log_event_queue_arn" {
107+
# See the `crates-io-logs` module
108+
description = "ARN of the SQS queue that receives S3 notifications for CDN logs"
109+
type = string
110+
}

terragrunt/modules/crates-io/s3-logs.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,21 @@ resource "aws_s3_bucket_public_access_block" "logs" {
2525
ignore_public_acls = true
2626
restrict_public_buckets = true
2727
}
28+
29+
resource "aws_s3_bucket_notification" "cdn_log_event_queue" {
30+
bucket = aws_s3_bucket.logs.id
31+
32+
queue {
33+
id = "cloudfront"
34+
events = ["s3:ObjectCreated:*"]
35+
queue_arn = var.cdn_log_event_queue_arn
36+
filter_prefix = "cloudfront/"
37+
}
38+
39+
queue {
40+
id = "fastly"
41+
events = ["s3:ObjectCreated:*"]
42+
queue_arn = var.cdn_log_event_queue_arn
43+
filter_prefix = "fastly-requests/"
44+
}
45+
}

0 commit comments

Comments
 (0)