Refactored variables file; changed TF infra - now fo each chain separate DB instance will be created; fixed bug with multiple chains created

This commit is contained in:
Arsenii Petrovich 2019-03-06 00:54:43 +03:00
parent b00c9cbf72
commit cadeea976c
13 changed files with 358 additions and 248 deletions

2
.gitignore vendored
View File

@ -22,3 +22,5 @@ roles/main_infra/files/terraform.tfvars
group_vars/*.yml
*.retry
*.temp
*.swp
.*.swp

View File

@ -58,13 +58,6 @@ public_subnet_cidr: "10.0.0.0/24"
db_subnet_cidr: "10.0.1.0/24"
dns_zone_name: "poa.internal"
prefix: "sokol"
db_id: "poa"
db_name: "poa"
db_username: "username"
db_password: "qwerty12345"
db_instance_class: "db.m4.xlarge"
db_storage: "120"
db_storage_type: "gp2"
use_ssl: "false"
alb_ssl_policy: "ELBSecurityPolicy-2016-08"
alb_certificate_arn: "arn:aws:acm:us-east-1:290379793816:certificate/6d1bab74-fb46-4244-aab2-832bf519ab24"
@ -107,6 +100,39 @@ networks: >
chain_graphiql_transaction = {
"mychain" = "0xbc426b4792c48d8ca31ec9786e403866e14e7f3e4d39c7f2852e518fae529ab4"
}
chain_block_transformer = {
"mychain" = "base"
}
chain_heart_beat_timeout = {
"mychain" = 30
}
chain_heart_command = {
"mychain" = "systemctl restart explorer.service"
}
chain_blockscout_version = {
"mychain" = "v1.3.0-beta"
}
chain_db_name = {
"mychain" = "myname"
}
chain_db_username = {
"mychain" = "myusername"
}
chain_db_password = {
"mychain" = "mypassword"
}
chain_db_instance_class = {
"mychain" = "db.m4.xlarge"
}
chain_db_storage = {
"mychain" = "200"
}
chain_db_storage_type = {
"mychain" = "gp2"
}
chain_db_version = {
"mychain" = "10.5"
}
```
- `aws_access_key` and `aws_secret_key` is a credentials pair that provides access to AWS for the deployer;
@ -118,7 +144,6 @@ networks: >
- `vpc_cidr`, `public_subnet_cidr`, `db_subnet_cidr` represents the network configuration for the deployment. Usually you want to leave it as is. However, if you want to modify it, please, expect that `db_subnet_cidr` represents not a single network, but a group of networks united with one CIDR block that will be divided during the deployment. For details, see [subnets.tf](https://github.com/ArseniiPetrovich/blockscout-terraform/blob/master/roles/main_infra/files/subnets.tf#L35) for details;
- An internal DNS zone with`dns_zone_name` name will be created to take care of BlockScout internal communications;
- `prefix` - is a unique tag to use for provisioned resources (5 alphanumeric chars or less);
- `db_id` and `db_name` identifies your database among others. The `db_username` and `db_password` can be a changed to any alphanumeric value. The `db_instance_class`,`db_storage` and `db_storage_type` are not required but are defaulted to `db.m4.large` , `120GB` and `gp2` respectively;
- The name of a IAM key pair to use for EC2 instances, if you provide a name which
already exists it will be used, otherwise it will be generated for you;
@ -144,6 +169,9 @@ networks: >
- `chain_network_path` - a relative URL path which will be used as an endpoint for defined chain. For example, if we will have our BlockScout at `blockscout.com` domain and place `core` network at `/poa/core`, then the resulting endpoint will be `blockscout.com/poa/core` for this network.
- `chain_network_icon` - maps the chain name to the network navigation icon at apps/block_scout_web/lib/block_scout_web/templates/icons without .eex extension
- `chain_graphiql_transaction` - is a variable that maps chain to a random transaction hash on that chain. This hash will be used to provide a sample query in the GraphIQL Playground.
- `chain_block_transformer` - will be `clique` for clique networks like Rinkeby and Goerli, and `base` for the rest;
- `chain_heart_beat_timeout`, `chain_heart_command` - configs for the integrated heartbeat. First describes a timeout after the command described at the second variable will be executed;
- Each of the `chain_db_*` variables configures the database for each chain. Each chain will have the separate RDS instance.
Chain configuration will be stored in the Systems Manager Parameter Store, each chain has its own set of config values. If you modify one of these values, you will need to go and terminate the instances for that chain so that they are reprovisioned with the new configuration.
@ -227,7 +255,7 @@ Error: Error applying plan:
Please include the following information in your report:
Terraform Version: 0.11.7
Terraform Version: 0.11.11
Resource ID: aws_autoscaling_group.explorer
Mismatch reason: attribute mismatch: availability_zones.1252502072
```

View File

@ -34,15 +34,6 @@ dns_zone_name: "poa.internal"
## All resources will be prefixed with this one
prefix: "sokol"
## The following settings are related to the Postgres RDS instance which will be created during deployment
db_id: "poa"
db_username: "username"
db_password: "qwerty12345"
db_instance_class: "db.m4.xlarge"
db_storage: "120"
db_storage_type: "gp2"
db_version: "10.5"
## The following settngs are related to SSL of Application Load Balancer that will be deployed to AWS. If use_ssl is set to false, alb_* variables can be omitted
use_ssl: "false"
alb_ssl_policy: "ELBSecurityPolicy-2016-08"
@ -65,124 +56,114 @@ new_relic_app_name: ""
new_relic_license_key: ""
# Network related variables
## The following set of chain_* variables has Terraform HCL syntax and should be filled accordingly. For example for core and sokol network you should fill this variables as follows:
## This variable represents network RPC endpoint:
# chains = {
# "core" = "http://10.10.10.10:8545",
# "sokol" = "https://192.168.0.1:8545"
# }
chains:
core: "http://10.10.10.10:8545"
sokol: "https://192.168.0.1:8545"
## This variable represents network RPC endpoint in trace mode. Can be the same as the previous variable:
# chain_trace_endpoint = {
# "core" = "http://10.10.10.11:8545",
# "sokol" = "http://192.168.0.1:8546"
# }
chain_trace_endpoint:
core: "http://10.10.10.11:8545"
sokol: "http://192.168.0.1:8546"
## This variable represents network RPC endpoint in websocket mode:
# chain_ws_endpoint = {
# "core" = "ws://10.10.10.10/ws",
# "sokol" = "ws://192.168.0.1/ws"
# }
chain_ws_endpoint:
core: "ws://10.10.10.10/ws"
sokol: "ws://192.168.0.1/ws"
## Next variable represents the client that is used to connect to the chain.
# chain_jsonrpc_variant = {
# "core" = "parity",
# "sokol" = "geth"
# }
chain_jsonrpc_variant:
core: "parity"
sokol: "geth"
## Place your own logo at apps/block_scout_web/assets/static folder of blockscout repo and specify a relative path here
# chain_logo = {
# "core" = "/images/core.svg",
# "sokol" = "/images/sokol.svg"
# }
chain_logo:
core: "/images/core.svg"
sokol: "/images/sokol.svg"
## The following variables represents a name of the coin that will be shown at blockchain explorer
# chain_coin = {
# "core" = "POA",
# "sokol" = "POA"
# }
chain_coin:
core: "POA"
sokol: "POA"
## Next variable usually represents the name of the organization/community that hosts the chain
# chain_network = {
# "core" = "POA Network",
# "sokol" = "POA Network"
# }
chain_network:
core: "POA Network"
sokol: "POA Network"
## Next variable represents the actual name of the particular network
# chain_subnetwork = {
# "core" = "POA Core Network",
# "sokol" = "POA Sokol test network"
# }
chain_subnetwork:
core: "POA Core Network"
sokol: "POA Sokol test network"
## The next variable represent a relative URL path which will be used as an endpoint for defined chain. For example, if we will have our blockscout at blockscout.com domain and place "core" network at "/poa/core", then the resulting endpoint will be blockscout.com/poa/core for this network.
# chain_network_path = {
# "core" = "/poa/core",
# "sokol" = "/poa/sokol"
# }
chain_network_path:
core: "/poa/core"
sokol: "/poa/sokol"
## The following variable maps the chain name to the network navigation icon at apps/block_scout_web/lib/block_scout_web/templates/icons without .eex extension
# chain_network_icon = {
# "core" = "_test_network_icon.html",
# "sokol" = "_test_network_icon.html"
# }
chain_network_icon:
core: "_test_network_icon.html"
sokol: "_test_network_icon.html"
## The following variable maps the chain names to random transaction hash on that chain. "chain_graphiql_transaction" is a variable that takes a transaction hash from a network to provide a sample query in the GraphIQL Playground.
# chain_graphiql_transaction = {
# "core" = "0xbc426b4792c48d8ca31ec9786e403866e14e7f3e4d39c7f2852e518fae529ab4",
# "sokol" = "0xbc426b4792c48d8ca31ec9786e403866e14e7f3e4d39c7f2852e518fae529ab5"
# }
chain_graphiql_transaction:
core: "0xbc426b4792c48d8ca31ec9786e403866e14e7f3e4d39c7f2852e518fae529ab4"
sokol: "0xbc426b4792c48d8ca31ec9786e403866e14e7f3e4d39c7f2852e518fae529ab5"
## A variable required in indexer configuration files. Can be either base or clique. Usually you don't want to change this value unless you know what are you doing.
# chain_block_transformer = {
# "core" = "base",
# "rinkeby" = "clique"
# }
chain_block_transformer:
core: "base"
sokol: "base"
## Heartbeat is an Erlang monitoring service that will restart BlockScout if it becomes unresponsive. The following two variables configures the timeout before Blockscout will be restarted and command to restart. Usually you don't want to change these values.
# chain_heart_beat_timeout = {
# "core" = 30,
# "sokol" = 30
# }
# chain_heart_command = {
# "core" = "systemctl restart explorer.service",
# "sokol" = "systemctl restart explorer.service"
# }
chain_heart_beat_timeout:
core: 30
sokol: 30
chain_heart_command:
core: "systemctl restart explorer.service"
sokol: "systemctl restart explorer.service"
## This value describes a version of Blockscout that will be shown at the footer. You can write any text there you want to see at the footer.
# chain_blockscout_version = {
# "core" = "v1.3.4-beta",
# "sokol" = "v1.3.4-beta"
# }
networks: >
chains = {
"mychain" = "url/to/endpoint"
}
chain_trace_endpoint = {
"mychain" = "url/to/debug/endpoint/or/the/main/chain/endpoint"
}
chain_ws_endpoint = {
"mychain" = "url/to/websocket/endpoint"
}
chain_jsonrpc_variant = {
"mychain" = "parity"
}
chain_logo = {
"mychain" = "url/to/logo"
}
chain_coin = {
"mychain" = "coin"
}
chain_network = {
"mychain" = "network name"
}
chain_subnetwork = {
"mychain" = "subnetwork name"
}
chain_network_path = {
"mychain" = "path/to/root"
}
chain_network_icon = {
"mychain" = "_test_network_icon.html"
}
chain_graphiql_transaction = {
"mychain" = "0xbc426b4792c48d8ca31ec9786e403866e14e7f3e4d39c7f2852e518fae529ab4"
}
chain_block_transformer = {
"mychain" = "base"
}
chain_heart_beat_timeout = {
"mychain" = 30
}
chain_heart_command = {
"mychain" = "systemctl restart explorer.service"
}
chain_blockscout_version = {
"mychain" = "v1.3.0-beta"
}
chain_blockscout_version:
core: "v1.3.4-beta"
sokol: "v1.3.4-beta"
## This value represents the name of the DB that will be created/attached. Must be unique. Will be prefixed with `prefix` variable.
chain_db_id:
core: "core"
sokol: "sokol"
## Each network should have it's own DB. This variable maps chain to DB name. Should not be messed with db_id variable, which represents the RDS instance ID.
chain_db_name:
core: "core"
sokol: "sokol"
## The following variables describes the DB configurations for each network including usernames, password, instance class, etc.
chain_db_username:
core: "core"
sokol: "sokol"
chain_db_password:
core: "fkowfjpoi309021"
sokol: "kopsdOPpa9213K"
chain_db_instance_class:
core: "db.m4.xlarge"
sokol: "db.m4.large"
# Size of storage in GiB.
chain_db_storage:
core: "200"
sokol: "100"
# Type of disk to be used for the DB.
chain_db_storage_type:
core: "io1"
sokol: "gp2"
# Blockscout uses Postgres as the DB engine. This variable describes the Postgres version used in each particular chain.
chain_db_version:
core: "10.5"
sokol: "10.6"

View File

@ -24,10 +24,15 @@
when: backend|bool == true
#Workaround since terraform module return unexpected error.
- name: Attach RDS to the current deployment
shell: "echo yes | {{ terraform_location }} {{ item }}"
- name: Initialize Terraform
shell: "echo yes | {{ terraform_location }} init{{ ' -backend-config=backend.tfvars' if backend|bool == true else '' }}"
args:
chdir: "roles/main_infra/files"
with_items:
- "init{{ ' -backend-config=backend.tfvars' if backend|bool == true else '' }}"
- "import aws_db_instance.default {{ prefix }}-{{ db_id }}"
- name: Attach existing DB instances
shell: "echo yes | {{ terraform_location }} import aws_db_instance.default[{{ index }}] {{ prefix }}-{{ item.value }}"
args:
chdir: "roles/main_infra/files"
loop: "{{ chain_db_id|dict2items }}"
loop_control:
index_var: index

View File

@ -1,9 +1,8 @@
dynamodb_table: "poa-terraform-lock"
bucket: "poa-terraform-state"
terraform_location: "/usr/local/bin/terraform"
region: "us-east-1"
prefix: "sokol"
prefix: "test"
vpc_cidr: "10.0.0.0/16"
public_subnet_cidr: "10.0.0.0/24"
db_subnet_cidr: "10.0.2.0/16"
@ -11,68 +10,7 @@ dns_zone_name: "poa.internal"
instance_type: "m5.large"
root_block_size: 8
pool_size: 30
ec2_ssh_key_name: "sokol-test"
ec2_ssh_key_content: ""
db_id: "poa"
db_name: "poa"
db_username: "username"
db_password: "qwerty12345"
db_instance_class: "db.m4.xlarge"
db_storage: "120"
db_storage_type: "gp2"
db_version: "10.5"
alb_ssl_policy: "ELBSecurityPolicy-2016-08"
alb_certificate_arn: "arn:aws:acm:us-east-1:008312654217:certificate/ce6ec2cb-eba4-4b02-af1d-e77ce8813497"
new_relic_app_name: ""
new_relic_license_key: ""
secret_key_base: "TPGMvGK0iIwlXBQuQDA5KRqk77VETbEBlG4gAWeb93TvBsYAjvoAvdODMd6ZeguPwf2YTRY3n7uvxXzQP4WayQ=="
use_ssl: false
networks: >
chains = {
"mychain" = "url/to/endpoint"
}
chain_trace_endpoint = {
"mychain" = "url/to/debug/endpoint/or/the/main/chain/endpoint"
}
chain_ws_endpoint = {
"mychain" = "url/to/websocket/endpoint"
}
chain_jsonrpc_variant = {
"mychain" = "parity"
}
chain_logo = {
"mychain" = "url/to/logo"
}
chain_coin = {
"mychain" = "coin"
}
chain_network = {
"mychain" = "network name"
}
chain_subnetwork = {
"mychain" = "subnetwork name"
}
chain_network_path = {
"mychain" = "path/to/root"
}
chain_network_icon = {
"mychain" = "_test_network_icon.html"
}
chain_graphiql_transaction = {
"mychain" = "0xbc426b4792c48d8ca31ec9786e403866e14e7f3e4d39c7f2852e518fae529ab4"
}
chain_block_transformer = {
"mychain" = "base"
}
chain_heart_beat_timeout = {
"mychain" = 30
}
chain_heart_command = {
"mychain" = "systemctl restart explorer.service"
}
chain_blockscout_version = {
"mychain" = "v1.3.0-beta"
}

View File

@ -1,7 +1,7 @@
resource "aws_ssm_parameter" "block_transformer" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/block_transformer"
value = "${element(values(var.chain_block_transformer),count.index)}"
value = "${lookup(var.chain_block_transformer,element(keys(var.chains),count.index))}"
type = "String"
}
@ -36,7 +36,7 @@ resource "aws_ssm_parameter" "ecto_use_ssl" {
resource "aws_ssm_parameter" "ethereum_jsonrpc_variant" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/ethereum_jsonrpc_variant"
value = "${element(values(var.chain_jsonrpc_variant),count.index)}"
value = "${lookup(var.chain_jsonrpc_variant,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "ethereum_url" {
@ -49,62 +49,62 @@ resource "aws_ssm_parameter" "ethereum_url" {
resource "aws_ssm_parameter" "trace_url" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/ethereum_jsonrpc_trace_url"
value = "${element(values(var.chain_trace_endpoint),count.index)}"
value = "${lookup(var.chain_trace_endpoint,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "ws_url" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/ethereum_jsonrpc_ws_url"
value = "${element(values(var.chain_ws_endpoint),count.index)}"
value = "${lookup(var.chain_ws_endpoint,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "logo" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/logo"
value = "${element(values(var.chain_logo),count.index)}"
value = "${lookup(var.chain_logo,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "coin" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/coin"
value = "${element(values(var.chain_coin),count.index)}"
value = "${lookup(var.chain_coin,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "network" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/network"
value = "${element(values(var.chain_network),count.index)}"
value = "${lookup(var.chain_network,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "subnetwork" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/subnetwork"
value = "${element(values(var.chain_subnetwork),count.index)}"
value = "${lookup(var.chain_subnetwork,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "network_path" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/network_path"
value = "${element(values(var.chain_network_path),count.index)}"
value = "${lookup(var.chain_network_path,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "network_icon" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/network_icon"
value = "${element(values(var.chain_network_icon),count.index)}"
value = "${lookup(var.chain_network_icon,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "graphiql_transaction" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/graphiql_transaction"
value = "${element(values(var.chain_graphiql_transaction),count.index)}"
value = "${lookup(var.chain_graphiql_transaction,element(keys(var.chains),count.index))}"
type = "String"
}
@ -160,28 +160,28 @@ resource "aws_ssm_parameter" "port" {
resource "aws_ssm_parameter" "db_username" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_username"
value = "${var.db_username}"
value = "${lookup(var.chain_db_username,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "db_password" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_password"
value = "${var.db_password}"
value = "${lookup(var.chain_db_password,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "db_host" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_host"
value = "${aws_route53_record.db.fqdn}"
value = "${aws_route53_record.db.*.fqdn[count.index]}"
type = "String"
}
resource "aws_ssm_parameter" "db_port" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_port"
value = "${aws_db_instance.default.port}"
value = "${aws_db_instance.default.*.port[count.index]}"
type = "String"
}
resource "aws_ssm_parameter" "alb_ssl_policy" {
@ -199,21 +199,27 @@ resource "aws_ssm_parameter" "alb_certificate_arn" {
resource "aws_ssm_parameter" "heart_beat_timeout" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/heart_beat_timeout"
value = "${element(values(var.chain_heart_beat_timeout),count.index)}"
value = "${lookup(var.chain_heart_beat_timeout,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "heart_command" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/heart_command"
value = "${element(values(var.chain_heart_command),count.index)}"
value = "${lookup(var.chain_heart_command,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "blockscout_version" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/blockscout_version"
value = "${element(values(var.chain_blockscout_version),count.index)}"
value = "${lookup(var.chain_blockscout_version,element(keys(var.chains),count.index))}"
type = "String"
}
resource "aws_ssm_parameter" "db_name" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_name"
value = "${lookup(var.chain_db_name,element(keys(var.chains),count.index))}"
type = "String"
}

View File

@ -12,12 +12,13 @@ resource "aws_route53_zone" "main" {
# Private DNS records
resource "aws_route53_record" "db" {
zone_id = "${aws_route53_zone.main.zone_id}"
name = "db"
name = "db${count.index}"
type = "A"
count = "${length(var.chains)}"
alias {
name = "${aws_db_instance.default.address}"
zone_id = "${aws_db_instance.default.hosted_zone_id}"
name = "${aws_db_instance.default.*.address[count.index]}"
zone_id = "${aws_db_instance.default.*.hosted_zone_id[count.index]}"
evaluate_target_health = false
}
}

View File

@ -157,7 +157,7 @@ DB_USER="$(get_param 'db_username')"
DB_PASS="$(get_param 'db_password')"
DB_HOST="$(get_param 'db_host')"
DB_PORT="$(get_param 'db_port')"
DB_NAME="$CHAIN"
DB_NAME="$(get_param 'db_name')"
DATABASE_URL="postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT"
# Need to map the Parameter Store response to a set of NAME="<value>" entries,

View File

@ -29,7 +29,3 @@ To deploy a new version of the application manually:
OUTPUT
}
output "db_instance_address" {
description = "The internal IP address of the RDS instance"
value = "${aws_db_instance.default.address}"
}

View File

@ -1,14 +1,16 @@
resource "aws_db_instance" "default" {
identifier = "${var.prefix}-${var.db_id}"
count = "${length(var.chains)}"
name = "${lookup(var.chain_db_name,element(keys(var.chains),count.index))}"
identifier = "${var.prefix}-${lookup(var.chain_db_id,element(keys(var.chains),count.index))}"
engine = "postgres"
engine_version = "${var.db_version}"
instance_class = "${var.db_instance_class}"
storage_type = "${var.db_storage_type}"
allocated_storage = "${var.db_storage}"
engine_version = "${lookup(var.chain_db_version,element(keys(var.chains),count.index))}"
instance_class = "${lookup(var.chain_db_instance_class,element(keys(var.chains),count.index))}"
storage_type = "${lookup(var.chain_db_storage_type,element(keys(var.chains),count.index))}"
allocated_storage = "${lookup(var.chain_db_storage,element(keys(var.chains),count.index))}"
copy_tags_to_snapshot = true
skip_final_snapshot = true
username = "${var.db_username}"
password = "${var.db_password}"
username = "${lookup(var.chain_db_username,element(keys(var.chains),count.index))}"
password = "${lookup(var.chain_db_password,element(keys(var.chains),count.index))}"
vpc_security_group_ids = ["${aws_security_group.database.id}"]
db_subnet_group_name = "${aws_db_subnet_group.database.id}"
apply_immediately = true

View File

@ -60,21 +60,21 @@ resource "aws_lb_target_group" "explorer" {
# The Listener for the ALB (HTTP protocol)
resource "aws_alb_listener" "alb_listener_http" {
count = "${var.use_ssl == "true" ? 0 : 1}"
load_balancer_arn = "${aws_lb.explorer.arn}"
count = "${var.use_ssl == "true" ? 0 : length(var.chains)}"
load_balancer_arn = "${aws_lb.explorer.*.arn[count.index]}"
port = 80
protocol = "HTTP"
default_action {
type = "forward"
target_group_arn = "${aws_lb_target_group.explorer.arn}"
target_group_arn = "${aws_lb_target_group.explorer.*.arn[count.index]}"
}
}
# The Listener for the ALB (HTTPS protocol)
resource "aws_alb_listener" "alb_listener_https" {
count = "${var.use_ssl == "true" ? 1 : 0}"
load_balancer_arn = "${aws_lb.explorer.arn}"
count = "${var.use_ssl == "true" ? length(var.chains) : 0}"
load_balancer_arn = "${aws_lb.explorer.*.arn[count.index]}"
port = 443
protocol = "HTTPS"
ssl_policy = "${var.alb_ssl_policy}"
@ -82,6 +82,6 @@ resource "aws_alb_listener" "alb_listener_https" {
default_action {
type = "forward"
target_group_arn = "${aws_lb_target_group.explorer.arn}"
target_group_arn = "${aws_lb_target_group.explorer.*.arn[count.index]}"
}
}

View File

@ -47,13 +47,37 @@ variable "chain_graphiql_transaction" {
default = {}
}
variable "db_id" {}
variable "db_username" {}
variable "db_password" {}
variable "db_storage" {}
variable "db_storage_type" {}
variable "db_instance_class" {}
variable "db_version" {}
variable "chain_db_id" {
default = {}
}
variable "chain_db_name" {
default = {}
}
variable "chain_db_username" {
default = {}
}
variable "chain_db_password" {
default = {}
}
variable "chain_db_storage" {
default = {}
}
variable "chain_db_storage_type" {
default = {}
}
variable "chain_db_instance_class" {
default = {}
}
variable "chain_db_version" {
default = {}
}
variable "new_relic_app_name" {}
variable "new_relic_license_key" {}

View File

@ -10,14 +10,6 @@ instance_type = "{{ instance_type }}"
root_block_size = "{{ root_block_size }}"
pool_size = "{{ pool_size }}"
db_id = "{{ db_id }}"
db_username = "{{ db_username }}"
db_password = "{{ db_password }}"
db_instance_class = "{{ db_instance_class }}"
db_storage = "{{ db_storage }}"
db_storage_type = "{{ db_storage_type }}"
db_version = "{{ db_version }}"
alb_ssl_policy = "{{ alb_ssl_policy }}"
alb_certificate_arn = "{{ alb_certificate_arn }}"
use_ssl = "{{ use_ssl }}"
@ -25,5 +17,140 @@ new_relic_app_name = "{{ new_relic_app_name }}"
new_relic_license_key = "{{ new_relic_license_key }}"
secret_key_base = "{{ secret_key_base }}"
chains = {
{% for key, value in chains.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
{{ networks }}
chain_trace_endpoint = {
{% for key, value in chain_trace_endpoint.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_ws_endpoint = {
{% for key, value in chain_ws_endpoint.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_jsonrpc_variant = {
{% for key, value in chain_jsonrpc_variant.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_logo = {
{% for key, value in chain_logo.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_coin = {
{% for key, value in chain_coin.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_network = {
{% for key, value in chain_network.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_subnetwork = {
{% for key, value in chain_subnetwork.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_network_path = {
{% for key, value in chain_network_path.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_network_icon = {
{% for key, value in chain_network_icon.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_graphiql_transaction = {
{% for key, value in chain_graphiql_transaction.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_block_transformer = {
{% for key, value in chain_block_transformer.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_heart_beat_timeout = {
{% for key, value in chain_heart_beat_timeout.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_heart_command = {
{% for key, value in chain_heart_command.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_blockscout_version = {
{% for key, value in chain_blockscout_version.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_id = {
{% for key, value in chain_db_id.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_name = {
{% for key, value in chain_db_name.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_username = {
{% for key, value in chain_db_username.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_password = {
{% for key, value in chain_db_password.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_instance_class = {
{% for key, value in chain_db_instance_class.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_storage = {
{% for key, value in chain_db_storage.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_storage_type = {
{% for key, value in chain_db_storage_type.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}
chain_db_version = {
{% for key, value in chain_db_version.iteritems() %}
{{ key }} = "{{ value }}"{% if not loop.last %},{% endif %}
{% endfor %}
}