Skip to content

Commit 9f15b3d

Browse files
rpoluriRaj Poluri
andauthored
Feature/s3 logs sqs (#175)
* manage logs sqs queue * update changelog * add tags to sns topics and sqs queues Co-authored-by: Raj Poluri <rpoluri@expediagroup.com>
1 parent 693e75c commit 9f15b3d

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6+
## [6.5.2] - 2020-09-08
7+
### Changed
8+
- Enable SQS events on managed logs bucket.
9+
610
## [6.5.1] - 2020-09-02
711
### Changed
812
- [Issue 165](https://github.com/ExpediaGroup/apiary-data-lake/issues/173) Configure metastore IAM roles using apiary bucket prefix.

s3-other.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ resource "aws_s3_bucket_public_access_block" "apiary_managed_logs_bucket" {
8888
ignore_public_acls = true
8989
}
9090

91+
resource "aws_s3_bucket_notification" "apiary_managed_logs_bucket" {
92+
count = local.enable_apiary_s3_log_management ? 1 : 0
93+
bucket = aws_s3_bucket.apiary_managed_logs_bucket[0].bucket
94+
95+
queue {
96+
queue_arn = aws_sqs_queue.apiary_managed_logs_queue[0].arn
97+
events = ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"]
98+
}
99+
}
100+
91101
resource "aws_s3_bucket" "apiary_access_logs_hive" {
92102
count = local.enable_apiary_s3_log_management ? 1 : 0
93103
bucket = local.apiary_s3_hive_logs_bucket

sns.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
resource "aws_sns_topic" "apiary_ops_sns" {
88
name = "${local.instance_alias}-operational-events"
9+
tags = var.apiary_tags
910
}
1011

1112
resource "aws_sns_topic" "apiary_metadata_events" {
1213
count = var.enable_metadata_events ? 1 : 0
1314
name = "${local.instance_alias}-metadata-events"
15+
tags = var.apiary_tags
1416

1517
policy = length(var.apiary_customer_accounts) == 0 ? null : <<POLICY
1618
{
@@ -33,6 +35,8 @@ resource "aws_sns_topic" "apiary_data_events" {
3335
} : {}
3436
name = "${local.instance_alias}-${each.value["resource_suffix"]}-data-events"
3537

38+
tags = var.apiary_tags
39+
3640
policy = <<POLICY
3741
{
3842
"Version":"2012-10-17",
@@ -52,6 +56,7 @@ POLICY
5256
resource "aws_sqs_queue" "apiary_data_event_queue" {
5357
count = local.create_sqs_data_event_queue ? 1 : 0
5458
name = "${local.instance_alias}-data-event-queue"
59+
tags = var.apiary_tags
5560

5661
policy = <<POLICY
5762
{
@@ -71,3 +76,25 @@ resource "aws_sqs_queue" "apiary_data_event_queue" {
7176
POLICY
7277
}
7378

79+
resource "aws_sqs_queue" "apiary_managed_logs_queue" {
80+
count = local.enable_apiary_s3_log_management ? 1 : 0
81+
name = "${local.instance_alias}-s3-logs-queue"
82+
tags = var.apiary_tags
83+
84+
policy = <<POLICY
85+
{
86+
"Version": "2012-10-17",
87+
"Statement": [
88+
{
89+
"Effect": "Allow",
90+
"Principal": { "Service": "s3.amazonaws.com" },
91+
"Action": "sqs:SendMessage",
92+
"Resource": "arn:aws:sqs:*:*:${local.instance_alias}-s3-logs-queue",
93+
"Condition":{
94+
"ArnEquals":{"aws:SourceArn":"arn:aws:s3:::${local.apiary_s3_logs_bucket}"}
95+
}
96+
}
97+
]
98+
}
99+
POLICY
100+
}

0 commit comments

Comments
 (0)