-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30c2b4e
commit c0ef10f
Showing
7 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
README.md | ||
# Core Infrastructure | ||
|
||
This directory contains Terraform configurations for the core infrastructure components of our | ||
project. These are foundational elements that other parts of our infrastructure rely upon. | ||
|
||
## Overview | ||
|
||
The `core` directory manages the following resources: | ||
|
||
- **AWS S3 Bucket** for Terraform state storage: Ensures that our Terraform state is stored | ||
securely and is accessible across our team for state management. | ||
- **DynamoDB Table** for Terraform state locking: Prevents concurrent operations from | ||
corrupting the state. | ||
|
||
## Structure | ||
|
||
- `s3.tf`: Contains the configuration for the S3 bucket used for state storage. | ||
- `dynamodb.tf`: Defines the DynamoDB table used for locking the Terraform state during | ||
modifications. | ||
- `providers.tf`: Sets up provider configurations and specifies the required versions. | ||
- `variables.tf`: Declares variables used across multiple configurations within the core | ||
infrastructure. | ||
|
||
## Usage | ||
|
||
To deploy or modify the core infrastructure, follow these steps: | ||
|
||
1. **Initialization**: | ||
Navigate to the `core` directory and run: | ||
|
||
`terraform init` | ||
|
||
This will prepare your directory for Terraform operations, setting up the backend and initializing | ||
provider plugins. | ||
|
||
2. **Planning**: | ||
To see what changes Terraform plans to make to your infrastructure based on the current | ||
configurations, run: | ||
|
||
`terraform plan` | ||
|
||
3. **Applying Changes**: | ||
To apply the changes proposed in the plan, run: | ||
|
||
`terraform apply` | ||
|
||
Always review the plan before applying it to prevent unintended changes. | ||
|
||
## Best Practices | ||
|
||
- **Review changes**: Always review the output of `terraform plan` before applying changes. | ||
- **Keep secrets secure**: Never hard-code sensitive information. Use environment variables | ||
and secrets management practices. | ||
- **Version control**: Keep all changes in version control and review changes through pull | ||
requests. | ||
|
||
## Contributing | ||
|
||
Contributions to the core infrastructure should follow the company's guidelines on | ||
infrastructure changes, including approval and review processes. | ||
|
||
--- | ||
|
||
For more detailed information on each resource, refer to the individual `.tf` files within this | ||
directory. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
resource "aws_dynamodb_table" "terraform_lock" { | ||
name = var.dynamodb_table_name | ||
billing_mode = "PAY_PER_REQUEST" | ||
hash_key = "LockID" | ||
attribute { | ||
name = "LockID" | ||
type = "S" | ||
} | ||
|
||
tags = { | ||
Name = "Terraform State Lock" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
provider "aws" { | ||
region = var.region | ||
} | ||
#s3 provider | ||
terraform { | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "4.31.0" | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
resource "aws_s3_bucket" "terraform_state_for_intro" { | ||
bucket = "s3-backend-${random_string.unique_suffix.result}" | ||
acl = "private" | ||
|
||
versioning { | ||
enabled = true | ||
} | ||
|
||
server_side_encryption_configuration { | ||
rule { | ||
apply_server_side_encryption_by_default { | ||
sse_algorithm = "AES256" | ||
} | ||
} | ||
} | ||
|
||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
|
||
lifecycle_rule { | ||
id = "delete_old_versions" | ||
enabled = true | ||
|
||
noncurrent_version_expiration { | ||
days = 30 | ||
} | ||
} | ||
} | ||
|
||
resource "random_string" "unique_suffix" { | ||
length = 7 | ||
special = false | ||
upper = false | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
variable "region" { | ||
default = "eu-west-2" | ||
} | ||
|
||
variable "dynamodb_table_name" { | ||
default = "project-name-terraform-state-lock" | ||
} |