forked from ZcashFoundation/zebra
-
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
2440589
commit 54e1d82
Showing
10 changed files
with
180 additions
and
16 deletions.
There are no files selected for viewing
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
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,44 @@ | ||
# Define variables | ||
ACCOUNT_DIR := dev | ||
REGION := eu-central-1 | ||
ENVIRONMENT := zsa | ||
AWS_PROFILE := qed-it | ||
BASE_DIR := /Users/arsenikalma/GIT/qed-it/zebra/demo-deploy/infra/terragrunt-aws-environments | ||
|
||
# Check prerequisites | ||
.PHONY: check-prerequisites plan-all apply-all destroy-all | ||
|
||
check-prerequisites: | ||
@echo "Checking prerequisites..." | ||
@if ! command -v aws >/dev/null 2>&1; then \ | ||
echo "Error: AWS CLI is not installed."; \ | ||
exit 1; \ | ||
fi | ||
@if ! command -v terragrunt >/dev/null 2>&1; then \ | ||
echo "Error: Terragrunt is not installed."; \ | ||
exit 1; \ | ||
fi | ||
@if ! grep -q "\[$(AWS_PROFILE)\]" ~/.aws/credentials; then \ | ||
echo "Error: AWS profile '$(AWS_PROFILE)' does not exist."; \ | ||
exit 1; \ | ||
fi | ||
@echo "All prerequisites are met." | ||
|
||
# Plan changes for all modules in an environment | ||
plan-all: check-prerequisites | ||
@echo "Planning changes for all modules in $(BASE_DIR)/$(ACCOUNT_DIR)/$(REGION)/$(ENVIRONMENT)..." | ||
cd $(BASE_DIR)/$(ACCOUNT_DIR)/$(REGION)/$(ENVIRONMENT) && \ | ||
terragrunt plan-all | ||
|
||
# Apply changes for all modules in an environment | ||
apply-all: check-prerequisites | ||
@echo "Applying changes for all modules in $(BASE_DIR)/$(ACCOUNT_DIR)/$(REGION)/$(ENVIRONMENT)..." | ||
cd $(BASE_DIR)/$(ACCOUNT_DIR)/$(REGION)/$(ENVIRONMENT) && \ | ||
terragrunt apply-all | ||
|
||
# Destroy all resources in an environment | ||
destroy-all: check-prerequisites | ||
@echo "Destroying all resources in $(BASE_DIR)/$(ACCOUNT_DIR)/$(REGION)/$(ENVIRONMENT)..." | ||
cd $(BASE_DIR)/$(ACCOUNT_DIR)/$(REGION)/$(ENVIRONMENT) && \ | ||
terragrunt destroy-all | ||
|
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 |
---|---|---|
@@ -1,3 +1,51 @@ | ||
# Background | ||
This folder contains the dockerfile and the Terraform code that will be deployed to the ECS cluster. | ||
There is a github action that will build the docker image and push it to the ECR repository, updating the ECS service to use the latest image. | ||
# Infrastructure Deployment Makefile | ||
|
||
This repository includes a `Makefile` to streamline the deployment, management, and teardown of AWS infrastructure using Terragrunt. The script ensures all prerequisites are met and simplifies executing commands for planning, applying, and destroying infrastructure across all modules in a specific environment. | ||
|
||
## Prerequisites | ||
|
||
Before using this script, ensure the following: | ||
|
||
1. **AWS CLI**: | ||
- Install the AWS CLI. | ||
- Configure it with your credentials. | ||
- Ensure the `qed-it` AWS profile exists in `~/.aws/credentials`. | ||
|
||
2. **Terragrunt**: | ||
- Install Terragrunt: [Install Instructions](https://terragrunt.gruntwork.io/docs/getting-started/install/). | ||
|
||
3. **Make**: | ||
- Ensure `make` is installed on your system. | ||
|
||
4. **Repository Structure**: | ||
- The script expects the `infra/terragrunt-aws-environments` directory to exist at the following location: | ||
``` | ||
/Users/arsenikalma/GIT/qed-it/zebra/demo-deploy/infra/terragrunt-aws-environments | ||
``` | ||
- Update the `Makefile` if the directory structure changes. | ||
## Makefile Targets | ||
### 1. `check-prerequisites` | ||
- Verifies that the required tools and configurations are available: | ||
- AWS CLI is installed. | ||
- Terragrunt is installed. | ||
- The `qed-it` AWS profile exists. | ||
### 2. `plan-all` | ||
- **Command**: `make plan-all` | ||
- Plans changes for all modules in the environment specified in the `Makefile`. | ||
### 3. `apply-all` | ||
- **Command**: `make apply-all` | ||
- Applies the planned changes for all modules in the environment. | ||
### 4. `destroy-all` | ||
- **Command**: `make destroy-all` | ||
- Destroys all resources in the specified environment. | ||
## Usage | ||
1. Navigate to the directory containing the `Makefile`: | ||
```bash | ||
cd /Users/arsenikalma/GIT/qed-it/zebra/demo-deploy |
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
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
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
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
24 changes: 24 additions & 0 deletions
24
...eploy/infra/terragrunt-aws-environments/dev/eu-central-1/zsa/ecr-logs/.terraform.lock.hcl
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
demo-deploy/infra/terragrunt-aws-environments/dev/eu-central-1/zsa/ecr-logs/terragrunt.hcl
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,25 @@ | ||
locals { | ||
# Automatically load environment-level variables | ||
environment_vars = read_terragrunt_config(find_in_parent_folders("env.hcl")) | ||
|
||
region_vars = read_terragrunt_config(find_in_parent_folders("region.hcl")) | ||
account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl")) | ||
# Extract out common variables for reuse | ||
env = local.environment_vars.locals.environment | ||
} | ||
|
||
# Terragrunt will copy the Terraform configurations specified by the source parameter, along with any files in the | ||
# working directory, into a temporary folder, and execute your Terraform commands in that folder. | ||
terraform { | ||
source = "../../../../../terraform-aws-modules//ecr" | ||
} | ||
|
||
# Include all settings from the root terragrunt.hcl file | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
inputs = { | ||
env = local.env | ||
name = "zebra-logs" | ||
} |
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