summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit <justsaumit@protonmail.com>2025-09-28 01:54:24 +0530
committerSaumit <justsaumit@protonmail.com>2025-09-28 01:54:24 +0530
commitd682471acaa88e96c78717b813ffeedb726da831 (patch)
tree9ddb923e20a568fd618de8a0793fee7893a07fc5
parent793b832b52d8dbce129d347e2cbcfffadaf4867d (diff)
backend.tf: State file configuration
-rw-r--r--astroshop-terraform/.gitignore83
-rw-r--r--astroshop-terraform/.terraform.lock.hcl25
-rw-r--r--astroshop-terraform/backend.tf25
-rw-r--r--astroshop-terraform/providers.tf12
-rw-r--r--astroshop-terraform/variables.tf5
5 files changed, 150 insertions, 0 deletions
diff --git a/astroshop-terraform/.gitignore b/astroshop-terraform/.gitignore
new file mode 100644
index 0000000..6190adb
--- /dev/null
+++ b/astroshop-terraform/.gitignore
@@ -0,0 +1,83 @@
+# .gitignore for Terraform
+
+# Local .terraform directories
+**/.terraform/*
+
+# .tfstate files
+*.tfstate
+*.tfstate.*
+
+# Crash log files
+crash.log
+crash.*.log
+
+# Exclude all .tfvars files, which are likely to contain sensitive data
+*.tfvars
+*.tfvars.json
+!example.tfvars
+
+# Ignore override files, as they are usually used to override resources locally
+override.tf
+override.tf.json
+*_override.tf
+*_override.tf.json
+
+# Include override files you do want to commit
+!example_override.tf
+
+# Ignore CLI configuration files
+.terraformrc
+terraform.rc
+
+# Ignore plan files
+*.tfplan
+plan.out
+
+# Ignore lock files (optional - many teams commit this)
+# .terraform.lock.hcl
+
+# Ignore Mac .DS_Store files
+.DS_Store
+
+# Ignore Linux/Unix hidden files
+.vscode/
+.idea/
+*.swp
+*.swo
+*~
+
+# Ignore Windows files
+Thumbs.db
+*.exe
+
+# Ignore temporary files
+*.tmp
+*.temp
+
+# Ignore local variable override files
+local.tfvars
+
+# Ignore environment-specific files
+*.local
+.env
+.env.local
+
+# Ignore Terraform debug files
+debug.tflog
+debug.tflog.*
+
+# Ignore custom scripts or local testing files
+scripts/local/
+local_tests/
+
+# Ignore secrets and credentials
+secrets.tfvars
+.ssh/
+*.pem
+*.pub
+
+# OS-specific
+.DS_Store
+.AppleDouble
+.LSOverride
+*.VC.db
diff --git a/astroshop-terraform/.terraform.lock.hcl b/astroshop-terraform/.terraform.lock.hcl
new file mode 100644
index 0000000..8ebbdbe
--- /dev/null
+++ b/astroshop-terraform/.terraform.lock.hcl
@@ -0,0 +1,25 @@
+# This file is maintained automatically by "terraform init".
+# Manual edits may be lost in future updates.
+
+provider "registry.terraform.io/hashicorp/aws" {
+ version = "6.21.0"
+ constraints = "~> 6.0"
+ hashes = [
+ "h1:YfPC5vxQr014wnHI6tBqLxaHZcZQvkaVr19ipqXijdw=",
+ "zh:03b65e7d275a48bbe5de9aed2bcacf841ea0a85352744587729d179ceb227994",
+ "zh:1a50fc50365602769b6844c6eba920b5c6941161508c2ebd5c1a60f7577edd18",
+ "zh:1bcbf2575e462849baa01554be469ac68dbd43fe7929819ab43eb8a849605ce9",
+ "zh:28466d206962bfe00a32ecf0a4fa8553a5099521629fce010f486bae2a5f194f",
+ "zh:3627c098788e4fc3eb88271101717212f260aa117dad15e648bde6f2889d3536",
+ "zh:3f8ae239d1b60a5de3f089810728947c19854eff3c16f22c31e1c8b039dd93a0",
+ "zh:62201751f1fc46b6e2720e5d7ea6bab75b98a7eb1f4c3460c258106be5bc5495",
+ "zh:86c89c7dd5866fcb57c4d35e7ba6ec849caf70c2fdd2d23c9d05da919ec06c8b",
+ "zh:94186ec3908ce6e89eaf98767b6b1e40acfb258de9fe8c09f2a100eb5cfca597",
+ "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
+ "zh:9d5863a6970735c9e428be91c301789c1e228a3105f711d77efe9c6056bb8295",
+ "zh:a94f9abe91656d68a0657d877665766931ae381825fa0b5121da26b3aa3ed15d",
+ "zh:df2b293078bb3d31b45bcc6e83c17e790dca40198b8d7069dc3e3b387146937f",
+ "zh:e7666954631899756e3bb428c64abcff1c94b7355f7d92eba29541c3d401e472",
+ "zh:f142320e9d4a5c663f6e9924abe05274bbbc4031700bac3387e0a67ec6c951ef",
+ ]
+}
diff --git a/astroshop-terraform/backend.tf b/astroshop-terraform/backend.tf
new file mode 100644
index 0000000..10553ae
--- /dev/null
+++ b/astroshop-terraform/backend.tf
@@ -0,0 +1,25 @@
+resource "aws_s3_bucket" "terraform_state" {
+ bucket = "astroshop-terraform-state"
+
+ lifecycle {
+ prevent_destroy = true
+ }
+}
+
+resource "aws_s3_bucket_versioning" "terraform_state" {
+ bucket = aws_s3_bucket.terraform_state.id
+
+ versioning_configuration {
+ status = "Enabled"
+ }
+}
+
+resource "aws_s3_bucket_server_side_encryption_configuration" "terraform_state" {
+ bucket = aws_s3_bucket.terraform_state.id
+
+ rule {
+ apply_server_side_encryption_by_default {
+ sse_algorithm = "AES256"
+ }
+ }
+} \ No newline at end of file
diff --git a/astroshop-terraform/providers.tf b/astroshop-terraform/providers.tf
new file mode 100644
index 0000000..c415ed0
--- /dev/null
+++ b/astroshop-terraform/providers.tf
@@ -0,0 +1,12 @@
+terraform {
+ required_providers {
+ aws = {
+ source = "hashicorp/aws"
+ version = "~> 6.0"
+ }
+ }
+}
+
+provider "aws" {
+ region = var.region
+} \ No newline at end of file
diff --git a/astroshop-terraform/variables.tf b/astroshop-terraform/variables.tf
new file mode 100644
index 0000000..3b0968c
--- /dev/null
+++ b/astroshop-terraform/variables.tf
@@ -0,0 +1,5 @@
+variable "region" {
+ description = "The AWS region to deploy resources in"
+ type = string
+ default = "ap-south-1"
+} \ No newline at end of file