Skip to content

Commit 7897c3e

Browse files
authored
Merge pull request #8 from olhado/tagged-resources
Tagged resources
2 parents 52ef807 + af64ffa commit 7897c3e

File tree

7 files changed

+21
-5
lines changed

7 files changed

+21
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ module "threatstack_aws_integration" {
169169
sns_topic_display_name = string # Defaults to "Threat Stack integration topic."
170170
sqs_queue_name = string # Defaults to "ThreatStackIntegration"
171171
s3_bucket_name = string # Defaults to "threatstack-integration"
172-
s3_force_destroy = string # Defaults to "/"
172+
s3_bucket_prefix = string # Defaults to "/"
173+
tags = map # Defaults to {} (empty map)
173174
}
174175
175176
#...
@@ -191,6 +192,8 @@ module "threatstack_aws_integration" {
191192

192193
* ___aws_optional_conf.s3_bucket_prefix (optional):___ S3 prefix path for logs. Useful is using a bucket used by other services. (Not recommended)
193194

195+
* ___aws_optional_conf.tags(optional):___ Map of tags to apply to all resources.
196+
194197
##### Using existing cloudtrail infrastructure
195198

196199
If you already have your Cloudtrail set up, with its corresponding cloudwatch log group and S3 bucket, you can configure this module to use this infrastructure by setting the following settings. The module will still set up the SQS and SNS resources required, as well as the various IAM resources to allow for the integration to talk to Threat Stack's platform.

aws_cloudtrail.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ resource "aws_cloudwatch_log_group" "ct" {
1818
count = var.existing_cloudtrail != null ? 0 : 1 # Don't create this if using an existing cloudtrail
1919

2020
name = "/aws/cloudtrail/${var.aws_optional_conf.cloudtrail_name}"
21+
tags = var.aws_optional_conf.tags
2122

2223
depends_on = [
2324
aws_iam_role_policy.ct,
@@ -29,6 +30,8 @@ resource "aws_iam_role" "ct" {
2930
count = var.existing_cloudtrail != null ? 0 : 1 # Don't create this if using an existing cloudtrail
3031

3132
name = "${var.aws_optional_conf.cloudtrail_name}-CloudTrailToCloudWatch"
33+
tags = var.aws_optional_conf.tags
34+
3235
assume_role_policy = data.template_file.aws_iam_cloudtrail_to_cloudwatch_assume_role_policy.rendered
3336
}
3437

@@ -44,6 +47,8 @@ resource "aws_cloudtrail" "ct" {
4447
count = var.existing_cloudtrail != null ? 0 : 1 # Don't create this if using an existing cloudtrail
4548

4649
name = var.aws_optional_conf.cloudtrail_name
50+
tags = var.aws_optional_conf.tags
51+
4752
s3_bucket_name = aws_s3_bucket.bucket[0].id
4853
enable_logging = var.aws_flags.enable_logging
4954
enable_log_file_validation = var.aws_flags.enable_log_file_validation

aws_iam_role.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ data "template_file" "aws_iam_role_policy" {
2222

2323
resource "aws_iam_role" "role" {
2424
name = var.aws_optional_conf.iam_role_name
25+
tags = var.aws_optional_conf.tags
26+
2527
assume_role_policy = data.template_file.aws_iam_assume_role_policy.rendered
2628
}
2729

aws_s3_bucket.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ resource "aws_s3_bucket" "bucket" {
2222
enabled = "false"
2323
}
2424
force_destroy = var.aws_flags.s3_force_destroy
25-
tags = {
26-
terraform = "true"
27-
}
28-
depends_on = [aws_sns_topic_subscription.sqs]
25+
26+
tags = var.aws_optional_conf.tags
27+
28+
depends_on = [aws_sns_topic_subscription.sqs]
2929
}
3030

3131
resource "aws_s3_bucket_policy" "bucket" {

aws_sns_topic.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ data "template_file" "aws_sns_topic_policy" {
66

77
resource "aws_sns_topic" "sns" {
88
name = var.aws_optional_conf.sns_topic_name
9+
tags = var.aws_optional_conf.tags
10+
911
display_name = var.aws_optional_conf.sns_topic_display_name
1012
depends_on = [aws_iam_role.role]
1113
}

aws_sqs_queue.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ data "template_file" "aws_sqs_queue_policy" {
99

1010
resource "aws_sqs_queue" "sqs" {
1111
name = var.aws_optional_conf.sqs_queue_name
12+
tags = var.aws_optional_conf.tags
13+
1214
depends_on = [aws_sns_topic_policy.sns]
1315
}
1416

variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ variable "aws_optional_conf" {
8181
sqs_queue_name = string
8282
s3_bucket_name = string
8383
s3_bucket_prefix = string
84+
tags = map(string)
8485
})
8586

8687
default = {
@@ -91,5 +92,6 @@ variable "aws_optional_conf" {
9192
sqs_queue_name = "ThreatStackIntegration"
9293
s3_bucket_name = "threatstack-integration"
9394
s3_bucket_prefix = "/"
95+
tags = {}
9496
}
9597
}

0 commit comments

Comments
 (0)