diff --git a/s3.tf b/s3.tf index 584f512..561a228 100644 --- a/s3.tf +++ b/s3.tf @@ -1,16 +1,17 @@ module "s3" { source = "dasmeta/s3/aws" - version = "1.2.2" + version = "1.2.3" - name = var.domain - acl = var.s3_configs.acl - create_index_html = var.s3_configs.create_index_html - ignore_public_acls = var.s3_configs.ignore_public_acls - restrict_public_buckets = var.s3_configs.restrict_public_buckets - block_public_acls = var.s3_configs.block_public_acls - block_public_policy = var.s3_configs.block_public_policy - versioning = var.s3_configs.versioning - website = var.s3_configs.website - create_iam_user = var.s3_configs.create_iam_user - cors_rule = var.s3_configs.cors_rule + name = var.domain + acl = var.s3_configs.acl + create_index_html = var.s3_configs.create_index_html + ignore_public_acls = var.s3_configs.ignore_public_acls + restrict_public_buckets = var.s3_configs.restrict_public_buckets + block_public_acls = var.s3_configs.block_public_acls + block_public_policy = var.s3_configs.block_public_policy + versioning = var.s3_configs.versioning + website = var.s3_configs.website + create_iam_user = var.s3_configs.create_iam_user + cors_rule = var.s3_configs.cors_rule + event_notification_config = var.s3_configs.event_notification_config } diff --git a/tests/s3-configed/1-example.tf b/tests/s3-configed/1-example.tf index c697c0a..391b613 100644 --- a/tests/s3-configed/1-example.tf +++ b/tests/s3-configed/1-example.tf @@ -9,12 +9,18 @@ module "this" { s3_configs = { cors_rule = [ { - allowed_methods = ["HEAD","GET","PUT", "POST"] + allowed_methods = ["HEAD", "GET", "PUT", "POST"] allowed_origins = ["https://modules.tf", "https://dasmeta.modules.tf"] allowed_headers = ["*"] - expose_headers = ["ETag","Access-Control-Allow-Origin"] + expose_headers = ["ETag", "Access-Control-Allow-Origin"] } ] + event_notification_config = { + target_type = "sqs" + name_suffix = "event" + filter_prefix = "test/" + events = ["s3:ObjectCreated:*"] + } } providers = { aws : aws, aws.virginia : aws.virginia } diff --git a/variables.tf b/variables.tf index 3ea462f..4e77ac4 100644 --- a/variables.tf +++ b/variables.tf @@ -43,8 +43,21 @@ variable "s3_configs" { versioning = optional(object({ enabled = bool }), { enabled = false }) website = optional(object({ index_document = string, error_document = string }), { index_document = "index.html", error_document = "index.html" }) create_iam_user = optional(bool, false) - cors_rule = optional(list(any),[]) + cors_rule = optional(list(any), []) + event_notification_config = optional(object({ + target_type = string, // Target type for the S3 event notification, can be "sqs" or "null". Other target types can be implemented in the future. + name_suffix = string, // Suffix to add to the target name. + filter_prefix = string, // Prefix to filter object key names for the event notification. + events = optional(list(string), ["s3:ObjectCreated:*"]) // List of S3 events that trigger the notification. Defaults to "s3:ObjectCreated:*". + }), { + target_type = "null" + name_suffix = "event" + filter_prefix = "test/" + events = ["s3:ObjectCreated:*"] + } + ) }) + default = { acl = "private" create_index_html = true @@ -61,6 +74,12 @@ variable "s3_configs" { } create_iam_user = false cors_rule = [] + event-notification-config = { + target_type = "null" + queue_name = "test" + filter_prefix = "test/" + events = ["s3:ObjectCreated:*"] + } } description = "S3 bucket configuration options" }