Skip to content

Commit

Permalink
CXF 97984: Add Example in Modules and Sanity case for VD to AWS (#121)
Browse files Browse the repository at this point in the history
* CXF-97984: Add example - VD to AWS

* CXF-97984: Add sanity tests and tests in GHA

* CXF-97984: Cleanup extra code

* CXF-97984: Fix formatting

* CXF-97984: Fix formatting

* CXF-97984: Fix formatting

* CXF-97984: Fix formatting

* CXF-97984: Fix formatting

* CXF-97984: main.tf consistent formatting

* CXF-97984: Address PR comments

* CXF-97984: Prod sanity suite changes

* CXF-97984: Address PR comments

* CXF-97984: Add lines

* CXF-97984: Fix typo

* CXF-97984: Fix typo
  • Loading branch information
d-bhola authored Aug 26, 2024
1 parent 94b3d97 commit 3b6e82e
Show file tree
Hide file tree
Showing 14 changed files with 536 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/terratests-prod-suite-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
TEST_DATA_PROD_VIRTUAL_DEVICE_2_WAN_CONNECTION: ${{ secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_WAN_CONNECTION }}
TEST_DATA_PROD_VIRTUAL_DEVICE_2_AZURE_CONNECTION: ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_AZURE_CONNECTION}}
TEST_DATA_PROD_VIRTUAL_DEVICE_2_PORT_CONNECTION: ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_PORT_CONNECTION}}
TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION: ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION}}

steps:
- name: Check out code into the Go module directory
Expand Down Expand Up @@ -97,6 +98,8 @@ jobs:
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./tests/examples-without-external-providers/virtual-device-2-port-connection/terraform.tfvars.json > ./tests/examples-without-external-providers/virtual-device-2-port-connection/tmp.test.json && mv ./tests/examples-without-external-providers/virtual-device-2-port-connection/tmp.test.json ./tests/examples-without-external-providers/virtual-device-2-port-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_CLOUD_ROUTER_2_VIRTUAL_DEVICE_CONNECTION >> "./examples/cloud-router-2-virtual-device-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/cloud-router-2-virtual-device-connection/terraform.tfvars.json > ./examples/cloud-router-2-virtual-device-connection/tmp.test.json && mv ./examples/cloud-router-2-virtual-device-connection/tmp.test.json ./examples/cloud-router-2-virtual-device-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION >> "./tests/examples-without-external-providers/virtual-device-2-aws-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./tests/examples-without-external-providers/virtual-device-2-aws-connection/terraform.tfvars.json > ./tests/examples-without-external-providers/virtual-device-2-aws-connection/tmp.test.json && mv ./tests/examples-without-external-providers/virtual-device-2-aws-connection/tmp.test.json ./tests/examples-without-external-providers/virtual-device-2-aws-connection/terraform.tfvars.json
- name: Run Go Tests
run:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/terratests-uat-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
TEST_DATA_UAT_CLOUD_ROUTER_2_SERVICE_PROFILE_CONNECTION: ${{secrets.TEST_DATA_UAT_CLOUD_ROUTER_2_SERVICE_PROFILE_CONNECTION}}
TEST_DATA_UAT_CLOUD_ROUTER_2_WAN_CONNECTION: ${{secrets.TEST_DATA_UAT_CLOUD_ROUTER_2_WAN_CONNECTION}}
TEST_DATA_UAT_CLOUD_ROUTER_2_VIRTUAL_DEVICE_CONNECTION: ${{secrets.TEST_DATA_UAT_CLOUD_ROUTER_2_VIRTUAL_DEVICE_CONNECTION}}
TEST_DATA_UAT_VIRTUAL_DEVICE_2_AWS_CONNECTION: ${{secrets.TEST_DATA_UAT_VIRTUAL_DEVICE_2_AWS_CONNECTION}}

steps:
- name: Check out code into the Go module directory
Expand Down Expand Up @@ -110,6 +111,7 @@ jobs:
echo $TEST_DATA_UAT_CLOUD_ROUTER_2_SERVICE_PROFILE_CONNECTION >> "./examples/cloud-router-2-service-profile-connection/terraform.tfvars.json"
echo $TEST_DATA_UAT_CLOUD_ROUTER_2_WAN_CONNECTION >> "./examples/cloud-router-2-wan-connection/terraform.tfvars.json"
echo $TEST_DATA_UAT_CLOUD_ROUTER_2_VIRTUAL_DEVICE_CONNECTION >> "./examples/cloud-router-2-virtual-device-connection/terraform.tfvars.json"
echo $TEST_DATA_UAT_VIRTUAL_DEVICE_2_AWS_CONNECTION >> "./tests/examples-without-external-providers/virtual-device-2-aws-connection/terraform.tfvars.json"
- name: Run Go Tests
run:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/terratests-virtualdevice-prod-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
TEST_DATA_PROD_VIRTUAL_DEVICE_2_WAN_CONNECTION: ${{ secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_WAN_CONNECTION }}
TEST_DATA_PROD_VIRTUAL_DEVICE_2_AZURE_CONNECTION: ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_AZURE_CONNECTION}}
TEST_DATA_PROD_VIRTUAL_DEVICE_2_PORT_CONNECTION: ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_PORT_CONNECTION}}
TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION: ${{secrets.TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION}}

steps:
- name: Check out code into the Go module directory
Expand Down Expand Up @@ -47,6 +48,8 @@ jobs:
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./tests/examples-without-external-providers/virtual-device-2-azure-connection/terraform.tfvars.json > ./tests/examples-without-external-providers/virtual-device-2-azure-connection/tmp.test.json && mv ./tests/examples-without-external-providers/virtual-device-2-azure-connection/tmp.test.json ./tests/examples-without-external-providers/virtual-device-2-azure-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_VIRTUAL_DEVICE_2_PORT_CONNECTION >> "./tests/examples-without-external-providers/virtual-device-2-port-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./tests/examples-without-external-providers/virtual-device-2-port-connection/terraform.tfvars.json > ./tests/examples-without-external-providers/virtual-device-2-port-connection/tmp.test.json && mv ./tests/examples-without-external-providers/virtual-device-2-port-connection/tmp.test.json ./tests/examples-without-external-providers/virtual-device-2-port-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_VIRTUAL_DEVICE_2_AWS_CONNECTION >> "./tests/examples-without-external-providers/virtual-device-2-aws-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./tests/examples-without-external-providers/virtual-device-2-aws-connection/terraform.tfvars.json > ./tests/examples-without-external-providers/virtual-device-2-aws-connection/tmp.test.json && mv ./tests/examples-without-external-providers/virtual-device-2-aws-connection/tmp.test.json ./tests/examples-without-external-providers/virtual-device-2-aws-connection/terraform.tfvars.json
- name: Run Go Tests
run:
Expand Down
99 changes: 99 additions & 0 deletions examples/virtual-device-2-aws-connection/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
provider "equinix" {
client_id = var.equinix_client_id
client_secret = var.equinix_client_secret
}

provider "aws" {
access_key = var.additional_info[0]["value"]
secret_key = var.additional_info[1]["value"]
region = var.zside_seller_region
}

## Creates NE ACL template and assigns it to the network device
resource "equinix_network_acl_template" "wan-acl-template" {
name = var.template_name
description = var.template_description
inbound_rule {
subnet = var.template_subnet
protocol = var.template_protocol
src_port = var.template_src_port
dst_port = var.template_dst_port
}
}

resource "equinix_network_device" "C8KV-SV" {
name = var.ne_name
metro_code = var.ne_metro_code
type_code = var.ne_type_code
self_managed = true
byol = true
package_code = var.ne_package_code
notifications = var.ne_notifications
hostname = var.ne_hostname
account_number = var.ne_account_number
version = var.ne_version
core_count = var.ne_core_count
term_length = var.ne_term_length

ssh_key {
username = var.ne_ssh_key_username
key_name = var.ne_ssh_key_name
}
acl_template_id = equinix_network_acl_template.wan-acl-template.id
}

#Connection
module "virtual_device_2_aws_connection" {
source = "../../modules/virtual-device-connection"

connection_name = var.connection_name
connection_type = var.connection_type
notifications_type = var.notifications_type
notifications_emails = var.notifications_emails
additional_info = var.additional_info
bandwidth = var.bandwidth
purchase_order_number = var.purchase_order_number

# A-side
aside_vd_type = var.aside_vd_type
aside_vd_uuid = equinix_network_device.C8KV-SV.id

#Zside
zside_ap_type = var.zside_ap_type
zside_ap_authentication_key = var.zside_ap_authentication_key
zside_ap_profile_type = var.zside_ap_profile_type
zside_location = var.zside_location
zside_seller_region = var.zside_seller_region
zside_sp_name = var.zside_sp_name
}

data "aws_dx_connection" "aws_connection" {
depends_on = [
module.virtual_device_2_aws_connection
]
name = var.connection_name
}

resource "aws_dx_gateway" "aws_gateway" {
depends_on = [
module.virtual_device_2_aws_connection
]
name = var.aws_gateway_name
amazon_side_asn = var.aws_gateway_asn
}

resource "aws_dx_private_virtual_interface" "aws_virtual_interface" {
depends_on = [
module.virtual_device_2_aws_connection,
aws_dx_gateway.aws_gateway
]
connection_id = data.aws_dx_connection.aws_connection.id
name = var.aws_vif_name
vlan = data.aws_dx_connection.aws_connection.vlan_id
address_family = var.aws_vif_address_family
bgp_asn = var.aws_vif_bgp_asn
amazon_address = var.aws_vif_amazon_address
customer_address = var.aws_vif_customer_address
bgp_auth_key = var.aws_vif_bgp_auth_key
dx_gateway_id = aws_dx_gateway.aws_gateway.id
}
6 changes: 6 additions & 0 deletions examples/virtual-device-2-aws-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
output "virtual_device_id" {
value = equinix_network_device.C8KV-SV.id
}
output "aws_connection_id" {
value = module.virtual_device_2_aws_connection.primary_connection_id
}
67 changes: 67 additions & 0 deletions examples/virtual-device-2-aws-connection/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
equinix_client_id = "MyEquinixClientId"
equinix_client_secret = "MyEquinixSecret"

#NE Acl Template
template_name = "test-wan-acl-template"
template_description = "WAN ACL template"
template_subnet = "172.16.25.0/24"
template_protocol = "TCP"
template_src_port = "any"
template_dst_port = "22"

#Network Edge
ne_name = "Terra_Test_router"
ne_metro_code = "SV"
ne_type_code = "C8000V"
ne_package_code = "network-essentials"
ne_notifications = ["[email protected]"]
ne_hostname = "C8KV"
ne_account_number = "182390403"
ne_version = "17.11.01a"
ne_core_count = 2
ne_term_length = 1

ne_ssh_key_username = "<SSH_Key_Username>"
ne_ssh_key_name = "<SSH_Key_Name"

#VD_2_AWS_Connection
aside_vd_type = "EDGE"
aside_vd_uuid = "<Virtual Device UUID>"
zside_ap_type = "SP"
zside_ap_profile_type = "L2_PROFILE"
zside_location = "SV"
zside_sp_name = "AWS"
zside_peering_type = "PRIVATE"

notifications_type = "ALL"
notifications_emails = ["[email protected]","[email protected]"]
purchase_order_number = "1-323292"
connection_name = "VD_2_AWS"
connection_type = "EVPL_VC"
bandwidth = 50
zside_ap_type = "SP"
zside_ap_authentication_key = "<AWS Account Id>"
zside_ap_profile_type = "L2_PROFILE"
zside_location = "SV"
zside_seller_region = "us-west-1"
zside_fabric_sp_name = "AWS Direct Connect"
additional_info = [
{
key = "accessKey"
value = "<aws_access_key>"
},
{
key = "secretKey"
value = "<aws_secret_key>"
}
]

#AWS Provider
aws_gateway_name = "aws_gateway"
aws_gateway_asn = 64518
aws_vif_name = "port2aws"
aws_vif_address_family = "ipv4"
aws_vif_bgp_asn = 64999
aws_vif_amazon_address = "169.254.0.1/30"
aws_vif_customer_address = "169.254.0.2/30"
aws_vif_bgp_auth_key = "secret"
Loading

0 comments on commit 3b6e82e

Please sign in to comment.