Skip to content

Commit

Permalink
FIX: add cloud nat and router (#503)
Browse files Browse the repository at this point in the history
* added partner code for infrastructure, and updated dev code

* added VPC network creation

* changes to PR requests

* added conditional to VPC creation and removed old partner code

* partner: var names for easier onboard

* minor

* moved around variables to simplify workflow

* address comments and change public image name

* leave the -0 suffix so it's easier if they want to run multiple nodes

* updated to configurable region

* variablized zone

* set default region to europe-west1

* updated backend config

* update default subnet

* added router and nat for public VM internet access

* changed contract name

* add back in -0

* added external IP address to outputs for easy identification

* update firewall rule

* fixed IP output

---------

Co-authored-by: Xiangyi Zheng <xiangyi@near.org>
  • Loading branch information
kmaus-near and ppca authored Mar 20, 2024
1 parent 994a455 commit f31e39f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion infra/partner-vm-testnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ resource "google_compute_firewall" "app_port" {

allow {
protocol = "tcp"
ports = [ "80" ]
ports = [ "80", "3000" ]
}

}
15 changes: 15 additions & 0 deletions infra/partner-vm-testnet/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,19 @@ module "vpc" {
]
},
]
}

resource "google_compute_router" "router" {
name = "default"
network = var.network
project = var.project_id
region = var.region
}

resource "google_compute_router_nat" "nat" {
name = "nat"
router = google_compute_router.router.name
region = var.region
nat_ip_allocate_option = "AUTO_ONLY"
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
}
3 changes: 3 additions & 0 deletions infra/partner-vm-testnet/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "node_public_ip" {
value = google_compute_global_address.external_ips[*].address
}
8 changes: 4 additions & 4 deletions infra/partner-vm-testnet/terraform-testnet-example.tfvars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
env = "testnet"
project_id = "<your-project-id>"
network = "default"
subnetwork = "europe-west1"
subnetwork = "default"
image = "us-east1-docker.pkg.dev/pagoda-discovery-platform-prod/multichain-public/multichain-testnet:latest"
region = "europe-west1"
zone = "europe-west1-b"
Expand All @@ -12,8 +12,8 @@ node_configs = [
account = "{your_near_account_id}"
cipher_pk = "<your_cipher_pk>"
# These 3 values below should match your secret names in google secrets manager
account_sk_secret_id = "multichain-account-sk-testnet"
cipher_sk_secret_id = "multichain-cipher-sk-testnet"
sk_share_secret_id = "multichain-sk-share-testnet"
account_sk_secret_id = "multichain-account-sk-testnet-0"
cipher_sk_secret_id = "multichain-cipher-sk-testnet-0"
sk_share_secret_id = "multichain-sk-share-testnet-0"
},
]
2 changes: 1 addition & 1 deletion infra/partner-vm-testnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ variable "static_env" {
},
{
name = "MPC_RECOVERY_CONTRACT_ID"
value = "multichain0.testnet"
value = "v1.multichain-mpc.testnet"
},
{
name = "MPC_RECOVERY_INDEXER_S3_BUCKET"
Expand Down

0 comments on commit f31e39f

Please sign in to comment.