From 5c95842ccea7347298ab16d65c89c3b815a26fd7 Mon Sep 17 00:00:00 2001 From: Shashidara G Date: Wed, 25 Sep 2024 19:26:53 +0530 Subject: [PATCH 1/3] Added modules for S3 bucket and DynamoDB table --- modules/dynamodb/main.tf | 13 +++++++++++++ modules/dynamodb/outputs.tf | 0 modules/dynamodb/variables.tf | 0 3 files changed, 13 insertions(+) create mode 100644 modules/dynamodb/main.tf create mode 100644 modules/dynamodb/outputs.tf create mode 100644 modules/dynamodb/variables.tf diff --git a/modules/dynamodb/main.tf b/modules/dynamodb/main.tf new file mode 100644 index 0000000..5e5c5a2 --- /dev/null +++ b/modules/dynamodb/main.tf @@ -0,0 +1,13 @@ +resource "aws_dynamodb_table" "new" { + name = var.table_name + billing_mode = var.billing_mode + + hash_key = var.hash_key + + attribute { + name = var.hash_key + type = var.hash_key_type + } + + tags = var.tags +} diff --git a/modules/dynamodb/outputs.tf b/modules/dynamodb/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/modules/dynamodb/variables.tf b/modules/dynamodb/variables.tf new file mode 100644 index 0000000..e69de29 From b58cfe5a1622b362fa02a20ad18c47a072df52ff Mon Sep 17 00:00:00 2001 From: Shashidara G Date: Wed, 25 Sep 2024 19:34:04 +0530 Subject: [PATCH 2/3] Added modified modules for S3 bucket and DynamoDB table --- modules/dynamodb/outputs.tf | 4 ++++ modules/dynamodb/variables.tf | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/modules/dynamodb/outputs.tf b/modules/dynamodb/outputs.tf index e69de29..86c667b 100644 --- a/modules/dynamodb/outputs.tf +++ b/modules/dynamodb/outputs.tf @@ -0,0 +1,4 @@ +output "table_id" { + description = "The ID of the DynamoDB table" + value = aws_dynamodb_table.this.id +} diff --git a/modules/dynamodb/variables.tf b/modules/dynamodb/variables.tf index e69de29..e7fb0d6 100644 --- a/modules/dynamodb/variables.tf +++ b/modules/dynamodb/variables.tf @@ -0,0 +1,27 @@ +variable "table_name" { + description = "The name of the DynamoDB table" + type = string +} + +variable "billing_mode" { + description = "DynamoDB billing mode" + type = string + default = "PAY_PER_REQUEST" +} + +variable "hash_key" { + description = "The hash key for the DynamoDB table" + type = string +} + +variable "hash_key_type" { + description = "The type of the hash key (S = string, N = number)" + type = string + default = "S" +} + +variable "tags" { + description = "Tags to assign to the DynamoDB table" + type = map(string) + default = {} +} From 32cd1947b840fa0825d8d3497b028ef24c685134 Mon Sep 17 00:00:00 2001 From: Shashidara G Date: Wed, 25 Sep 2024 19:37:44 +0530 Subject: [PATCH 3/3] Added modules for S3 bucket --- modules/s3/main.tf | 13 +++++++++++++ modules/s3/outputs.tf | 10 ++++++++++ modules/s3/variables.tf | 16 ++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 modules/s3/main.tf create mode 100644 modules/s3/outputs.tf create mode 100644 modules/s3/variables.tf diff --git a/modules/s3/main.tf b/modules/s3/main.tf new file mode 100644 index 0000000..61634a9 --- /dev/null +++ b/modules/s3/main.tf @@ -0,0 +1,13 @@ +resource "aws_s3_bucket" "new" { + bucket = var.bucket_name + + tags = var.tags +} + +resource "aws_s3_bucket_versioning" "new" { + bucket = aws_s3_bucket.new.id + + versioning_configuration { + status = var.versioning_enabled ? "Enabled" : "Suspended" + } +} diff --git a/modules/s3/outputs.tf b/modules/s3/outputs.tf new file mode 100644 index 0000000..6c35d06 --- /dev/null +++ b/modules/s3/outputs.tf @@ -0,0 +1,10 @@ +output "bucket_id" { + description = "The ID of the S3 bucket" + value = aws_s3_bucket.new.id +} + +output "bucket_arn" { + description = "The ARN of the S3 bucket" + value = aws_s3_bucket.new.arn +} + diff --git a/modules/s3/variables.tf b/modules/s3/variables.tf new file mode 100644 index 0000000..ec7a113 --- /dev/null +++ b/modules/s3/variables.tf @@ -0,0 +1,16 @@ +variable "bucket_name" { + description = "The name of the S3 bucket" + type = string +} + +variable "versioning_enabled" { + description = "Enable versioning for the S3 bucket" + type = bool + default = false +} + +variable "tags" { + description = "Tags to assign to the S3 bucket" + type = map(string) + default = {} +} \ No newline at end of file