Skip to content

Commit

Permalink
Main -> Develop (solved conflicts) (#297)
Browse files Browse the repository at this point in the history
* feat: terraform configuration (#170)

* feat: add terraform module for partners (#294)

* redundant variables deleted

* terraform fmt

* redundant parameters deleted

* lookup_url deleted from setup

* fmt

* redundant dep deleted

* duplicated service-account-datastore-user deleted

* unused terraform value firebase_audience_id deleted

* terraform fmt

---------

Co-authored-by: Daniyar Itegulov <[email protected]>
Co-authored-by: DavidM-D <[email protected]>
Co-authored-by: Phuong Nguyen <[email protected]>
  • Loading branch information
4 people authored Sep 21, 2023
1 parent e5d0781 commit a4a0825
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
22 changes: 22 additions & 0 deletions infra/migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from google.oauth2 import service_account
from google.cloud import datastore

credentials_source = service_account.Credentials.from_service_account_file(
'../source-service-keys.json')
client_source = datastore.Client(project="pagoda-discovery-platform-dev", credentials=credentials_source)

credentials_target = service_account.Credentials.from_service_account_file(
'../target-service-keys.json')
client_target = datastore.Client(project="pagoda-discovery-platform-prod", credentials=credentials_target)

print('Fetching source entities')
query = credentials_source.query(kind="EncryptedUserCredentials-dev")
entities = []
for entity in list(query.fetch()):
entity.key = client_target.key('EncryptedUserCredentials-mainnet').completed_key(entity.key.id_or_name)
print(entity.key)
print(entity)
entities.append(entity)

print("Uploading a total of " + str(len(entities)) + " entities to target")
client_target.put_multi(entities)
97 changes: 97 additions & 0 deletions infra/partner/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "4.66.0"
}
docker = {
source = "kreuzwerker/docker"
version = "3.0.2"
}
}
}

locals {
credentials = file(var.credentials_file)
client_email = jsondecode(local.credentials).client_email
client_id = jsondecode(local.credentials).client_id
}

provider "google" {
credentials = local.credentials

project = var.project
region = var.region
zone = var.zone
}

provider "docker" {
registry_auth {
address = "${var.region}-docker.pkg.dev"
username = "_json_key"
password = local.credentials
}
}

resource "google_service_account" "service_account" {
account_id = "mpc-recovery-${var.env}"
display_name = "MPC Recovery ${var.env} Account"
}

resource "google_service_account_iam_binding" "serivce-account-iam" {
service_account_id = google_service_account.service_account.name
role = "roles/iam.serviceAccountUser"

members = [
"serviceAccount:${local.client_email}",
]
}

resource "google_project_iam_binding" "service-account-datastore-user" {
project = var.project
role = "roles/datastore.user"

members = [
"serviceAccount:${google_service_account.service_account.email}",
]
}

resource "google_artifact_registry_repository" "mpc_recovery" {
repository_id = "mpc-recovery-signer-${var.env}"
format = "DOCKER"
}

resource "docker_registry_image" "mpc_recovery" {
name = docker_tag.mpc_recovery.target_image
keep_remotely = true
}

resource "docker_tag" "mpc_recovery" {
source_image = var.docker_image
target_image = "${var.region}-docker.pkg.dev/${var.project}/${google_artifact_registry_repository.mpc_recovery.name}/mpc-recovery-${var.env}"
}

# resource "docker_image" "mpc_recovery" {
# name = "${var.region}-docker.pkg.dev/${var.project}/${google_artifact_registry_repository.mpc_recovery.name}/mpc-recovery-${var.env}"
# build {
# context = "${path.cwd}/.."
# }
# }

module "signer" {
source = "../modules/signer"

env = var.env
project = var.project
region = var.region
zone = var.zone
service_account_email = google_service_account.service_account.email
docker_image = docker_tag.mpc_recovery.target_image

node_id = var.node_id

cipher_key = var.cipher_key
sk_share = var.sk_share

depends_on = [docker_registry_image.mpc_recovery]
}
30 changes: 30 additions & 0 deletions infra/partner/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
variable "env" {
}

variable "project" {
}

variable "credentials_file" {}

variable "region" {
default = "us-east1"
}

variable "zone" {
default = "us-east1-c"
}

variable "docker_image" {
}

variable "node_id" {
}

# Secrets
variable "cipher_key" {
type = string
}

variable "sk_share" {
type = string
}
1 change: 1 addition & 0 deletions infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ variable "zone" {

# Application variables
variable "account_creator_id" {
default = "tmp_acount_creator.serhii.testnet"
}

variable "fast_auth_partners" {
Expand Down

0 comments on commit a4a0825

Please sign in to comment.