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

Additional terraform example #48

Merged
merged 5 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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: 18 additions & 0 deletions examples/env_with_dxe/README.md
Original file line number Diff line number Diff line change
@@ -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 |
calbritt marked this conversation as resolved.
Show resolved Hide resolved
| 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 |
10 changes: 10 additions & 0 deletions examples/env_with_dxe/input.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
consortium_name = "test-consortium"
kaleido_api_key = ""
env_name = "test-environment"
provider = "pantheon"
consensus = "ibft"
multi_region = "false"
node_count = 1
block_period = 2
gc_mode = "archive"
service_count = 4
79 changes: 79 additions & 0 deletions examples/env_with_dxe/main.tf
Original file line number Diff line number Diff line change
@@ -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
*/
calbritt marked this conversation as resolved.
Show resolved Hide resolved
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}"
calbritt marked this conversation as resolved.
Show resolved Hide resolved
size = "small"
}
65 changes: 65 additions & 0 deletions examples/env_with_dxe/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
}
Loading