diff --git a/.github/workflows/terratests-prod-suite-all.yaml b/.github/workflows/terratests-prod-suite-all.yaml index 1fb8eac4..3aeb02ea 100644 --- a/.github/workflows/terratests-prod-suite-all.yaml +++ b/.github/workflows/terratests-prod-suite-all.yaml @@ -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 @@ -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: diff --git a/.github/workflows/terratests-uat-suite.yaml b/.github/workflows/terratests-uat-suite.yaml index b33a4002..4b2410e7 100644 --- a/.github/workflows/terratests-uat-suite.yaml +++ b/.github/workflows/terratests-uat-suite.yaml @@ -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 @@ -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: diff --git a/.github/workflows/terratests-virtualdevice-prod-suite.yaml b/.github/workflows/terratests-virtualdevice-prod-suite.yaml index c6084bd7..9c8a0b9b 100644 --- a/.github/workflows/terratests-virtualdevice-prod-suite.yaml +++ b/.github/workflows/terratests-virtualdevice-prod-suite.yaml @@ -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 @@ -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: diff --git a/examples/virtual-device-2-aws-connection/main.tf b/examples/virtual-device-2-aws-connection/main.tf new file mode 100644 index 00000000..c562f6a1 --- /dev/null +++ b/examples/virtual-device-2-aws-connection/main.tf @@ -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 +} diff --git a/examples/virtual-device-2-aws-connection/outputs.tf b/examples/virtual-device-2-aws-connection/outputs.tf new file mode 100644 index 00000000..fe36869d --- /dev/null +++ b/examples/virtual-device-2-aws-connection/outputs.tf @@ -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 +} diff --git a/examples/virtual-device-2-aws-connection/terraform.tfvars.example b/examples/virtual-device-2-aws-connection/terraform.tfvars.example new file mode 100644 index 00000000..ea507ba9 --- /dev/null +++ b/examples/virtual-device-2-aws-connection/terraform.tfvars.example @@ -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 = ["test@eq.com"] +ne_hostname = "C8KV" +ne_account_number = "182390403" +ne_version = "17.11.01a" +ne_core_count = 2 +ne_term_length = 1 + +ne_ssh_key_username = "" +ne_ssh_key_name = "