Skip to content

Commit

Permalink
update files
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahim-mohamed-zaghloul committed Oct 14, 2024
1 parent f9adc91 commit a81923b
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 20 deletions.
10 changes: 10 additions & 0 deletions terraform/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

terraform {
backend "s3" {
bucket = "depi-final" # Reference the created bucket
key = "global/s3/terraform.tfstate" # Path to store the state file in the bucket
region = "us-east-1" # Replace with your bucket's region
encrypt = true # Encrypt the state file
dynamodb_table = "terraform-locking" # Reference the created DynamoDB table
}
}
16 changes: 16 additions & 0 deletions terraform/dynamodb.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

resource "aws_dynamodb_table" "terraform_lock" {
name = "terraform-locking"
billing_mode = "PAY_PER_REQUEST" # Autoscale billing mode
hash_key = "LockID"

attribute {
name = "LockID"
type = "S"
}

tags = {
Name = "Terraform Lock Table"
Environment = "Dev"
}
}
4 changes: 2 additions & 2 deletions terraform/ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ resource "aws_ecr_repository" "ecr_front" {
name = var.ecr_frontend_name
}

output "ecr_url" {
output "ecr_url_front" {
value = aws_ecr_repository.ecr_front.repository_url
}

resource "aws_ecr_repository" "ecr_back" {
name = var.ecr_backend_name
}

output "ecr_url" {
output "ecr_url_back" {
value = aws_ecr_repository.ecr_back.repository_url
}

8 changes: 8 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

output "s3_bucket_name" {
value = aws_s3_bucket.terraform_state.bucket
}

output "dynamodb_table_name" {
value = aws_dynamodb_table.terraform_lock.name
}
19 changes: 2 additions & 17 deletions terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
}
backend "remote" {
hostname = "app.terraform.io"
organization = "depi_final"

workspaces {
name = "Terraform-AWS-EKS-GitHub-Actions"
}
}
}

provider "aws" {
region = var.region
}
region = "us-east-1" # Replace with your preferred region
}
21 changes: 21 additions & 0 deletions terraform/s3.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

resource "aws_s3_bucket" "terraform_state" {
bucket = "depi-final" # Replace with a globally unique bucket name

versioning {
enabled = true # Enable versioning to keep track of state file changes
}

server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}

tags = {
Name = "Terraform State Bucket"
Environment = "Dev"
}
}
2 changes: 1 addition & 1 deletion terraform/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#provider

region = "us_east_1"
region = "us-east-1"

#ecr

Expand Down

0 comments on commit a81923b

Please sign in to comment.