From 448eb09e18e9b5fa05984201df1e1700a3c8dbe2 Mon Sep 17 00:00:00 2001 From: Cari Albritton Date: Tue, 3 Oct 2023 17:06:57 -0400 Subject: [PATCH 1/5] Add additional example Signed-off-by: Cari Albritton --- examples/env_with_dxe/README.md | 0 examples/env_with_dxe/input.tfvars | 10 ++++ examples/env_with_dxe/main.tf | 79 ++++++++++++++++++++++++++++++ examples/env_with_dxe/variables.tf | 65 ++++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 examples/env_with_dxe/README.md create mode 100644 examples/env_with_dxe/input.tfvars create mode 100644 examples/env_with_dxe/main.tf create mode 100644 examples/env_with_dxe/variables.tf diff --git a/examples/env_with_dxe/README.md b/examples/env_with_dxe/README.md new file mode 100644 index 0000000..e69de29 diff --git a/examples/env_with_dxe/input.tfvars b/examples/env_with_dxe/input.tfvars new file mode 100644 index 0000000..9bb6a08 --- /dev/null +++ b/examples/env_with_dxe/input.tfvars @@ -0,0 +1,10 @@ +consortium_name = "test-consortium" +kaleido_api_key = "" +env_name = "test-environment" +provider = "pantheon" +consensus = "ibft" +multi_region = "true" +node_count = 1 +block_period = 2 +gc_mode = "archive" +service_count = 4 diff --git a/examples/env_with_dxe/main.tf b/examples/env_with_dxe/main.tf new file mode 100644 index 0000000..a947a27 --- /dev/null +++ b/examples/env_with_dxe/main.tf @@ -0,0 +1,79 @@ +/* +This creates suite of environments using all available +environment types and consensus methods. +*/ + +provider "kaleido" { + api = "https://console${var.kaleido_region}.kaleido.io/api/v1" + api_key = "${var.kaleido_api_key}" +} + +/* +This represents a Consortia. Give it a name and a description. +"mode" can be set to "single-org" or ... +*/ +resource "kaleido_consortium" "consortium" { + name = "${var.consortium_name}" + description = "${var.network_description}" +} + +/* +This creates a membership for each node +*/ +resource "kaleido_membership" "member" { + count = "${var.node_count}" + consortium_id = "${kaleido_consortium.consortium.id}" + org_name = "Org ${count.index + 1}" +} + +/* +Create an environment +*/ +resource "kaleido_environment" "env" { + consortium_id = "${kaleido_consortium.consortium.id}" + multi_region = "${var.multi_region}" + name = "${var.env_name}" + env_type = "${var.provider}" + consensus_type = "${var.consensus}" + description = "${var.env_description}" + prefunded_accounts = "${var.prefunded_accounts}" +} + +/* +Create nodes +*/ +resource "kaleido_node" "kaleido" { + count = "${var.node_count}" + consortium_id = "${kaleido_consortium.consortium.id}" + environment_id = "${kaleido_environment.env.id}" + membership_id = "${element(kaleido_membership.member.*.id, count.index)}" + name = "Node ${count.index + 1}" + size = "${var.node_size}" +} + +/* +Create ipfs service +*/ +resource "kaleido_service" "kaleido" { + count = "${var.service_count}" + consortium_id = "${kaleido_consortium.consortium.id}" + environment_id = "${kaleido_environment.env.id}" + membership_id = "${element(kaleido_membership.member.*.id, count.index)}" + name = "IPFS ${count.index + 1}" + service_type = "ipfs" + + depends_on = ["kaleido_node.kaleido"] +} + +/* +Create DXE service +*/ +resource "kaleido_service" "dxe" { + count = "${var.service_count}" + consortium_id = "${kaleido_consortium.consortium.id}" + environment_id = "${kaleido_environment.env.id}" + membership_id = "${element(kaleido_membership.member.*.id, count.index)}" + service_type = "dataexchange" + name = "IPFS ${count.index + 1}" + size = "small" +} \ No newline at end of file diff --git a/examples/env_with_dxe/variables.tf b/examples/env_with_dxe/variables.tf new file mode 100644 index 0000000..3363070 --- /dev/null +++ b/examples/env_with_dxe/variables.tf @@ -0,0 +1,65 @@ +variable "kaleido_api_key" { + type = "string" + description = "Kaleido API Key" +} + +variable "kaleido_region" { + type = "string" + description = "Can be '-ap' for Sydney, or '-eu' for Frankfurt. Defaults to US" + default = "" +} + +variable "provider" { + type = "string" + default = "pantheon" + description = "Protocol implementation to deploy." +} + +variable "consensus" { + type = "string" + default = "ibft" + description = "Consensus mechanism." +} + +variable "multi_region" { + type = "string" + default = false + description = "Make the environment multi-region compatible to support additional regions, now or in the future" +} + +variable "node_size" { + type = "string" + default = "small" + description = "Size of the node" +} + +variable "node_count" { + type = "string" + default = 4 + description = "Count of nodes to create - each will have its own membership" +} + +variable "service_count" { + type = "string" + default = 1 + description = "Count of services to create - each will have its own membership" +} + +variable "consortium_name" { + type = "string" + default = "My Business Network" +} + +variable "env_name" { + type = "string" + default = "Development" +} + +variable "env_description" { + type = "string" + default = "Created with Terraform" +} +variable "network_description" { + type = "string" + default = "Modern Business Network - Built on Kaleido" +} From 467a08f22dabaa5525ed705eee6403abc9bdf057 Mon Sep 17 00:00:00 2001 From: Cari Albritton Date: Tue, 3 Oct 2023 17:11:07 -0400 Subject: [PATCH 2/5] add readme Signed-off-by: Cari Albritton --- examples/env_with_dxe/README.md | 18 ++++++++++++++++++ examples/env_with_dxe/input.tfvars | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/examples/env_with_dxe/README.md b/examples/env_with_dxe/README.md index e69de29..c4eea95 100644 --- a/examples/env_with_dxe/README.md +++ b/examples/env_with_dxe/README.md @@ -0,0 +1,18 @@ +## Summary + +Create an environment with: + +* Nodes and IPFS and Data Exchange Services + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| kaleido_api_key | Kaleido API Key | string | - | yes | +| kaleido_region | Can be '-ap' for Sydney, or '-eu' for Frankfurt. Defaults to US | string | `` | no | +| provider | Blockchain Provider for the environment. | string | `pantheon` | no | +| consensus | Consensus methods supported by pantheon. | list | `ibft` | no | +| multi_region | Multi region env | string | `false` | no | +| node_size | Size of the nodes to be created | string | `small` | no | +| node_count | Number of nodes to create | string | 4 | no | +| service_count | Number of services to create | string | 1 | no | diff --git a/examples/env_with_dxe/input.tfvars b/examples/env_with_dxe/input.tfvars index 9bb6a08..856a0d5 100644 --- a/examples/env_with_dxe/input.tfvars +++ b/examples/env_with_dxe/input.tfvars @@ -3,7 +3,7 @@ kaleido_api_key = "" env_name = "test-environment" provider = "pantheon" consensus = "ibft" -multi_region = "true" +multi_region = "false" node_count = 1 block_period = 2 gc_mode = "archive" From d034cc4863cb5084afbf231082eb388ac7607f81 Mon Sep 17 00:00:00 2001 From: Cari Albritton Date: Tue, 3 Oct 2023 20:29:46 -0400 Subject: [PATCH 3/5] multi region default Signed-off-by: Cari Albritton --- examples/env_with_dxe/input.tfvars | 2 +- examples/env_with_dxe/variables.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/env_with_dxe/input.tfvars b/examples/env_with_dxe/input.tfvars index 856a0d5..9bb6a08 100644 --- a/examples/env_with_dxe/input.tfvars +++ b/examples/env_with_dxe/input.tfvars @@ -3,7 +3,7 @@ kaleido_api_key = "" env_name = "test-environment" provider = "pantheon" consensus = "ibft" -multi_region = "false" +multi_region = "true" node_count = 1 block_period = 2 gc_mode = "archive" diff --git a/examples/env_with_dxe/variables.tf b/examples/env_with_dxe/variables.tf index 3363070..6a4f145 100644 --- a/examples/env_with_dxe/variables.tf +++ b/examples/env_with_dxe/variables.tf @@ -23,7 +23,7 @@ variable "consensus" { variable "multi_region" { type = "string" - default = false + default = true description = "Make the environment multi-region compatible to support additional regions, now or in the future" } From 5bd9104077b6479e243bfcb9650f5bc3996ca9d7 Mon Sep 17 00:00:00 2001 From: Cari Albritton Date: Tue, 3 Oct 2023 20:32:26 -0400 Subject: [PATCH 4/5] Update comments Signed-off-by: Cari Albritton --- examples/env_with_dxe/README.md | 2 +- examples/env_with_dxe/main.tf | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/env_with_dxe/README.md b/examples/env_with_dxe/README.md index c4eea95..1c150f6 100644 --- a/examples/env_with_dxe/README.md +++ b/examples/env_with_dxe/README.md @@ -12,7 +12,7 @@ Create an environment with: | kaleido_region | Can be '-ap' for Sydney, or '-eu' for Frankfurt. Defaults to US | string | `` | no | | provider | Blockchain Provider for the environment. | string | `pantheon` | no | | consensus | Consensus methods supported by pantheon. | list | `ibft` | no | -| multi_region | Multi region env | string | `false` | no | +| multi_region | Multi region env | string | `true` | no | | node_size | Size of the nodes to be created | string | `small` | no | | node_count | Number of nodes to create | string | 4 | no | | service_count | Number of services to create | string | 1 | no | diff --git a/examples/env_with_dxe/main.tf b/examples/env_with_dxe/main.tf index a947a27..b85f5b5 100644 --- a/examples/env_with_dxe/main.tf +++ b/examples/env_with_dxe/main.tf @@ -36,7 +36,6 @@ resource "kaleido_environment" "env" { env_type = "${var.provider}" consensus_type = "${var.consensus}" description = "${var.env_description}" - prefunded_accounts = "${var.prefunded_accounts}" } /* @@ -66,7 +65,8 @@ resource "kaleido_service" "kaleido" { } /* -Create DXE service +Create DXE service - please contact Kaleido support if you're interested in using DataExchange Enterprise for FireFly multi-party networks +https://hyperledger.github.io/firefly/v1.2.2/overview/multiparty/data_exchange.html */ resource "kaleido_service" "dxe" { count = "${var.service_count}" @@ -74,6 +74,6 @@ resource "kaleido_service" "dxe" { environment_id = "${kaleido_environment.env.id}" membership_id = "${element(kaleido_membership.member.*.id, count.index)}" service_type = "dataexchange" - name = "IPFS ${count.index + 1}" + name = "DXE ${count.index + 1}" size = "small" } \ No newline at end of file From 897b6b647eb932866e5a2d7867f496ec927b4afb Mon Sep 17 00:00:00 2001 From: Cari Albritton Date: Wed, 4 Oct 2023 08:09:29 -0400 Subject: [PATCH 5/5] Update variable name, add required provider, and remove quotes Signed-off-by: Cari Albritton --- examples/env_with_dxe/main.tf | 9 ++++++++- examples/env_with_dxe/variables.tf | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/examples/env_with_dxe/main.tf b/examples/env_with_dxe/main.tf index b85f5b5..8a5b3fc 100644 --- a/examples/env_with_dxe/main.tf +++ b/examples/env_with_dxe/main.tf @@ -2,6 +2,13 @@ This creates suite of environments using all available environment types and consensus methods. */ +terraform { + required_providers { + kaleido = { + source = "kaleido-io/kaleido" + } + } +} provider "kaleido" { api = "https://console${var.kaleido_region}.kaleido.io/api/v1" @@ -33,7 +40,7 @@ resource "kaleido_environment" "env" { consortium_id = "${kaleido_consortium.consortium.id}" multi_region = "${var.multi_region}" name = "${var.env_name}" - env_type = "${var.provider}" + env_type = "${var.provider_type}" consensus_type = "${var.consensus}" description = "${var.env_description}" } diff --git a/examples/env_with_dxe/variables.tf b/examples/env_with_dxe/variables.tf index 6a4f145..820964b 100644 --- a/examples/env_with_dxe/variables.tf +++ b/examples/env_with_dxe/variables.tf @@ -1,65 +1,65 @@ variable "kaleido_api_key" { - type = "string" + type = string description = "Kaleido API Key" } variable "kaleido_region" { - type = "string" + type = string description = "Can be '-ap' for Sydney, or '-eu' for Frankfurt. Defaults to US" default = "" } -variable "provider" { - type = "string" +variable "provider_type" { + type = string default = "pantheon" description = "Protocol implementation to deploy." } variable "consensus" { - type = "string" + type = string default = "ibft" description = "Consensus mechanism." } variable "multi_region" { - type = "string" + type = string default = true description = "Make the environment multi-region compatible to support additional regions, now or in the future" } variable "node_size" { - type = "string" + type = string default = "small" description = "Size of the node" } variable "node_count" { - type = "string" + type = string default = 4 description = "Count of nodes to create - each will have its own membership" } variable "service_count" { - type = "string" + type = string default = 1 description = "Count of services to create - each will have its own membership" } variable "consortium_name" { - type = "string" + type = string default = "My Business Network" } variable "env_name" { - type = "string" + type = string default = "Development" } variable "env_description" { - type = "string" + type = string default = "Created with Terraform" } variable "network_description" { - type = "string" + type = string default = "Modern Business Network - Built on Kaleido" }