Skip to content

Commit 34bf651

Browse files
committed
remote backend (s3) & dynamodb for statelock functionality
1 parent 0fbcd86 commit 34bf651

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~>3.0"
6+
}
7+
}
8+
backend "s3" {
9+
bucket = "terraform-course-backend"
10+
key = "security/terraform.tfstate"
11+
region = "us-east-2"
12+
dynamodb_table = "terraform-state-lock"
13+
}
14+
}
15+
16+
provider "aws" {
17+
region = var.region
18+
}
19+
20+
resource "time_sleep" "wait_150_seconds" {
21+
create_duration = "150s"
22+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- In this we will be seeing how to integrate the backend store like s3 to connect with dynamodb.
2+
- In regular backend scenarios where the *.tfstate file is stored in s3 bucket, we are not gaurentee the lock functionality
3+
- As a reason we will use dynamodb to record the state info so that any one else in the team is trying for a parallel write on the *.tfstate file will be warned of the lock that is acquired at that moment.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variable "region" {
2+
type = string
3+
default = "us-east-2"
4+
}

0 commit comments

Comments
 (0)