Remove multiple chain deploy and update readme

This commit is contained in:
Andrew Cravenho 2018-09-27 03:48:05 -04:00
parent b3b80eb021
commit bdab91c6a8
9 changed files with 130 additions and 193 deletions

View File

@ -126,15 +126,22 @@ root_block_size = 120
## Defining Chains/Adding Chains
The default of this repo is to build infra for the `sokol` chain, but you may not want that, or want a different set, so you need to create/edit `terraform.tfvars` or `user.auto.tfvars` and add the following configuration:
The default of this repo is to build infra for the `sokol` chain, but you may not want that, or want a different set, so you need to create/edit `terraform.tfvars` and add the following configuration:
```terraform
chains = {
"mychain" = "url/to/endpoint"
}
chain_trace_endpoints = {
"mychain" = "url/to/debug/endpoint/or/the/main/chain/endpoint"
}
chain_jsonrpc_variant = "parity"
chain = "sokol"
chain_ethereum_url = "https://sokol.poa.network"
chain_trace_endpoint = "https://sokol-trace.poa.network"
chain_ws_endpoint = "wss://sokol-ws.poa.network/ws"
chain_logo = "/images/sokol_logo.svg"
chain_check_origin = "[\"blockscout.com\"]"
chain_coin "POA"
chain_network "POA Network"
chain_subnetwork = "Sokol Testnet"
chain_network_path = "poa"
chain_subnetwork_path = "sokol"
chain_network_icon = "_test_network_icon.html"
```
This will ensure that those chains are used when provisioning the infrastructure.

View File

@ -13,16 +13,18 @@ module "stack" {
prefix = "${var.prefix}"
region = "${var.region}"
key_name = "${var.key_name}"
chains = "${var.chains}"
chain_trace_endpoints = "${var.chain_trace_endpoints}"
chain_ws_endpoints = "${var.chain_ws_endpoints}"
chain_jsonrpc_variant = "${var.chain_jsonrpc_variant}"
chain = "${var.chain}"
chain_ethereum_url = "${var.chain_ethereum_url}"
chain_trace_endpoint = "${var.chain_trace_endpoint}"
chain_ws_endpoint = "${var.chain_ws_endpoint}"
chain_logo = "${var.chain_logo}"
chain_css_file = "${var.chain_css_file}"
chain_check_origin = "${var.chain_check_origin}"
chain_coin = "${var.chain_coin}"
chain_network = "${var.chain_network}"
chain_subnetwork = "${var.chain_subnetwork}"
chain_network_navigation = "${var.chain_network_navigation}"
chain_network_path = "${var.chain_network_path}"
chain_subnetwork_path = "${var.chain_subnetwork_path}"
chain_network_icon = "${var.chain_network_icon}"
vpc_cidr = "${var.vpc_cidr}"

View File

@ -33,97 +33,69 @@ variable "root_block_size" {
default = 8
}
variable "chains" {
variable "chain" {
description = "A map of chain names to urls"
default = {
"sokol" = "https://sokol-trace.poa.network"
}
default = "sokol"
}
variable "chain_trace_endpoints" {
description = "A map of chain names to trace urls"
default = {
"sokol" = "https://sokol-trace.poa.network"
}
variable "chain_jsonrpc_variant" {
description = "The chain JSON RPC variant"
default = "parity"
}
variable "chain_ws_endpoints" {
description = "A map of chain names to websocket urls"
default = {
"sokol" = "wss://sokol-ws.poa.network/ws"
}
variable "chain_ethereum_url" {
description = "The base RPC endpoint for the chain"
default = "https://sokol.poa.network"
}
variable "chain_trace_endpoint" {
description = "A RPC tracing RPC endpoint"
default = "https://sokol-trace.poa.network"
}
variable "chain_ws_endpoint" {
description = "A Websocket RPC Endpoint for the chain"
default = "wss://sokol-ws.poa.network/ws"
}
variable "chain_logo" {
description = "A map of chain names to logo urls"
default = {
"sokol" = "/images/sokol_logo.svg"
}
}
variable "chain_css_file" {
description = "A map of chain names to the css file"
default = {
"sokol" = "sokol_variables"
}
description = "The logo url for the chain"
default = "/images/sokol_logo.svg"
}
variable "chain_check_origin" {
description = "A map of chain names to the check_origin configuration"
default = "['//*.blockscout.com']"
description = "The chain names to the check_origin configuration"
default = "false"
}
variable "chain_coin" {
description = "A map of chain names to the coin name"
default = {
"sokol" = "POA"
}
description = "The coin symbol"
default = "POA"
}
variable "chain_network" {
description = "A map of chain names to the network name"
default = {
"sokol" = "POA Network"
}
description = "The network name"
default = "POA Network"
}
variable "chain_subnetwork" {
description = "A map of chain names to the subnetwork name"
default = {
"sokol" = "Sokol Testnet"
}
description = "The subnetwork name"
default = "Sokol Testnet"
}
variable "chain_network_path" {
description = "A map of chain names to the network name"
default = {
"sokol" = "poa"
}
description = "The network name path"
default = "poa"
}
variable "chain_subnetwork_path" {
description = "A map of chain names to the subnetwork name"
default = {
"sokol" = "sokol"
}
description = "The subnetwork name path"
default = "sokol"
}
variable "chain_network_icon" {
description = "A map of chain names to the network navigation"
default = {
"sokol" = "_test_network_icon.html"
}
description = "The network navigation icon"
default = "_test_network_icon.html"
}
# RDS/Database configuration

View File

@ -1,192 +1,169 @@
resource "aws_ssm_parameter" "new_relic_app_name" {
count = "${var.new_relic_app_name == "" ? 0 : length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/new_relic_app_name"
name = "/${var.prefix}/${var.chain}/new_relic_app_name"
value = "${var.new_relic_app_name}"
type = "String"
}
resource "aws_ssm_parameter" "new_relic_license_key" {
count = "${var.new_relic_license_key == "" ? 0 : length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/new_relic_license_key"
name = "/${var.prefix}/${var.chain}/new_relic_license_key"
value = "${var.new_relic_license_key}"
type = "String"
}
resource "aws_ssm_parameter" "pool_size" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/pool_size"
name = "/${var.prefix}/${var.chain}/pool_size"
value = "10"
type = "String"
}
resource "aws_ssm_parameter" "ecto_use_ssl" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/ecto_use_ssl"
name = "/${var.prefix}/${var.chain}/ecto_use_ssl"
value = "false"
type = "String"
}
resource "aws_ssm_parameter" "ethereum_jsonrpc_variant" {
name = "/${var.prefix}/${var.chain}/ethereum_jsonrpc_variant"
value = "${var.chain_jsonrpc_variant}"
type = "String"
}
resource "aws_ssm_parameter" "ethereum_url" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/ethereum_url"
value = "${element(values(var.chains),count.index)}"
name = "/${var.prefix}/${var.chain}/ethereum_url"
value = "${var.chain_ethereum_url}"
type = "String"
}
resource "aws_ssm_parameter" "trace_url" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_trace_endpoints),count.index)}/trace_url"
value = "${element(values(var.chain_trace_endpoints), count.index)}"
name = "/${var.prefix}/${var.chain}/trace_url"
value = "${var.chain_trace_endpoint}"
type = "String"
}
resource "aws_ssm_parameter" "ws_url" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_ws_endpoints),count.index)}/ws_url"
value = "${element(values(var.chain_ws_endpoints), count.index)}"
name = "/${var.prefix}/${var.chain}/ws_url"
value = "${var.chain_ws_endpoint}"
type = "String"
}
resource "aws_ssm_parameter" "logo" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_logo),count.index)}/logo"
value = "${element(values(var.chain_logo), count.index)}"
type = "String"
}
resource "aws_ssm_parameter" "css_file" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_css_file),count.index)}/css_file"
value = "${element(values(var.chain_css_file), count.index)}"
name = "/${var.prefix}/${var.chain}/logo"
value = "${var.chain_logo}"
type = "String"
}
resource "aws_ssm_parameter" "check_origin" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/check_origin"
name = "/${var.prefix}/${var.chain}/check_origin"
value = "${var.chain_check_origin}"
type = "String"
}
resource "aws_ssm_parameter" "coin" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_coin),count.index)}/coin"
value = "${element(values(var.chain_coin), count.index)}"
name = "/${var.prefix}/${var.chain}/coin"
value = "${var.chain_coin}"
type = "String"
}
resource "aws_ssm_parameter" "network" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_network),count.index)}/network"
value = "${element(values(var.chain_network), count.index)}"
name = "/${var.prefix}/${var.chain}/network"
value = "${var.chain_network}"
type = "String"
}
resource "aws_ssm_parameter" "subnetwork" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_subnetwork),count.index)}/subnetwork"
value = "${element(values(var.chain_subnetwork), count.index)}"
name = "/${var.prefix}/${var.chain}/subnetwork"
value = "${var.chain_subnetwork}"
type = "String"
}
resource "aws_ssm_parameter" "network_path" {
name = "/${var.prefix}/${var.chain}/network_path"
value = "${var.chain_network_path}"
type = "String"
}
resource "aws_ssm_parameter" "subnetwork_path" {
name = "/${var.prefix}/${var.chain}/subnetwork_path"
value = "${var.chain_subnetwork_path}"
type = "String"
}
resource "aws_ssm_parameter" "network_icon" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_network_icon),count.index)}/network_icon"
value = "${element(values(var.chain_network_icon), count.index)}"
type = "String"
}
resource "aws_ssm_parameter" "network_navigation" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chain_network_navigation),count.index)}/network_navigation"
value = "${element(values(var.chain_network_navigation), count.index)}"
name = "/${var.prefix}/${var.chain}/network_icon"
value = "${var.chain_network_icon}"
type = "String"
}
resource "aws_ssm_parameter" "exq_blocks_concurrency" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/exq_blocks_concurrency"
name = "/${var.prefix}/${var.chain}/exq_blocks_concurrency"
value = "1"
type = "String"
}
resource "aws_ssm_parameter" "exq_concurrency" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/exq_concurrency"
name = "/${var.prefix}/${var.chain}/exq_concurrency"
value = "1"
type = "String"
}
resource "aws_ssm_parameter" "exq_internal_transactions_concurrency" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/exq_internal_transactions_concurrency"
name = "/${var.prefix}/${var.chain}/exq_internal_transactions_concurrency"
value = "1"
type = "String"
}
resource "aws_ssm_parameter" "exq_receipts_concurrency" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/exq_receipts_concurrency"
name = "/${var.prefix}/${var.chain}/exq_receipts_concurrency"
value = "1"
type = "String"
}
resource "aws_ssm_parameter" "exq_transactions_concurrency" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/exq_transactions_concurrency"
name = "/${var.prefix}/${var.chain}/exq_transactions_concurrency"
value = "1"
type = "String"
}
resource "aws_ssm_parameter" "secret_key_base" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/secret_key_base"
name = "/${var.prefix}/${var.chain}/secret_key_base"
value = "${var.secret_key_base}"
type = "String"
}
resource "aws_ssm_parameter" "port" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/port"
name = "/${var.prefix}/${var.chain}/port"
value = "4000"
type = "String"
}
resource "aws_ssm_parameter" "db_username" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_username"
name = "/${var.prefix}/${var.chain}/db_username"
value = "${var.db_username}"
type = "String"
}
resource "aws_ssm_parameter" "db_password" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_password"
name = "/${var.prefix}/${var.chain}/db_password"
value = "${var.db_password}"
type = "String"
}
resource "aws_ssm_parameter" "db_host" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_host"
name = "/${var.prefix}/${var.chain}/db_host"
value = "${aws_route53_record.db.fqdn}"
type = "String"
}
resource "aws_ssm_parameter" "db_port" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/db_port"
name = "/${var.prefix}/${var.chain}/db_port"
value = "${aws_db_instance.default.port}"
type = "String"
}
resource "aws_ssm_parameter" "alb_ssl_policy" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/alb_ssl_policy"
name = "/${var.prefix}/${var.chain}/alb_ssl_policy"
value = "${var.alb_ssl_policy}"
type = "String"
}
resource "aws_ssm_parameter" "alb_certificate_arn" {
count = "${length(var.chains)}"
name = "/${var.prefix}/${element(keys(var.chains),count.index)}/alb_certificate_arn"
name = "/${var.prefix}/${var.chain}/alb_certificate_arn"
value = "${var.alb_certificate_arn}"
type = "String"
}

View File

@ -12,7 +12,7 @@ resource "aws_codedeploy_app" "explorer" {
}
resource "aws_codedeploy_deployment_group" "explorer" {
count = "${length(var.chains)}"
count = 1
app_name = "${aws_codedeploy_app.explorer.name}"
deployment_group_name = "${var.prefix}-explorer-dg${count.index}"
service_role_arn = "${aws_iam_role.deployer.arn}"

View File

@ -40,17 +40,17 @@ resource "aws_launch_configuration" "explorer" {
}
resource "aws_placement_group" "explorer" {
count = "${length(var.chains)}"
count = 1
name = "${var.prefix}-explorer-placement-group${count.index}"
strategy = "cluster"
}
resource "aws_autoscaling_group" "explorer" {
count = "${length(var.chains)}"
count = 1
name = "${aws_launch_configuration.explorer.name}-asg${count.index}"
max_size = "${length(var.chains) * 4}"
min_size = "${length(var.chains)}"
desired_capacity = "${length(var.chains)}"
max_size = 4
min_size = 1
desired_capacity = 1
placement_group = "${aws_placement_group.explorer.*.id[count.index]}"
launch_configuration = "${aws_launch_configuration.explorer.name}"
vpc_zone_identifier = ["${aws_subnet.default.id}"]
@ -100,14 +100,14 @@ resource "aws_autoscaling_group" "explorer" {
tag {
key = "chain"
value = "${element(keys(var.chains),count.index)}"
value = "${var.chain}"
propagate_at_launch = true
}
}
# TODO: These autoscaling policies are not currently wired up to any triggers
resource "aws_autoscaling_policy" "explorer-up" {
count = "${length(var.chains)}"
count = 1
name = "${var.prefix}-explorer-autoscaling-policy-up${count.index}"
autoscaling_group_name = "${element(aws_autoscaling_group.explorer.*.name, count.index)}"
adjustment_type = "ChangeInCapacity"
@ -116,7 +116,7 @@ resource "aws_autoscaling_policy" "explorer-up" {
}
resource "aws_autoscaling_policy" "explorer-down" {
count = "${length(var.chains)}"
count = 1
name = "${var.prefix}-explorer-autoscaling-policy-down${count.index}"
autoscaling_group_name = "${element(aws_autoscaling_group.explorer.*.name, count.index)}"
adjustment_type = "ChangeInCapacity"

View File

@ -20,7 +20,7 @@ output "codedeploy_bucket_path" {
output "explorer_urls" {
description = "A map of each chain to the DNS name of its corresponding Explorer instance"
value = "${zipmap(keys(var.chains), aws_lb.explorer.*.dns_name)}"
value = "${aws_lb.explorer.*.dns_name}"
}
output "db_instance_address" {

View File

@ -17,8 +17,7 @@ resource "aws_route" "internet_access" {
# The ALB for the app server
resource "aws_lb" "explorer" {
count = "${length(var.chains)}"
name = "${var.prefix}-explorer-${element(keys(var.chains),count.index)}-alb"
name = "${var.prefix}-explorer-${var.chain}-alb"
internal = false
load_balancer_type = "application"
security_groups = ["${aws_security_group.alb.id}"]
@ -34,8 +33,7 @@ resource "aws_lb" "explorer" {
# The Target Group for the ALB
resource "aws_lb_target_group" "explorer" {
count = "${length(var.chains)}"
name = "${var.prefix}-explorer-${element(keys(var.chains),count.index)}-alb-target"
name = "${var.prefix}-explorer-${var.chain}-alb-target"
port = 4000
protocol = "HTTP"
vpc_id = "${aws_vpc.vpc.id}"

View File

@ -8,38 +8,19 @@ variable "dns_zone_name" {}
variable "instance_type" {}
variable "root_block_size" {}
variable "chains" {
default = {}
}
variable "chain_trace_endpoints" {
default = {}
}
variable "chain_ws_endpoints" {
default = {}
}
variable "chain_logo" {
default = {}
}
variable "chain_css_file" {
default = {}
}
variable "chain_jsonrpc_variant" {}
variable "chain" {}
variable "chain_ethereum_url" {}
variable "chain_trace_endpoint" {}
variable "chain_ws_endpoint" {}
variable "chain_logo" {}
variable "chain_check_origin" {}
variable "chain_coin" {
default = {}
}
variable "chain_network" {
default = {}
}
variable "chain_subnetwork" {
default = {}
}
variable "chain_network_icon" {
default = {}
}
variable "chain_network_navigation" {
default = {}
}
variable "chain_coin" {}
variable "chain_network" {}
variable "chain_subnetwork" {}
variable "chain_network_path" {}
variable "chain_subnetwork_path" {}
variable "chain_network_icon" {}
variable "db_id" {}
variable "db_name" {}