Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added modules for S3 bucket and DynamoDB table #55

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions modules/dynamodb/main.tf
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 4 additions & 0 deletions modules/dynamodb/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "table_id" {
description = "The ID of the DynamoDB table"
value = aws_dynamodb_table.this.id
}
27 changes: 27 additions & 0 deletions modules/dynamodb/variables.tf
Original file line number Diff line number Diff line change
@@ -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 = {}
}
13 changes: 13 additions & 0 deletions modules/s3/main.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
10 changes: 10 additions & 0 deletions modules/s3/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}

16 changes: 16 additions & 0 deletions modules/s3/variables.tf
Original file line number Diff line number Diff line change
@@ -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 = {}
}