Skip to content

Commit 8f23675

Browse files
authored
Merge pull request #379 from jdno/s3-log-notifications
Send S3 notifications in staging environment
2 parents 48ca4ff + 09d6ae9 commit 8f23675

File tree

7 files changed

+40
-11
lines changed

7 files changed

+40
-11
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"aws": {
33
"profile": "crates-io-staging",
4-
"region": "us-east-2"
4+
"region": "us-west-1"
55
}
66
}

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-logs/_terraform.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,3 @@ terraform {
88
}
99
}
1010
}
11-
12-
variable "bucket_account" {
13-
type = number
14-
description = "Account ID of the S3 bucket which will send events to the SQS queue"
15-
}
16-
17-
variable "bucket_arn" {
18-
type = string
19-
description = "ARN of the S3 bucket which will send events to the SQS queue"
20-
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# ARN of the SQS queue that receives S3 bucket notifications
2+
output "sqs_queue_arn" {
3+
value = aws_sqs_queue.cdn_log_event_queue.arn
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "bucket_account" {
2+
type = number
3+
description = "Account ID of the S3 bucket which will send events to the SQS queue"
4+
}
5+
6+
variable "bucket_arn" {
7+
type = string
8+
description = "ARN of the S3 bucket which will send events to the SQS queue"
9+
}

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)