From 033d39c93c2177ec8fb7be423f05230a19e82cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Placzy=C5=84ski?= Date: Mon, 5 Feb 2024 13:37:32 +0100 Subject: [PATCH] [#97] Rename application components in infrastructure configuration 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)`. --- docs/operations/DEPLOY.md | 2 +- infra/terraform/main.tf | 48 +++++++++---------- infra/terraform/modules/ecr/variables.tf | 2 +- .../modules/{vva-ec2 => govtool-ec2}/main.tf | 8 ++-- .../terraform/modules/govtool-ec2/outputs.tf | 7 +++ .../{vva-ec2 => govtool-ec2}/user_data.sh | 0 .../{vva-ec2 => govtool-ec2}/variables.tf | 2 +- infra/terraform/modules/vva-ec2/outputs.tf | 7 --- scripts/govtool/Makefile | 2 +- 9 files changed, 39 insertions(+), 39 deletions(-) rename infra/terraform/modules/{vva-ec2 => govtool-ec2}/main.tf (96%) create mode 100644 infra/terraform/modules/govtool-ec2/outputs.tf rename infra/terraform/modules/{vva-ec2 => govtool-ec2}/user_data.sh (100%) rename infra/terraform/modules/{vva-ec2 => govtool-ec2}/variables.tf (94%) delete mode 100644 infra/terraform/modules/vva-ec2/outputs.tf diff --git a/docs/operations/DEPLOY.md b/docs/operations/DEPLOY.md index 0aa83ccea..f0cedf97b 100644 --- a/docs/operations/DEPLOY.md +++ b/docs/operations/DEPLOY.md @@ -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 diff --git a/infra/terraform/main.tf b/infra/terraform/main.tf index 291e66a89..b62940485 100644 --- a/infra/terraform/main.tf +++ b/infra/terraform/main.tf @@ -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" } @@ -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 ] }, { @@ -55,24 +55,24 @@ 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" @@ -80,33 +80,33 @@ module "vva-staging-sanchonet" { 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 } diff --git a/infra/terraform/modules/ecr/variables.tf b/infra/terraform/modules/ecr/variables.tf index 4f29a09de..33fcb170f 100644 --- a/infra/terraform/modules/ecr/variables.tf +++ b/infra/terraform/modules/ecr/variables.tf @@ -1,4 +1,4 @@ variable "app_name" { - default = "vva" + default = "govtool" } variable "repo_name" {} diff --git a/infra/terraform/modules/vva-ec2/main.tf b/infra/terraform/modules/govtool-ec2/main.tf similarity index 96% rename from infra/terraform/modules/vva-ec2/main.tf rename to infra/terraform/modules/govtool-ec2/main.tf index e5a5522aa..f71417f05 100644 --- a/infra/terraform/modules/vva-ec2/main.tf +++ b/infra/terraform/modules/govtool-ec2/main.tf @@ -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 @@ -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}" @@ -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] } diff --git a/infra/terraform/modules/govtool-ec2/outputs.tf b/infra/terraform/modules/govtool-ec2/outputs.tf new file mode 100644 index 000000000..99a2f8920 --- /dev/null +++ b/infra/terraform/modules/govtool-ec2/outputs.tf @@ -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 +} diff --git a/infra/terraform/modules/vva-ec2/user_data.sh b/infra/terraform/modules/govtool-ec2/user_data.sh similarity index 100% rename from infra/terraform/modules/vva-ec2/user_data.sh rename to infra/terraform/modules/govtool-ec2/user_data.sh diff --git a/infra/terraform/modules/vva-ec2/variables.tf b/infra/terraform/modules/govtool-ec2/variables.tf similarity index 94% rename from infra/terraform/modules/vva-ec2/variables.tf rename to infra/terraform/modules/govtool-ec2/variables.tf index 7a230a530..0f58d46b4 100644 --- a/infra/terraform/modules/vva-ec2/variables.tf +++ b/infra/terraform/modules/govtool-ec2/variables.tf @@ -3,7 +3,7 @@ variable "ami" { } variable "app_env" {} variable "app_name" { - default = "vva" + default = "govtool" } variable "cardano_network" {} variable "custom_subdomain" { diff --git a/infra/terraform/modules/vva-ec2/outputs.tf b/infra/terraform/modules/vva-ec2/outputs.tf deleted file mode 100644 index 821684c05..000000000 --- a/infra/terraform/modules/vva-ec2/outputs.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "vva_eip" { - value = aws_eip.vva.public_ip -} - -output "frontend_domain" { - value = var.app_env == "beta" ? aws_eip.vva.public_ip : aws_route53_record.frontend[0].fqdn -} diff --git a/scripts/govtool/Makefile b/scripts/govtool/Makefile index 4c2017d22..dc8c8feac 100644 --- a/scripts/govtool/Makefile +++ b/scripts/govtool/Makefile @@ -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; }