Skip to content

Commit

Permalink
[#97] Rename application components in infrastructure configuration
Browse files Browse the repository at this point in the history
This commit encompasses a series of updates to the infrastructure configuration
of the GovTool project, aligning with the rebranding initiative detailed
in ticket #111. The modifications include renaming Terraform modules,
EC2 instances, and related infrastructure components from 'vva' to 'govtool'.

Technical Details:
- Updated the DEPLOY.md documentation to reference the new `govtool-ec2` module
  instead of the old `vva-ec2`.
- Renamed Terraform modules in `main.tf`. For instance, `vva-ecr-be` is now
  `govtool-ecr-backend`, and `vva-ecr-fe` is `govtool-ecr-frontend`.
- Updated various Terraform configurations, including resource names and module
  references, to reflect the new `govtool` naming.
- Renamed files and modules within the `infra/terraform/modules` directory,
  such as changing `vva-ec2` to `govtool-ec2` and updating associated files like
  `user_data.sh` and `variables.tf`.
- Adjusted the Makefile in the `scripts/govtool` directory to check for
  the renamed Terraform module `govtool-$(env)-$(cardano_network)`.
  • Loading branch information
placek committed Feb 5, 2024
1 parent 90e6f79 commit 033d39c
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/operations/DEPLOY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This has to be done only once per AWS account.
1. Run `terraform plan` to view changes that would be performed to infrastructure.
1. Take note of the outputs - they contain ECR repo URLs and app domains.

Note: the Terraform code configures the EC2 instance using `infra/terraform/modules/vva-ec2/user_data.sh`. This script is only executed on instance creation.
Note: the Terraform code configures the EC2 instance using `infra/terraform/modules/govtool-ec2/user_data.sh`. This script is only executed on instance creation.

## Application deployment

Expand Down
48 changes: 24 additions & 24 deletions infra/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ resource "aws_route53_zone" "govtool" {
name = "govtool.byron.network."
}

module "vva-ecr-be" {
module "govtool-ecr-backend" {
source = "./modules/ecr"
repo_name = "backend"
}

module "vva-ecr-fe" {
module "govtool-ecr-frontend" {
source = "./modules/ecr"
repo_name = "frontend"
}
Expand All @@ -32,8 +32,8 @@ resource "aws_iam_policy" "cicd_ecr" {
]
Effect = "Allow"
Resource = [
module.vva-ecr-be.repo_arn,
module.vva-ecr-fe.repo_arn
module.govtool-ecr-backend.repo_arn,
module.govtool-ecr-forntend.repo_arn
]
},
{
Expand All @@ -55,58 +55,58 @@ resource "aws_iam_group_policy_attachment" "cicd" {
# duplicate the following block in order to prepare a new environment
# make sure that app_env/cardano_network variable pair is unique

module "vva-dev-sanchonet" {
source = "./modules/vva-ec2"
module "govtool-dev-sanchonet" {
source = "./modules/govtool-ec2"
app_env = "dev"
cardano_network = "sanchonet"
instance_type = "t3.large"
dns_zone_id = aws_route53_zone.govtool.id
}

module "vva-test-sanchonet" {
source = "./modules/vva-ec2"
module "govtool-test-sanchonet" {
source = "./modules/govtool-ec2"
app_env = "test"
cardano_network = "sanchonet"
instance_type = "t3.large"
dns_zone_id = aws_route53_zone.govtool.id
}

module "vva-staging-sanchonet" {
source = "./modules/vva-ec2"
module "govtool-staging-sanchonet" {
source = "./modules/govtool-ec2"
app_env = "staging"
cardano_network = "sanchonet"
instance_type = "t3.large"
dns_zone_id = aws_route53_zone.govtool.id
custom_subdomain = "staging"
}

module "vva-beta-sanchonet" {
source = "./modules/vva-ec2"
module "govtool-beta-sanchonet" {
source = "./modules/govtool-ec2"
app_env = "beta"
cardano_network = "sanchonet"
instance_type = "t3.large"
}

output "vva-ecr-be-url" {
value = module.vva-ecr-be.repo_url
output "govtool-ecr-backend-url" {
value = module.govtool-ecr-backend.repo_url
}

output "vva-ecr-fe-url" {
value = module.vva-ecr-fe.repo_url
output "govtool-ecr-frontend-url" {
value = module.govtool-ecr-frontend.repo_url
}

output "vva-dev-sanchonet-frontend-domain" {
value = module.vva-dev-sanchonet.frontend_domain
output "govtool-dev-sanchonet-frontend-domain" {
value = module.govtool-dev-sanchonet.frontend_domain
}

output "vva-test-sanchonet-frontend-domain" {
value = module.vva-test-sanchonet.frontend_domain
output "govtool-test-sanchonet-frontend-domain" {
value = module.govtool-test-sanchonet.frontend_domain
}

output "vva-staging-sanchonet-frontend-domain" {
value = module.vva-staging-sanchonet.frontend_domain
output "govtool-staging-sanchonet-frontend-domain" {
value = module.govtool-staging-sanchonet.frontend_domain
}

output "vva-beta-sanchonet-frontend-domain" {
value = module.vva-beta-sanchonet.frontend_domain
output "govtool-beta-sanchonet-frontend-domain" {
value = module.govtool-beta-sanchonet.frontend_domain
}
2 changes: 1 addition & 1 deletion infra/terraform/modules/ecr/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "app_name" {
default = "vva"
default = "govtool"
}
variable "repo_name" {}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ resource "aws_security_group" "web_sg" {
}
}

resource "aws_instance" "vva" {
resource "aws_instance" "govtool" {
ami = var.ami
instance_type = var.instance_type

Expand Down Expand Up @@ -174,8 +174,8 @@ resource "aws_instance" "vva" {
}
}

resource "aws_eip" "vva" {
instance = aws_instance.vva.id
resource "aws_eip" "govtool" {
instance = aws_instance.govtool.id

tags = {
Name = "${var.app_name}_${var.app_env}_${var.cardano_network}"
Expand All @@ -191,5 +191,5 @@ resource "aws_route53_record" "frontend" {
name = "${var.custom_subdomain != "" ? "${var.custom_subdomain}" : "${var.app_env}-${var.cardano_network}"}"
type = "A"
ttl = 180
records = [aws_eip.vva.public_ip]
records = [aws_eip.govtool.public_ip]
}
7 changes: 7 additions & 0 deletions infra/terraform/modules/govtool-ec2/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "govtool_eip" {
value = aws_eip.govtool.public_ip
}

output "frontend_domain" {
value = var.app_env == "beta" ? aws_eip.govtool.public_ip : aws_route53_record.frontend[0].fqdn
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable "ami" {
}
variable "app_env" {}
variable "app_name" {
default = "vva"
default = "govtool"
}
variable "cardano_network" {}
variable "custom_subdomain" {
Expand Down
7 changes: 0 additions & 7 deletions infra/terraform/modules/vva-ec2/outputs.tf

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/govtool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ all: docker-login prepare-config upload-config build-backend push-backend build-
check-env-defined:
@:$(call check_defined, cardano_network)
@:$(call check_defined, env)
@grep -q "module \"vva-$(env)-$(cardano_network)\"" ../../infra/terraform/main.tf && \
@grep -q "module \"govtool-$(env)-$(cardano_network)\"" ../../infra/terraform/main.tf && \
echo "Environment $(env) for network $(cardano_network) is defined in Terraform" || \
{ echo "Environment $(env) for network $(cardano_network) is NOT defined in Terraform, cannot deploy there"; exit 1; }

Expand Down

0 comments on commit 033d39c

Please sign in to comment.