diff --git a/cloudtrail.tf b/cloudtrail.tf index 0d4180f..1e03e03 100644 --- a/cloudtrail.tf +++ b/cloudtrail.tf @@ -5,4 +5,5 @@ resource "aws_cloudtrail" "global_Default" { is_multi_region_trail = true include_global_service_events = true enable_log_file_validation = true + tags = "${merge(var.tags, map(var.name_tag_name, format("%s", var.trail_name)))}" } diff --git a/s3_cloudtrail.tf b/s3_cloudtrail.tf index bc564e6..ecc9915 100644 --- a/s3_cloudtrail.tf +++ b/s3_cloudtrail.tf @@ -2,7 +2,7 @@ resource "aws_s3_bucket" "cloudtrail_bucket" { bucket = "${local.bucket_name}" acl = "private" count = "${var.trail_bucketname_create}" - + server_side_encryption_configuration { rule { apply_server_side_encryption_by_default { @@ -11,6 +11,8 @@ resource "aws_s3_bucket" "cloudtrail_bucket" { } } } + + tags = "${merge(var.tags, map(var.name_tag_name, format("%s", local.bucket_name)))}" } resource "aws_s3_bucket_policy" "cloudtrail_bucket_policy" { diff --git a/variables.tf b/variables.tf index 53d1216..f6f9b16 100644 --- a/variables.tf +++ b/variables.tf @@ -53,4 +53,15 @@ variable "trail_bucket_default_encryption" { variable "trail_bucket_default_encryption_key" { description = "Defines if the KMS encryption key, used if trail_bucket_default_encryption is set to aws:kms" default = "" -} \ No newline at end of file +} + +variable "tags" { + description = "A map of tags to add to all resources" + default = {} + type = "map" +} + +variable "name_tag_name" { + description = "Name of the 'name' tag that is added to, for example, the S3 resources" + default = "Name" +}