generated from makandra/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a6cb74
commit fa7defe
Showing
13 changed files
with
151 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
SELECT * FROM cloudfront.cloudfront_logs | ||
WHERE host='https://$CLOUDFRONT_NAME.cloudfront.net' | ||
WHERE host='$DISTRIBUTION_DOMAIN_NAME' -- without protocol, e.g. a1a1aaaaaa1a1a.cloudfront.net | ||
-- AND "date" BETWEEN DATE '2023-08-10' AND DATE '2023-08-11' --date is a reserved word and needs to be doublequoted | ||
-- AND status=200 | ||
-- AND ssl_protocol=TLSv1.2 | ||
-- AND ssl_protocol='TLSv1.2' | ||
LIMIT 100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
select useridentity.username, sourceipaddress, eventtime, additionaleventdata | ||
select useridentity, sourceipaddress, eventtime, additionaleventdata | ||
from cloudtrail.cloudtrail_logs | ||
where eventname = 'ConsoleLogin' | ||
order by date(from_iso8601_timestamp(eventtime)) desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
queries/ses_bounce_ratio.sql.tftpl → ...es_daily_bounced_and_send_mails.sql.tftpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
select bounces.date, bounces, send, ((bounces * 1.0)/(send * 1.0) * 100 ) as "% bounces" | ||
select bounces.date, bounces, send | ||
from | ||
( select | ||
date(from_iso8601_timestamp(mail.timestamp)) as date, count(*) as bounces from ses.ses_bounce_logs where eventtype='Bounce'and bounce.bouncedrecipients[1].diagnosticcode not like '%Amazon SES did not send the message to this address%' | ||
date(from_iso8601_timestamp(mail.timestamp)) as date, count(*) as bounces from ses.ses_logs where eventtype='Bounce'and bounce.bouncedrecipients[1].diagnosticcode not like '%Amazon SES did not send the message to this address%' | ||
GROUP BY date(from_iso8601_timestamp(mail.timestamp)) order by date(from_iso8601_timestamp(mail.timestamp)) desc) bounces | ||
|
||
inner join | ||
( select | ||
date(from_iso8601_timestamp(mail.timestamp)) as date, count(*) as send from ses.ses_bounce_logs where eventtype='Send' | ||
date(from_iso8601_timestamp(mail.timestamp)) as date, count(*) as send from ses.ses_logs where eventtype='Send' | ||
GROUP BY date(from_iso8601_timestamp(mail.timestamp)) order by date(from_iso8601_timestamp(mail.timestamp)) desc) send | ||
ON | ||
bounces.date = send.date | ||
bounces.date = send.date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
select | ||
date(from_iso8601_timestamp(mail.timestamp)) as date, count(*) as bounces from ses.ses_bounce_logs where eventtype='Bounce'and bounce.bouncedrecipients[1].diagnosticcode not like '%Amazon SES did not send the message to this address%' | ||
date(from_iso8601_timestamp(mail.timestamp)) as date, count(*) as bounces from ses.ses_logs where eventtype='Bounce'and bounce.bouncedrecipients[1].diagnosticcode not like '%Amazon SES did not send the message to this address%' | ||
GROUP BY date(from_iso8601_timestamp(mail.timestamp)) order by date(from_iso8601_timestamp(mail.timestamp)) desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
select mail.timestamp, mail.source, mail.destination, bounce.bouncedrecipients[1].diagnosticcode as diagnosticcode from ses.ses_bounce_logs | ||
select mail.timestamp, mail.source, mail.destination, bounce.bouncedrecipients[1].diagnosticcode as diagnosticcode from ses.ses_logs | ||
-- where eventtype='Bounce' -- or any other event type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
mock_provider "aws" {} | ||
|
||
run "dont_create_resources_without_input" { | ||
variables { | ||
query_bucket_name = "test" | ||
} | ||
assert { | ||
condition = length(local.named_queries.cloudfront) == 0 | ||
error_message = "local.named_queries.cloudfront should have 0 elements, but has ${length(local.named_queries.cloudfront)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_database.cloudfront) == 0 | ||
error_message = "aws_athena_database.cloudfront should have 0 instances, but has ${length(aws_athena_database.cloudfront)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_named_query.cloudfront) == 0 | ||
error_message = "aws_athena_named_query.cloudfront should have 0 instances, but has ${length(aws_athena_database.cloudfront)}" | ||
} | ||
} | ||
|
||
run "create_resources_with_correct_input" { | ||
variables { | ||
query_bucket_name = "test" | ||
cloudfront = "cloudfront-bucket" | ||
} | ||
|
||
assert { | ||
condition = length(local.named_queries.cloudfront) != 0 | ||
error_message = "local.named_queries.cloudfront should not have 0 elements" | ||
} | ||
assert { | ||
condition = length(aws_athena_database.cloudfront) == 1 | ||
error_message = "aws_athena_database.cloudfront should have 1 instance, but has ${length(aws_athena_database.cloudfront)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_named_query.cloudfront) != 0 | ||
error_message = "aws_athena_named_query.cloudfront should not have 0 element" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
mock_provider "aws" {} | ||
|
||
run "dont_create_resources_without_input" { | ||
variables { | ||
query_bucket_name = "test" | ||
} | ||
assert { | ||
condition = length(local.named_queries.cloudtrail) == 0 | ||
error_message = "local.named_queries.cloudtrail should have 0 elements, but has ${length(local.named_queries.cloudtrail)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_database.cloudtrail) == 0 | ||
error_message = "aws_athena_database.cloudtrail should have 0 instances, but has ${length(aws_athena_database.cloudtrail)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_named_query.cloudtrail) == 0 | ||
error_message = "aws_athena_named_query.cloudtrail should have 0 instances, but has ${length(aws_athena_database.cloudtrail)}" | ||
} | ||
} | ||
|
||
run "create_resources_with_correct_input" { | ||
variables { | ||
query_bucket_name = "test" | ||
cloudtrail = { | ||
bucket_name = "cloudtrail-bucket" | ||
} | ||
} | ||
|
||
assert { | ||
condition = length(local.named_queries.cloudtrail) != 0 | ||
error_message = "local.named_queries.cloudtrail should not have 0 elements" | ||
} | ||
assert { | ||
condition = length(aws_athena_database.cloudtrail) == 1 | ||
error_message = "aws_athena_database.cloudtrail should have 1 instance, but has ${length(aws_athena_database.cloudtrail)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_named_query.cloudtrail) != 0 | ||
error_message = "aws_athena_named_query.cloudtrail should not have 0 element" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
mock_provider "aws" {} | ||
|
||
run "dont_create_resources_without_input" { | ||
variables { | ||
query_bucket_name = "test" | ||
} | ||
assert { | ||
condition = length(local.named_queries.ses) == 0 | ||
error_message = "local.named_queries.ses should have 0 elements, but has ${length(local.named_queries.ses)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_database.ses) == 0 | ||
error_message = "aws_athena_database.ses should have 0 instances, but has ${length(aws_athena_database.ses)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_named_query.ses) == 0 | ||
error_message = "aws_athena_named_query.ses should have 0 instances, but has ${length(aws_athena_database.ses)}" | ||
} | ||
} | ||
|
||
run "create_resources_with_correct_input" { | ||
variables { | ||
query_bucket_name = "test" | ||
ses = "ses-bucket" | ||
} | ||
|
||
assert { | ||
condition = length(local.named_queries.ses) != 0 | ||
error_message = "local.named_queries.ses should not have 0 elements" | ||
} | ||
assert { | ||
condition = length(aws_athena_database.ses) == 1 | ||
error_message = "aws_athena_database.ses should have 1 instance, but has ${length(aws_athena_database.ses)}" | ||
} | ||
assert { | ||
condition = length(aws_athena_named_query.ses) != 0 | ||
error_message = "aws_athena_named_query.ses should not have 0 element" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
terraform { | ||
required_version = ">= 1.7.0" | ||
required_version = ">= 1.6.0" | ||
required_providers { | ||
aws = { | ||
version = ">= 5.40.0" | ||
version = ">= 4.55.0" | ||
} | ||
} | ||
} |