diff --git a/README.md b/README.md
index 9a95ac4..c49902c 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,7 @@ No modules.
| [logging\_log\_retention\_days](#input\_logging\_log\_retention\_days) | Number of days to retain S3 logging data before expiration. | `number` | `30` | no |
| [logging\_s3\_prefix](#input\_logging\_s3\_prefix) | Prefix for S3 logging objects. | `string` | `"s3/"` | no |
| [object\_ownership](#input\_object\_ownership) | Defines who owns newly uploaded objects in the bucket. | `string` | `"BucketOwnerPreferred"` | no |
+| [region](#input\_region) | AWS region for the provider. Defaults to ap-southeast-2 if not specified. | `string` | `"ap-southeast-2"` | no |
| [restrict\_public\_buckets](#input\_restrict\_public\_buckets) | Whether to restrict public access to the bucket. | `bool` | `true` | no |
| [sse\_algorithm](#input\_sse\_algorithm) | The encryption algorithm for S3 bucket | `string` | `"AES256"` | no |
| [tags](#input\_tags) | Tags for the S3 bucket | `map(string)` | `{}` | no |
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 91c9859..dfd8341 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -10,6 +10,8 @@ resource "random_string" "suffix" {
module "s3_bucket" {
source = "../.."
+ region = "ap-southeast-2"
+
# General Configuration
bucket_name = "test-bucket"
bucket_suffix = random_string.suffix.result
diff --git a/examples/minimal/main.tf b/examples/minimal/main.tf
index 955d6d2..555bd7b 100644
--- a/examples/minimal/main.tf
+++ b/examples/minimal/main.tf
@@ -11,6 +11,8 @@ resource "random_string" "suffix" {
module "s3_bucket" {
source = "../.."
+ region = "ap-southeast-2"
+
# General Configuration
bucket_name = "test-bucket"
bucket_suffix = random_string.suffix.result
diff --git a/examples/standard/main.tf b/examples/standard/main.tf
index f526acb..f7e9d7d 100644
--- a/examples/standard/main.tf
+++ b/examples/standard/main.tf
@@ -11,6 +11,8 @@ resource "random_string" "suffix" {
module "s3_bucket" {
source = "../.."
+ region = "ap-southeast-2"
+
# General Configuration
bucket_name = "test-bucket"
bucket_suffix = random_string.suffix.result
diff --git a/tests/s3_bucket.tftest.hcl b/tests/s3_bucket.tftest.hcl
index a14ac73..4ebb106 100644
--- a/tests/s3_bucket.tftest.hcl
+++ b/tests/s3_bucket.tftest.hcl
@@ -6,6 +6,8 @@ run "setup" {
run "test_s3_bucket" {
variables {
+ region = run.setup.region
+
bucket_name = "test-s3-bucket"
bucket_suffix = run.setup.suffix
force_destroy = true
diff --git a/tests/setup/main.tf b/tests/setup/main.tf
index d1012ee..43cf341 100644
--- a/tests/setup/main.tf
+++ b/tests/setup/main.tf
@@ -20,3 +20,7 @@ output "suffix" {
output "account_id" {
value = data.aws_caller_identity.current.account_id
}
+
+output "region" {
+ value = "ap-southeast-2"
+}
diff --git a/variables.tf b/variables.tf
index bbe2771..7b470ae 100644
--- a/variables.tf
+++ b/variables.tf
@@ -1,3 +1,18 @@
+############################################
+# GENERAL CONFIGURATION
+############################################
+
+variable "region" {
+ description = "AWS region for the provider. Defaults to ap-southeast-2 if not specified."
+ type = string
+ default = "ap-southeast-2"
+
+ validation {
+ condition = can(regex("^([a-z]{2}-[a-z]+-\\d{1})$", var.region))
+ error_message = "Invalid AWS region format. Example: 'us-east-1', 'ap-southeast-2'."
+ }
+}
+
############################################
# GENERAL BUCKET CONFIGURATION VARIABLES
############################################
diff --git a/versions.tf b/versions.tf
index ad82eda..77c3f20 100644
--- a/versions.tf
+++ b/versions.tf
@@ -7,6 +7,6 @@ terraform {
}
}
-# provider "aws" {
-# region = var.region
-# }
+provider "aws" {
+ region = var.region
+}