Skip to content

Commit

Permalink
Merge pull request #4213 from connext/main
Browse files Browse the repository at this point in the history
Testnet prod sync
  • Loading branch information
sanchaymittal authored May 12, 2023
2 parents 205d319 + 48c2354 commit 32de5e8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
34 changes: 21 additions & 13 deletions ops/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,49 @@ ecs cluster, with its required dependencies. Namely:
- testnet/staging/mainnet environment automatic set up and deployment with GH Actions
- Reusable Infrastructure as Code, modularized as Terraform components


## Scaffolding

```text
├── infra <- Cross-environment infrastructure
├── tesnet <- Tesnet set up
└── modules
├── testnet <- Testnet set up
└── modules
├── service <- Generic, configurable ECS service
├── ecs <- ECS cluster definition
├── iam <- IAM roles needed for ECS
├── redis <- ElastiCache cluster
├── redis <- ElastiCache cluster
└── networking <- VPCs, Subnets and all those shenanigans
```


## Deployment & Usage

Deployment should occur only via CICD with Github Actions. However, it is also possible to deploy the infra
from a local set up. Ensure you have the right AWS credentials and `terraform 1.1.7` installed
([instructions](https://learn.hashicorp.com/tutorials/terraform/install-cli))
([instructions](https://learn.hashicorp.com/tutorials/terraform/install-cli)).

Then, navigate to the `environment` you'd like to operate on (`testnet`, `staging`, `mainnet`), and do:
Grab vars from `sops` based on the `environment` you will operate on:

```shell
>>> terraform init
sops -d ops/env/testnet/backend/secrets.prod.json > ops/testnet/prod/backend/tfvars.json
```

Make your changes,
Copy env vars from CI job:

```shell
>>> terraform plan
export AWS_PROFILE=aws-deployer-connext
export TF_VAR_cartographer_image_tag=3a8dea29cf8f413e627589606f1af52c3691e5f2
```

Then, navigate to the `environment` you're targeting (e.g. `/ops/testnet/prod/backend`), and do:

```shell
terraform init
```

Make your changes, then:

```shell
terraform plan -var-file=tfvars.json
```

To set custom variables, you can set them with `export TF_ENV_<variable_name>=<variable value>`
Expand All @@ -50,6 +61,3 @@ To set custom variables, you can set them with `export TF_ENV_<variable_name>=<v

**sequencer**: https://sequencer.testnet.connext.ninja
**router**: https://router.testnet.connext.ninja



3 changes: 1 addition & 2 deletions ops/mainnet/prod/backend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ module "cartographer_db" {
Domain = var.domain
}

parameter_group_name = module.db.rds_parameter_group_name
vpc_id = module.network.vpc_id
vpc_id = module.network.vpc_id

hosted_zone_id = data.aws_route53_zone.primary.zone_id
stage = var.stage
Expand Down
2 changes: 1 addition & 1 deletion ops/modules/db/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "aws_db_instance" "db" {

vpc_security_group_ids = [var.db_security_group_id]
db_subnet_group_name = aws_db_subnet_group.default.name
parameter_group_name = var.parameter_group_name
parameter_group_name = aws_db_parameter_group.rds_postgres.name
performance_insights_enabled = var.performance_insights_enabled

availability_zone = var.availability_zone
Expand Down
8 changes: 1 addition & 7 deletions ops/modules/db/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ variable "db_security_group_id" {
type = string
}


variable "parameter_group_name" {
description = "Name of the DB parameter group to associate"
type = string
}

variable "availability_zone" {
description = "The Availability Zone of the RDS instance"
type = string
Expand Down Expand Up @@ -110,4 +104,4 @@ variable "publicly_accessible" {

variable "performance_insights_enabled" {
default = true
}
}
4 changes: 1 addition & 3 deletions ops/testnet/prod/backend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ module "cartographer_db" {
allocated_storage = 150
max_allocated_storage = 180


name = "connext" // db name
username = var.postgres_user
password = var.postgres_password
Expand All @@ -43,8 +42,7 @@ module "cartographer_db" {
Domain = var.domain
}

parameter_group_name = module.db.rds_parameter_group_name
vpc_id = module.network.vpc_id
vpc_id = module.network.vpc_id

hosted_zone_id = data.aws_route53_zone.primary.zone_id
stage = var.stage
Expand Down

0 comments on commit 32de5e8

Please sign in to comment.