-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- new variables for creating cloudwatch alarms
- create_cloudwatch_alarms
- cloudwatch_alarm_topic_arn- Loading branch information
Showing
8 changed files
with
208 additions
and
2 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
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,76 @@ | ||
| #data "aws_sns_topic" "tgw_vpn" { | ||
| # name = format("inf-tgw-%v", local.region) | ||
| #} | ||
|
|
||
| locals { | ||
| vpn_t1_details = { for k, v in local.vpn_tunnel_outputs : format("%v:1", k) => { | ||
| tunnel_number = 1 | ||
| name = format("%v-tunnel-%v.%v.%v", v.label, 1, v.account_alias, v.region) | ||
| account_alias = v.account_alias | ||
| account_id = v.account_id | ||
| customer_address = v.customer_address | ||
| full_label = v.full_label | ||
| label = v.label | ||
| region = v.region | ||
| sequence = v.sequence | ||
| site = v.site | ||
| tunnel_address = v.tunnel1_address | ||
| interface_number = v.tunnel1_interface_number | ||
| tunnel_label = v.tunnel1_label | ||
| loopback = v.tunnel1_loopback | ||
| vpc_id = local.vpc_id | ||
| cidr_block = v.vpc_cidr_block | ||
| vpc_short_name = v.vpc_short_name | ||
| vpc_name = v.vpc_name | ||
| vpn_environment = v.vpn_environment | ||
| vpn_connection_id = v.vpn_connection_id | ||
| } } | ||
| vpn_t2_details = { for k, v in local.vpn_tunnel_outputs : format("%v:2", k) => { | ||
| tunnel_number = 2 | ||
| name = format("%v-tunnel-%v.%v.%v", v.label, 2, v.account_alias, v.region) | ||
| account_alias = v.account_alias | ||
| account_id = v.account_id | ||
| customer_address = v.customer_address | ||
| full_label = v.full_label | ||
| label = v.label | ||
| region = v.region | ||
| sequence = v.sequence | ||
| site = v.site | ||
| tunnel_address = v.tunnel2_address | ||
| interface_number = v.tunnel2_interface_number | ||
| tunnel_label = v.tunnel2_label | ||
| loopback = v.tunnel2_loopback | ||
| vpc_id = local.vpc_id | ||
| cidr_block = v.vpc_cidr_block | ||
| vpc_short_name = v.vpc_short_name | ||
| vpc_name = v.vpc_name | ||
| vpn_environment = v.vpn_environment | ||
| vpn_connection_id = v.vpn_connection_id | ||
| } } | ||
| vpn_details = merge(local.vpn_t1_details, local.vpn_t2_details) | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_metric_alarm" "tgw_vpn" { | ||
| for_each = var.create_cloudwatch_alarms && var.cloudwatch_alarm_topic_arn != null ? local.vpn_details : {} | ||
| actions_enabled = true | ||
| alarm_actions = [var.cloudwatch_alarm_topic_arn] | ||
| alarm_description = templatefile("${path.module}/templates/cloudwatch_alarm.tpl", tomap(each.value)) | ||
| alarm_name = each.value.name | ||
| comparison_operator = "LessThanThreshold" | ||
| datapoints_to_alarm = 5 | ||
| dimensions = { | ||
| "TunnelIpAddress" = each.value.tunnel_address | ||
| } | ||
| evaluation_periods = 8 | ||
| metric_name = "TunnelState" | ||
| namespace = "AWS/VPN" | ||
| period = 60 | ||
| statistic = "Average" | ||
| threshold = 1 | ||
| treat_missing_data = "missing" | ||
|
|
||
| tags = merge( | ||
| local.base_tags, | ||
| var.tags, | ||
| ) | ||
| } |
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,25 @@ | ||
|
|
||
| # VPN Tunnel Down | ||
|
|
||
| ## ${account_alias} ${region} ${label} tunnel ${tunnel_number} | ||
|
|
||
| * account = ${account_alias} {account_id} | ||
| * region = ${region} | ||
| * label = ${full_label} | ||
| * vpc | ||
| * id = ${vpc_id} | ||
| * cidr_block = ${cidr_block} | ||
| * name = ${vpc_short_name}-${vpc_name} | ||
| * vpn_connection = ${vpn_connection_id} | ||
| * tunnel | ||
| * site = ${site} | ||
| * environment = ${vpn_environment} | ||
| * sequence = ${sequence} | ||
| * addresses | ||
| * tunnel_number = ${tunnel_number} | ||
| * tunnel_address = ${tunnel_address} | ||
| * tunnel_label = ${tunnel_label} | ||
| * interface_number = ${interface_number} | ||
| * loopback = ${loopback} | ||
| * asr-endpiont = ${customer_address} | ||
|
|
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,80 @@ | ||
| vrf: ${vrf} | ||
| cloud_provider: aws | ||
| aws: | ||
| region_full: ${region_full} | ||
| region_short: ${region_short} | ||
| vpc_full_name: ${vpc_full_name} | ||
| vpc_suffix: ${vpc_name} | ||
| vpc_number: ${vpc_number} | ||
| vpc_cidr_block: ${vpc_cidr_block} | ||
| vpn_connection_id: ${vpn_connection_id} | ||
| vpn_connection_description: ${vpn_connection_description} | ||
| tunnels: | ||
| - tunnel1: | ||
| description: ${vpc_connection_description} | ||
| %{ for k,v in tunnel1 } | ||
| ${k}: ${v} | ||
| %{ endfor ~} | ||
| - tunnel2: | ||
| description: ${vpc_connection_description} | ||
| %{ for k,v in tunnel2 } | ||
| ${k}: ${v} | ||
| %{ endfor ~} | ||
|
|
||
| ## tunnel1_bgp_asn = aws_vpn_connection.vpn[k].tunnel1_bgp_asn | ||
| ## tunnel1_address = aws_vpn_connection.vpn[k].tunnel1_address | ||
| ## tunnel1_inside_cidr = aws_vpn_connection.vpn[k].tunnel1_inside_cidr | ||
| ## tunnel1_cgw_inside_address = aws_vpn_connection.vpn[k].tunnel1_cgw_inside_address | ||
| ## tunnel1_vgw_inside_address = aws_vpn_connection.vpn[k].tunnel1_vgw_inside_address | ||
| ## | ||
|
|
||
| asr: | ||
| site: ${site} | ||
| # device_name: hqnt-r1-cld-vpn-rtr1 | ||
| device_name: bccm2-dmz-r68-cld-vpn-rtr1 | ||
|
|
||
|
|
||
|
|
||
|
|
||
| aws: | ||
| region: us-gov-east-1 | us-gov-west-1 | ||
| # description: (none) | ||
| # comment: for EW, we will need 4 new BGP numbers, one per region east-1, east-2, west-1, west-2 | ||
| region_short: east | west | ||
| # description: AWS VPC Region | ||
| vpc_name: vpc1-tgw-common | vpc2-dice-dev | .. | ||
| # description: AWS VPC Name | ||
| vpc_short_name: vpc1 | ||
| # description: AWS VPC Sub-name | ||
| vpc_number: 1 | 2 | ... | ||
| # description: AWS VPC Number | ||
| vrf_name: cen-services | cen-dev | cen-test | cen-stage | cen-prod | cen-cre | misc-dmz | ||
| # description: VRF Name (ALL CAPS) | ||
| vpn_connection_id: | ||
| # comment: not sure how to represent this just yet | ||
| # description: AWS VPN Connection ID BCC: [BCC ID] | ||
| # description: AWS VPN Connection ID HQ: [HQ ID] | ||
| aws_bgp_asn: 64513 (east) | 64514 (west) | ||
| # description: AWS BGP ASN | ||
|
|
||
| ## from TCO | ||
| asr: | ||
| tunnel_interface_numbers: [ tu-1-number, tu-2-number ] | ||
| # description: Tunnel 1 Interface Number | ||
| # description: Tunnel 2 Interface Number | ||
| tunnel_interface_prefixes: | ||
| # description: map of VRF to prefix of {prefix}{xx} | ||
| cen-dev: 14 | ||
| cen-test: 15 | ||
| cen-stage: 16 | ||
| cen-prod: 17 | ||
| cen-service: 18 | ||
| cen-cre: 19 | ||
| misc-dmz: 99 | ||
| loopback_number: {integer} | ||
| # description: Loopback Number | ||
| object_track_interface_numbers: [ tu-1-number-drop-leading-digit, tu-2-number-drop-leading-digit ] | ||
| # description: Object Track 1: [TRACK 1] | ||
| # description: Object Track 2: [TRACK 2] | ||
| # comment: Drop 1st digit of Tu interface | ||
| # comment: not sure how that works with misc-dmz |
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