Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multi-region deployment #735

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .github/workflows/sub-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ jobs:

validate-staging:
name: Validate Staging
strategy:
matrix:
endpoint:
- "https://staging.rpc.walletconnect.com"
- "https://eu-central-1.staging.rpc.walletconnect.com"
# - "https://us-east-1.staging.rpc.walletconnect.com"
# - "https://ap-southeast-1.staging.rpc.walletconnect.com"
needs: [ cd-staging ]
uses: ./.github/workflows/sub-validate.yml
secrets: inherit
with:
stage: staging
stage-url: https://staging.${{ vars.SUBDOMAIN_NAME }}.walletconnect.com
stage-url: ${{ matrix.endpoint }}

cd-prod:
name: Prod
Expand All @@ -71,9 +78,16 @@ jobs:

validate-prod:
name: Validate Prod
strategy:
matrix:
endpoint:
- "https://rpc.walletconnect.com"
- "https://eu-central-1.rpc.walletconnect.com"
# - "https://us-east-1.rpc.walletconnect.com"
# - "https://ap-southeast-1.rpc.walletconnect.com"
needs: [ cd-prod ]
uses: ./.github/workflows/sub-validate.yml
secrets: inherit
with:
stage: prod
stage-url: https://${{ vars.SUBDOMAIN_NAME }}.walletconnect.com
stage-url: ${{ matrix.endpoint }}
8 changes: 4 additions & 4 deletions .github/workflows/sub-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions:

jobs:
health-check:
name: Health Check - ${{ inputs.stage }}
name: Health Check - ${{ inputs.stage-url }}
runs-on: ubuntu-latest
environment:
name: ${{ inputs.stage }}
Expand All @@ -31,7 +31,7 @@ jobs:
run: curl "${{ inputs.stage-url }}/health"

integration-tests:
name: Integration Tests - ${{ inputs.stage }}
name: Integration Tests - ${{ inputs.stage-url }}
runs-on: ubuntu-latest
services:
postgres:
Expand Down Expand Up @@ -74,15 +74,15 @@ jobs:
args: --test integration

integration-tests-providers:
name: Providers Integration Tests - ${{ inputs.stage }}
name: Providers Integration Tests - ${{ inputs.stage-url }}
uses: ./.github/workflows/sub-providers.yml
secrets: inherit
with:
providers-directory: "src/providers/"
stage-url: ${{ inputs.stage-url }}

integration-tests-ts:
name: TS Integration Tests - ${{ inputs.stage }}
name: TS Integration Tests - ${{ inputs.stage-url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "terraform/monitoring/grafonnet-lib"]
path = terraform/monitoring/grafonnet-lib
[submodule "terraform/region/monitoring/grafonnet-lib"]
path = terraform/region/monitoring/grafonnet-lib
url = [email protected]:WalletConnect/grafonnet-lib.git
[submodule "irn"]
path = irn
Expand Down
14 changes: 0 additions & 14 deletions terraform/ecs/dns.tf

This file was deleted.

30 changes: 0 additions & 30 deletions terraform/inputs.tf
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
data "terraform_remote_state" "org" {
backend = "remote"
config = {
organization = "wallet-connect"
workspaces = {
name = "aws-org"
}
}
}

data "terraform_remote_state" "datalake" {
backend = "remote"
config = {
organization = "wallet-connect"
workspaces = {
name = "datalake-${module.stage.dev ? "staging" : local.stage}"
}
}
}

data "terraform_remote_state" "infra_aws" {
backend = "remote"
config = {
organization = "wallet-connect"
workspaces = {
name = "infra-aws"
}
}
}

data "terraform_remote_state" "monitoring" {
backend = "remote"
config = {
Expand Down
88 changes: 42 additions & 46 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
data "aws_caller_identity" "this" {}
module "eu_central_1" {
source = "./region"
region = "eu-central-1"
image_version = var.image_version
log_level = var.log_level
app_autoscaling_desired_count = var.app_autoscaling_desired_count
app_autoscaling_min_capacity = var.app_autoscaling_min_capacity
app_autoscaling_max_capacity = var.app_autoscaling_max_capacity
ofac_blocked_countries = var.ofac_blocked_countries
registry_api_endpoint = var.registry_api_endpoint
registry_api_auth_token = var.registry_api_auth_token
project_cache_ttl = var.project_cache_ttl
infura_project_id = var.infura_project_id
pokt_project_id = var.pokt_project_id
zerion_api_key = var.zerion_api_key
quicknode_api_tokens = var.quicknode_api_tokens
coinbase_api_key = var.coinbase_api_key
coinbase_app_id = var.coinbase_app_id
one_inch_api_key = var.one_inch_api_key
one_inch_referrer = var.one_inch_referrer
getblock_access_tokens = var.getblock_access_tokens
pimlico_api_key = var.pimlico_api_key
solscan_api_v1_token = var.solscan_api_v1_token
solscan_api_v2_token = var.solscan_api_v2_token
testing_project_id = var.testing_project_id
geoip_db_key = var.geoip_db_key
notification_channels = var.notification_channels
webhook_cloudwatch_p2 = var.webhook_cloudwatch_p2
webhook_prometheus_p2 = var.webhook_prometheus_p2
rate_limiting_max_tokens = var.rate_limiting_max_tokens
rate_limiting_refill_interval = var.rate_limiting_refill_interval
rate_limiting_refill_rate = var.rate_limiting_refill_rate
irn_vpc_id = var.irn_vpc_ids["eu-central-1"]
irn_vpc_cidr = var.irn_vpc_cidrs["eu-central-1"]
irn_aws_account_id = var.irn_aws_account_id
irn_node = var.irn_nodes["eu-central-1"]
irn_key = var.irn_key
irn_namespace = var.irn_namespace
irn_namespace_secret = var.irn_namespace_secret

resource "random_pet" "this" {
length = 2
}

locals {
ecr_repository_url = module.stage.dev ? data.terraform_remote_state.org.outputs.accounts.sdlc.dev.ecr-urls.blockchain : data.terraform_remote_state.org.outputs.accounts.wl.blockchain[local.stage].ecr-url
}

resource "aws_kms_key" "cloudwatch_logs" {
description = "KMS key for encrypting CloudWatch Logs"
enable_key_rotation = true
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "Enable IAM User Permissions"
Effect = "Allow"
Principal = {
AWS = data.aws_caller_identity.this.account_id
}
Action = "kms:*"
Resource = "*"
},
{
Sid = "AllowCloudWatchLogs"
Effect = "Allow"
Principal = {
Service = "logs.${module.this.region}.amazonaws.com"
}
Action = [
"kms:Encrypt*",
"kms:Decrypt*",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:Describe*"
]
Resource = "*"
},
]
})
}

resource "aws_kms_alias" "cloudwatch_logs" {
name = "alias/${module.this.id}-cloudwatch-logs"
target_key_id = aws_kms_key.cloudwatch_logs.key_id
providers = {
aws = aws.eu-central-1
}
}
Loading