Skip to content

Commit

Permalink
Merge pull request rust-lang#379 from jdno/s3-log-notifications
Browse files Browse the repository at this point in the history
Send S3 notifications in staging environment
  • Loading branch information
jdno authored Jan 17, 2024
2 parents 48ca4ff + 09d6ae9 commit 8f23675
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 11 deletions.
2 changes: 1 addition & 1 deletion terragrunt/accounts/crates-io-staging/account.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"aws": {
"profile": "crates-io-staging",
"region": "us-east-2"
"region": "us-west-1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ inputs = {
static_fastly_weight = 100

fastly_customer_id_ssm_parameter = "/staging/crates-io/fastly/customer-id"

cdn_log_event_queue_arn = "arn:aws:sqs:us-west-1:359172468976:cdn-log-event-queue"
}
10 changes: 0 additions & 10 deletions terragrunt/modules/crates-io-logs/_terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,3 @@ terraform {
}
}
}

variable "bucket_account" {
type = number
description = "Account ID of the S3 bucket which will send events to the SQS queue"
}

variable "bucket_arn" {
type = string
description = "ARN of the S3 bucket which will send events to the SQS queue"
}
4 changes: 4 additions & 0 deletions terragrunt/modules/crates-io-logs/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ARN of the SQS queue that receives S3 bucket notifications
output "sqs_queue_arn" {
value = aws_sqs_queue.cdn_log_event_queue.arn
}
9 changes: 9 additions & 0 deletions terragrunt/modules/crates-io-logs/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "bucket_account" {
type = number
description = "Account ID of the S3 bucket which will send events to the SQS queue"
}

variable "bucket_arn" {
type = string
description = "ARN of the S3 bucket which will send events to the SQS queue"
}
6 changes: 6 additions & 0 deletions terragrunt/modules/crates-io/_terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ variable "fastly_aws_account_id" {
description = "The AWS account ID that Fastly uses to write logs"
default = "717331877981"
}

variable "cdn_log_event_queue_arn" {
# See the `crates-io-logs` module
description = "ARN of the SQS queue that receives S3 notifications for CDN logs"
type = string
}
18 changes: 18 additions & 0 deletions terragrunt/modules/crates-io/s3-logs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ resource "aws_s3_bucket_public_access_block" "logs" {
ignore_public_acls = true
restrict_public_buckets = true
}

resource "aws_s3_bucket_notification" "cdn_log_event_queue" {
bucket = aws_s3_bucket.logs.id

queue {
id = "cloudfront"
events = ["s3:ObjectCreated:*"]
queue_arn = var.cdn_log_event_queue_arn
filter_prefix = "cloudfront/"
}

queue {
id = "fastly"
events = ["s3:ObjectCreated:*"]
queue_arn = var.cdn_log_event_queue_arn
filter_prefix = "fastly-requests/"
}
}

0 comments on commit 8f23675

Please sign in to comment.