File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff 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
1812provider "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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments