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

Send S3 notifications in staging environment #379

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
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
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/"
}
}