-
Notifications
You must be signed in to change notification settings - Fork 12
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
Remote peering #81
Remote peering #81
Changes from all commits
4372b67
983b9d4
ef555f4
bd512ba
6323014
62b93b0
56e9265
1ded84e
2d5838f
9b7cb2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
kaleido_platform_api = "https://myaccount.kaleido.dev" | ||
kaleido_platform_username = "key1" | ||
kaleido_platform_password = "ac8255da-9ddf-4be4-92ad-daa957196e7a8e0328af-10b8-47f0-96ce-ebc042da7b89" | ||
environment_name = "env_alex" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.terraform* | ||
terraform.d | ||
terraform.tfstate* | ||
terraform.tfvars |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
terraform { | ||
required_providers { | ||
kaleido = { | ||
source = "kaleido-io/kaleido" | ||
version = "1.1.0-rc.4" | ||
configuration_aliases = [ kaleido.originator, kaleido.secondary ] | ||
} | ||
} | ||
} | ||
|
||
provider "kaleido" { | ||
alias = "originator" | ||
platform_api = var.originator_api_url | ||
platform_username = var.originator_api_key_name | ||
platform_password = var.originator_api_key_value | ||
} | ||
|
||
provider "kaleido" { | ||
alias = "secondary" | ||
platform_api = var.secondary_api_url | ||
platform_username = var.secondary_api_key_name | ||
platform_password = var.secondary_api_key_value | ||
} | ||
|
||
// Environment 1 - the originator of the network | ||
|
||
resource "kaleido_platform_environment" "env_og" { | ||
provider = kaleido.originator | ||
name = var.originator_name | ||
} | ||
|
||
resource "kaleido_platform_network" "net_og" { | ||
provider = kaleido.originator | ||
type = "Besu" | ||
name = var.originator_name | ||
environment = kaleido_platform_environment.env_og.id | ||
init_mode = "automated" | ||
|
||
config_json = jsonencode({ | ||
chainID = 12345 | ||
bootstrapOptions = { | ||
qbft = { | ||
blockperiodseconds = 5 | ||
} | ||
eipBlockConfig = { | ||
shanghaiTime = 0 | ||
} | ||
initialBalances = { | ||
"0x12F62772C4652280d06E64CfBC9033d409559aD4" = "0x111111111111", | ||
} | ||
blockConfigFlags = { | ||
zeroBaseFee = true | ||
} | ||
} | ||
}) | ||
} | ||
|
||
|
||
resource "kaleido_platform_runtime" "bnr_signer_net_og" { | ||
provider = kaleido.originator | ||
type = "BesuNode" | ||
name = "${var.originator_name}_signer${count.index+1}" | ||
environment = kaleido_platform_environment.env_og.id | ||
config_json = jsonencode({}) | ||
count = var.originator_signer_count | ||
} | ||
|
||
resource "kaleido_platform_service" "bns_signer_net_og" { | ||
provider = kaleido.originator | ||
type = "BesuNode" | ||
name = "${var.originator_name}_signer${count.index+1}" | ||
environment = kaleido_platform_environment.env_og.id | ||
runtime = kaleido_platform_runtime.bnr_signer_net_og[count.index].id | ||
config_json = jsonencode({ | ||
network = { | ||
id = kaleido_platform_network.net_og.id | ||
} | ||
signer = true | ||
}) | ||
count = var.originator_signer_count | ||
} | ||
|
||
resource "kaleido_platform_runtime" "bnr_peer_net_og" { | ||
provider = kaleido.originator | ||
type = "BesuNode" | ||
name = "${var.originator_name}_peer${count.index+1}" | ||
environment = kaleido_platform_environment.env_og.id | ||
zone = var.originator_peer_network_dz | ||
config_json = jsonencode({}) | ||
count = var.originator_peer_count | ||
} | ||
|
||
resource "kaleido_platform_service" "bns_peer_net_og" { | ||
provider = kaleido.originator | ||
type = "BesuNode" | ||
name = "${var.originator_name}_peer${count.index+1}" | ||
environment = kaleido_platform_environment.env_og.id | ||
runtime = kaleido_platform_runtime.bnr_peer_net_og[count.index].id | ||
config_json = jsonencode({ | ||
network = { | ||
id = kaleido_platform_network.net_og.id | ||
} | ||
signer = false | ||
}) | ||
count = var.originator_peer_count | ||
} | ||
|
||
resource "kaleido_platform_runtime" "gwr_net_og" { | ||
provider = kaleido.originator | ||
type = "EVMGateway" | ||
name = "${var.originator_name}_gateway" | ||
environment = kaleido_platform_environment.env_og.id | ||
config_json = jsonencode({}) | ||
count = var.originator_gateway_count | ||
} | ||
|
||
|
||
resource "kaleido_platform_service" "gws_net_og" { | ||
provider = kaleido.originator | ||
type = "EVMGateway" | ||
name = "${var.originator_name}_gateway" | ||
environment = kaleido_platform_environment.env_og.id | ||
runtime = kaleido_platform_runtime.gwr_net_og[count.index].id | ||
config_json = jsonencode({ | ||
network = { | ||
id = kaleido_platform_network.net_og.id | ||
} | ||
}) | ||
count = var.originator_gateway_count | ||
} | ||
|
||
data "kaleido_platform_network_bootstrap_data" "net_og_bootstrap" { | ||
provider = kaleido.originator | ||
environment = kaleido_platform_environment.env_og.id | ||
network = kaleido_platform_network.net_og.id | ||
depends_on = [ | ||
kaleido_platform_service.bns_signer_net_og, | ||
kaleido_platform_network.net_og | ||
] | ||
} | ||
|
||
|
||
|
||
// Environment 2 - another member of the network | ||
|
||
resource "kaleido_platform_environment" "env_sec" { | ||
provider = kaleido.secondary | ||
name = var.secondary_name | ||
} | ||
|
||
resource "kaleido_platform_network" "net_sec" { | ||
provider = kaleido.secondary | ||
type = "Besu" | ||
name = var.secondary_name | ||
environment = kaleido_platform_environment.env_sec.id | ||
init_mode = "manual" | ||
file_sets = data.kaleido_platform_network_bootstrap_data.net_og_bootstrap.bootstrap_files != null ? { | ||
init = data.kaleido_platform_network_bootstrap_data.net_og_bootstrap.bootstrap_files | ||
} : {} | ||
init_files = data.kaleido_platform_network_bootstrap_data.net_og_bootstrap.bootstrap_files != null ? "init" : null | ||
config_json = jsonencode({}) | ||
depends_on = [kaleido_platform_network.net_og, kaleido_platform_service.bns_signer_net_og, data.kaleido_platform_network_bootstrap_data.net_og_bootstrap] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah also true. I will remove and retest it |
||
} | ||
|
||
resource "kaleido_platform_runtime" "bnr_peer_net_sec" { | ||
provider = kaleido.secondary | ||
type = "BesuNode" | ||
name = "${var.secondary_name}_peer${count.index+1}" | ||
environment = kaleido_platform_environment.env_sec.id | ||
zone = var.secondary_peer_network_dz | ||
config_json = jsonencode({}) | ||
count = var.secondary_peer_count | ||
depends_on = [kaleido_platform_network.net_sec] | ||
} | ||
|
||
resource "kaleido_platform_service" "bns_peer_net_sec" { | ||
provider = kaleido.secondary | ||
type = "BesuNode" | ||
name = "${var.secondary_name}_peer${count.index+1}" | ||
environment = kaleido_platform_environment.env_sec.id | ||
runtime = kaleido_platform_runtime.bnr_peer_net_sec[count.index].id | ||
config_json = jsonencode({ | ||
network = { | ||
id = kaleido_platform_network.net_sec.id | ||
} | ||
signer = false | ||
}) | ||
count = var.secondary_peer_count | ||
} | ||
|
||
resource "kaleido_platform_runtime" "gwr_net_sec" { | ||
provider = kaleido.secondary | ||
type = "EVMGateway" | ||
name = "${var.originator_name}_gateway" | ||
environment = kaleido_platform_environment.env_sec.id | ||
config_json = jsonencode({}) | ||
depends_on = [kaleido_platform_network.net_sec] | ||
count = var.secondary_gateway_count | ||
} | ||
|
||
resource "kaleido_platform_service" "gws_net_sec" { | ||
provider = kaleido.secondary | ||
type = "EVMGateway" | ||
name = "${var.originator_name}_gateway" | ||
environment = kaleido_platform_environment.env_sec.id | ||
runtime = kaleido_platform_runtime.gwr_net_sec[count.index].id | ||
config_json = jsonencode({ | ||
network = { | ||
id = kaleido_platform_network.net_sec.id | ||
} | ||
}) | ||
count = var.secondary_gateway_count | ||
} | ||
|
||
|
||
// Authenticators | ||
resource "kaleido_platform_authenticator" "net_sec_authenticator" { | ||
provider = kaleido.secondary | ||
type = "Permitted" | ||
name = "${var.secondary_name}_auth" | ||
environment = kaleido_platform_environment.env_sec.id | ||
network = kaleido_platform_network.net_sec.id | ||
zone = var.secondary_peer_network_dz | ||
conn = var.secondary_peer_network_connection | ||
permitted_json = jsonencode({ peers = [ for peer in resource.kaleido_platform_service.bns_peer_net_og : jsondecode(peer.connectivity_json) ] }) | ||
depends_on = [kaleido_platform_network.net_sec, kaleido_platform_service.bns_peer_net_og] | ||
} | ||
|
||
|
||
resource "kaleido_platform_authenticator" "net_og_authenticator" { | ||
provider = kaleido.originator | ||
type = "Permitted" | ||
name = "${var.originator_name}_auth" | ||
environment = kaleido_platform_environment.env_og.id | ||
network = kaleido_platform_network.net_og.id | ||
zone = var.originator_peer_network_dz | ||
conn = var.originator_peer_network_connection | ||
permitted_json = jsonencode({ peers = [ for peer in resource.kaleido_platform_service.bns_peer_net_sec : jsondecode(peer.connectivity_json) ] }) | ||
depends_on = [kaleido_platform_network.net_og, kaleido_platform_service.bns_peer_net_sec] | ||
} | ||
Comment on lines
+216
to
+240
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah nice right. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
kaleido_platform_api_baseurl = "kaleido.dev" | ||
|
||
originator_account_name = "myaccount" | ||
originator_api_key_name = "key1" | ||
originator_api_key_value = "1dbf8a3a-51c0-4e5e-a36a-50c58535db1b60cb9dc4-691c-4243-b88e-221a890cc511" | ||
|
||
secondary_account_name = "other" | ||
secondary_api_key_name = "key1" | ||
secondary_api_key_value = "fc07c759-dace-445e-9a06-8c21cca4e7080cd9e28d-32f6-4c49-96b6-839d009fb1fb" | ||
|
||
originator_name = "besu_originator" | ||
originator_signer_count = 2 | ||
originator_peer_count = 1 | ||
originator_peer_network_dz = "local-external-zone-1" | ||
originator_peer_network_connection = "local" | ||
|
||
secondary_name = "besu_secondary" | ||
secondary_peer_count = 2 | ||
secondary_peer_network_dz = "local-external-zone-1" | ||
secondary_peer_network_connection = "local" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
|
||
variable "originator_api_url" { | ||
type = string | ||
} | ||
|
||
variable "originator_api_key_name" { | ||
type = string | ||
} | ||
|
||
variable "originator_api_key_value" { | ||
type = string | ||
} | ||
|
||
variable "secondary_api_url" { | ||
type = string | ||
} | ||
|
||
variable "secondary_api_key_name" { | ||
type = string | ||
} | ||
|
||
variable "secondary_api_key_value" { | ||
type = string | ||
} | ||
|
||
variable "originator_name" { | ||
type = string | ||
} | ||
|
||
variable "secondary_name" { | ||
type = string | ||
} | ||
|
||
variable "originator_signer_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "originator_peer_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "secondary_peer_count" { | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "originator_peer_network_dz" { | ||
type = string | ||
} | ||
|
||
variable "originator_peer_network_connection" { | ||
type = string | ||
} | ||
|
||
variable "secondary_peer_network_dz" { | ||
type = string | ||
} | ||
|
||
variable "secondary_peer_network_connection" { | ||
type = string | ||
} | ||
|
||
variable "originator_gateway_count" { | ||
type = number | ||
default = 1 | ||
validation { | ||
condition = contains([0, 1], var.originator_gateway_count) | ||
error_message = "Valid values for originator_gateway_count are (0, 1)" | ||
} | ||
} | ||
|
||
variable "secondary_gateway_count" { | ||
type = number | ||
default = 1 | ||
validation { | ||
condition = contains([0, 1], var.secondary_gateway_count) | ||
error_message = "Valid values for secondary_gateway_count are (0, 1)" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the conditional if we have a proper dependency on the data object here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah good point. I will try removing it. I added this when I was trying to make it work with one resource before I added the datasource