-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from dasmeta/DMVP-1232-refactor-dashboard-add-…
…new-widgets DMVP-1232: Added blocks
- Loading branch information
Showing
37 changed files
with
1,022 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
locals { | ||
# get all blocks and annotate | ||
initial_blocks = [ | ||
for index1, block in var.rows : { | ||
block : block[0], | ||
index1 : index1, | ||
type : replace(block[0].type, "block/", "") | ||
} if strcontains(block[0].type, "block/") | ||
] | ||
|
||
blocks_by_type_results = concat([ | ||
for type_blocks in local.blocks_by_type : [ | ||
for index3, block in type_blocks : merge(block, { results : local.blocks_results[block.type][index3] }) | ||
] | ||
]...) | ||
|
||
rows = concat([ | ||
for index1, row in var.rows : strcontains(row[0].type, "block/") ? | ||
concat([ | ||
for item in local.blocks_by_type_results : item.results if item.index1 == index1 | ||
]...) | ||
: [row] | ||
]...) | ||
|
||
# bring all module results together | ||
blocks_results = { | ||
rds = module.block_rds.*.result | ||
dns = module.block_dns.*.result | ||
cdn = module.block_cdn.*.result | ||
alb = module.block_alb.*.result | ||
service = module.block_service.*.result | ||
sla = module.block_sla.*.result | ||
} | ||
|
||
# annotate each block type with subIndex | ||
blocks_by_type = { | ||
rds = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "rds")], | ||
dns = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "dns")], | ||
cdn = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "cdn")], | ||
alb = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "alb")] | ||
service = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "service")] | ||
sla = [for index2, block in local.initial_blocks : merge(block, { index2 : index2 }) if strcontains(block.type, "sla")] | ||
} | ||
} | ||
|
||
# get modules replace block with subset | ||
module "block_rds" { | ||
source = "./modules/blocks/rds" | ||
|
||
count = length(local.blocks_by_type.rds) | ||
|
||
name = local.blocks_by_type.rds[count.index].block.name | ||
db_max_connections_count = local.blocks_by_type.rds[count.index].block.db_max_connections_count | ||
region = var.region != "" ? var.region : data.aws_region.current.name | ||
} | ||
|
||
module "block_dns" { | ||
source = "./modules/blocks/dns" | ||
|
||
count = length(local.blocks_by_type.dns) | ||
|
||
zone_name = local.blocks_by_type.dns[count.index].block.zone_name | ||
} | ||
|
||
module "block_cdn" { | ||
source = "./modules/blocks/cdn" | ||
|
||
count = length(local.blocks_by_type.cdn) | ||
|
||
cdn_id = local.blocks_by_type.cdn[count.index].block.cdn_id | ||
} | ||
|
||
module "block_alb" { | ||
source = "./modules/blocks/alb" | ||
|
||
count = length(local.blocks_by_type.alb) | ||
|
||
balancer_name = local.blocks_by_type.alb[count.index].block.balancer_name | ||
account_id = local.blocks_by_type.alb[count.index].block.account_id | ||
region = var.region != "" ? var.region : data.aws_region.current.name | ||
} | ||
|
||
module "block_service" { | ||
source = "./modules/blocks/service" | ||
|
||
count = length(local.blocks_by_type.service) | ||
|
||
service_name = local.blocks_by_type.service[count.index].block.service_name | ||
balancer_name = local.blocks_by_type.service[count.index].block.balancer_name | ||
target_group_arn = local.blocks_by_type.service[count.index].block.target_group_arn | ||
healthcheck_id = local.blocks_by_type.service[count.index].block.healthcheck_id | ||
cluster = local.blocks_by_type.service[count.index].block.cluster | ||
region = var.region != "" ? var.region : data.aws_region.current.name | ||
} | ||
|
||
module "block_sla" { | ||
source = "./modules/blocks/sla" | ||
|
||
count = length(local.blocks_by_type.sla) | ||
|
||
balancer_name = local.blocks_by_type.service[count.index].block.balancer_name | ||
region = var.region != "" ? var.region : data.aws_region.current.name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# sqs | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_lb.balancer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lb) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | AWS account ID | `string` | n/a | yes | | ||
| <a name="input_balancer_name"></a> [balancer\_name](#input\_balancer\_name) | ALB name | `string` | n/a | yes | | ||
| <a name="input_region"></a> [region](#input\_region) | n/a | `string` | `""` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_result"></a> [result](#output\_result) | description | | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
data "aws_lb" "balancer" { | ||
name = var.balancer_name | ||
} | ||
|
||
output "result" { | ||
description = "description" | ||
value = [ | ||
[ | ||
{ type : "text/title-with-link", text : "Load Balancer (ALB)", link_to_jump = "https://${var.region}.console.aws.amazon.com/ec2/home?region=${var.region}#LoadBalancer:loadBalancerArn=${data.aws_lb.balancer.arn};tab=listeners" } | ||
], | ||
[ | ||
{ type : "balancer/request-count", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection : false }, | ||
{ type : "balancer/2xx", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection : false }, | ||
{ type : "balancer/4xx", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection : false }, | ||
{ type : "balancer/5xx", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection : false }, | ||
], | ||
[ | ||
{ type : "balancer/all-requests", accountId : var.account_id, balancer_name : var.balancer_name }, | ||
{ type : "balancer/unhealthy-request-count", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection : false }, | ||
{ type : "balancer/error-rate", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection = false }, | ||
{ type : "balancer/connection-issues", accountId : var.account_id, balancer_name : var.balancer_name, anomaly_detection = false }, | ||
], | ||
[ | ||
{ type : "balancer/response-time", accountId : var.account_id, balancer_name : var.balancer_name }, | ||
{ type : "balancer/traffic", accountId : var.account_id, balancer_name : var.balancer_name }, | ||
], | ||
] | ||
} |
Oops, something went wrong.