Skip to content

Commit 83480d5

Browse files
Created the aws dynamodb request
1 parent 776affd commit 83480d5

5 files changed

Lines changed: 47 additions & 19 deletions

File tree

terraform/backend.tfvars

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
terraform {
2-
required_providers {
3-
aws = {
4-
source = "hashicorp/aws"
5-
version = "~> 5.0"
6-
}
7-
}
8-
required_version = ">= 1.2.0"
9-
}
10-
11-
provider "aws" {
12-
region = "us-east-1"
13-
}
1+
# bucket = "serverlesshealthcheckapi"
2+
# key = "health-check-app/terraform.tfstate"
3+
# region = "us-east-1"
4+
# encrypt = true
5+
# dynamodb_table = "terraform-locks"

terraform/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ terraform {
77
version = "~> 5.0"
88
}
99
}
10-
11-
backend "s3" {
12-
bucket = var.terraform_backend_bucket
13-
key = "${var.project_name}/${var.environment}/tfstate"
14-
region = var.aws_region
15-
}
1610
}
1711

1812
provider "aws" {
@@ -31,3 +25,10 @@ locals {
3125
CreatedAt = timestamp()
3226
}
3327
}
28+
29+
# DynamoDB Module
30+
module "dynamodb" {
31+
source = "./modules/dynamodb"
32+
environment = var.environment
33+
common_tags = local.common_tags
34+
}

terraform/modules/dynamodb/main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
resource "aws_dynamodb_table" "requests" {
2+
name = "${var.environment}-requests-db"
3+
billing_mode = "PAY_PER_REQUEST"
4+
hash_key = "request_id"
5+
6+
attribute {
7+
name = "request_id"
8+
type = "S"
9+
}
10+
11+
ttl {
12+
attribute_name = "expiration_time"
13+
enabled = true
14+
}
15+
16+
tags = var.common_tags
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "table_name" {
2+
description = "Name of the DynamoDB"
3+
value = aws_dynamodb_table.requests.name
4+
}
5+
6+
output "table_arn" {
7+
description = "ARN of the DynamoDB"
8+
value = aws_dynamodb_table.requests.arn
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "environment" {
2+
description = "Environment name"
3+
type = string
4+
}
5+
6+
variable "common_tags" {
7+
description = "Common tags for all resources"
8+
type = map(string)
9+
}

0 commit comments

Comments
 (0)