Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Integrating IBM provider with Fabric Example and Updating metal-nimf sanity suite #91

Merged
merged 5 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/terratests-metal-nimf-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,34 @@ jobs:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- name: Install jq
run: |
sudo apt-get install jq
- name: Set Connection Name variable
run: echo "TF_VAR_connection_name=nimf_$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV

- name: Setup Variables Files
run: |
TIMESTAMP=$(date +"%m%d%M%S")
SUFFIX="_DIGP"
echo $TEST_DATA_PROD_METAL_NIMF_2_AZURE_CONNECTION >> "./examples/metal-nimf-2-azure-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/metal-nimf-2-azure-connection/terraform.tfvars.json > ./examples/metal-nimf-2-azure-connection/tmp.test.json && mv ./examples/metal-nimf-2-azure-connection/tmp.test.json ./examples/metal-nimf-2-azure-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_METAL_NIMF_2_AWS_CONNECTION >> "./examples/metal-nimf-2-aws-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/metal-nimf-2-aws-connection/terraform.tfvars.json > ./examples/metal-nimf-2-aws-connection/tmp.test.json && mv ./examples/metal-nimf-2-aws-connection/tmp.test.json ./examples/metal-nimf-2-aws-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_METAL_NIMF_2_ORACLE_CONNECTION >> "./examples/metal-nimf-2-oracle-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/metal-nimf-2-oracle-connection/terraform.tfvars.json > ./examples/metal-nimf-2-oracle-connection/tmp.test.json && mv ./examples/metal-nimf-2-oracle-connection/tmp.test.json ./examples/metal-nimf-2-oracle-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_CLOUD_ROUTER_2_METAL_NIMF_CONNECTION >> "./examples/cloud-router-2-metal-nimf-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/cloud-router-2-metal-nimf-connection/terraform.tfvars.json > ./examples/cloud-router-2-metal-nimf-connection/tmp.test.json && mv ./examples/cloud-router-2-metal-nimf-connection/tmp.test.json ./examples/cloud-router-2-metal-nimf-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_METAL_NIMF_2_PORT_CONNECTION >> "./examples/metal-nimf-2-port-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/metal-nimf-2-port-connection/terraform.tfvars.json > ./examples/metal-nimf-2-port-connection/tmp.test.json && mv ./examples/metal-nimf-2-port-connection/tmp.test.json ./examples/metal-nimf-2-port-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_METAL_NIMF_2_IBM2_CONNECTION >> "./examples/metal-nimf-2-ibm2-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP$SUFFIX" '.connection_name += "" + $timestamp' ./examples/metal-nimf-2-ibm2-connection/terraform.tfvars.json > ./examples/metal-nimf-2-ibm2-connection/tmp.test.json && mv ./examples/metal-nimf-2-ibm2-connection/tmp.test.json ./examples/metal-nimf-2-ibm2-connection/terraform.tfvars.json
echo $TEST_DATA_PROD_METAL_NIMF_2_SERVICE_PROFILE_CONNECTION >> "./examples/metal-nimf-2-service-profile-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/metal-nimf-2-service-profile-connection/terraform.tfvars.json > ./examples/metal-nimf-2-service-profile-connection/tmp.test.json && mv ./examples/metal-nimf-2-service-profile-connection/tmp.test.json ./examples/metal-nimf-2-service-profile-connection/terraform.tfvars.json
echo $GOOGLE_SERVICE_KEYS >> "./examples/metal-nimf-2-google-connection/keys.json"
echo $TEST_DATA_PROD_METAL_NIMF_2_GOOGLE_CONNECTION >> "./examples/metal-nimf-2-google-connection/terraform.tfvars.json"
jq --arg timestamp "$TIMESTAMP" '.connection_name = ($timestamp + "_" + .connection_name)' ./examples/metal-nimf-2-google-connection/terraform.tfvars.json > ./examples/metal-nimf-2-google-connection/tmp.test.json && mv ./examples/metal-nimf-2-google-connection/tmp.test.json ./examples/metal-nimf-2-google-connection/terraform.tfvars.json
- name: Run Go Tests
run:
Expand Down
27 changes: 27 additions & 0 deletions examples/metal-nimf-2-ibm2-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ provider "equinix" {
auth_token = var.metal_auth_token
}

provider "ibm" {
ibmcloud_api_key = var.ibm_cloud_api_key
iaas_classic_username = var.ibm_classic_username
iaas_classic_api_key = var.ibm_classic_api_key
}

resource "equinix_metal_vlan" "vlan-server" {
description = "${var.metal_connection_metro} VLAN Server 1 to Cloud"
metro = var.metal_connection_metro
Expand Down Expand Up @@ -44,3 +50,24 @@ module "metal_2_ibm2_connection" {
zside_fabric_sp_name = var.zside_fabric_sp_name
additional_info = var.additional_info
}

resource "time_sleep" "wait_dl_connection" {
create_duration = "1m"
}

data "ibm_dl_gateway" "test_ibm_dl_gateway" {
name = var.connection_name
depends_on = [time_sleep.wait_dl_connection]
}

data "ibm_resource_group" "rg" {
name = var.ibm_resource_group_name
}

resource "ibm_dl_gateway_action" "test_dl_gateway_action" {
gateway = data.ibm_dl_gateway.test_ibm_dl_gateway.id
action = var.ibm_gateway_action
global = var.ibm_gateway_global
metered = var.ibm_gateway_metered
resource_group = data.ibm_resource_group.rg.id
}
3 changes: 3 additions & 0 deletions examples/metal-nimf-2-ibm2-connection/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ output "metal_connection_id" {
output "Metal_IBM2_Connection_Id" {
value = module.metal_2_ibm2_connection.primary_connection_id
}
output "IBM_Gateway_Action_Id" {
value = ibm_dl_gateway_action.test_dl_gateway_action.id
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ zside_location = "SV"
zside_fabric_sp_name = "IBM Cloud Direct Link 2"
zside_seller_region = "San Jose 2"
additional_info = [ {"key" : "ASN", "value": 1234 }]

ibm_cloud_api_key = "<IBM_Cloud_API_Key",
ibm_classic_username = "<IBM_Classic_Username>"
ibm_classic_api_key = "<IBM_Classic_API_Key"
ibm_resource_group_name = "Equinix"
ibm_gateway_action = "create_gateway_approve"
33 changes: 33 additions & 0 deletions examples/metal-nimf-2-ibm2-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,36 @@ variable "additional_info" {
type = list(object({ key = string, value = string }))
default = []
}
variable "ibm_cloud_api_key" {
description = "The IBM Cloud platform API key"
type = string
sensitive = true
}
variable "ibm_classic_username" {
description = "The IBM Cloud Classic Infrastructure user name"
type = string
sensitive = true
}
variable "ibm_classic_api_key" {
description = "The IBM Cloud Classic Infrastructure API key"
type = string
sensitive = true
}
variable "ibm_resource_group_name" {
description = "The IBM Resource Group Name"
type = string
}
variable "ibm_gateway_action" {
description = "IBM Approve/reject a pending change request"
type = string
}
variable "ibm_gateway_global" {
description = "Required-Gateway with global routing as true can connect networks outside your associated region"
type = bool
default = true
}
variable "ibm_gateway_metered" {
description = "Metered billing option. If set true gateway usage is billed per GB"
type = bool
default = true
}
6 changes: 5 additions & 1 deletion examples/metal-nimf-2-ibm2-connection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.34.0"
version = ">= 1.38.1"
}
ibm = {
source = "IBM-Cloud/ibm"
version = ">= 1.12.0"
}
}
}
27 changes: 27 additions & 0 deletions examples/port-2-ibm2-connection/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ provider "equinix" {
client_secret = var.equinix_client_secret
}

provider "ibm" {
ibmcloud_api_key = var.ibm_cloud_api_key
iaas_classic_username = var.ibm_classic_username
iaas_classic_api_key = var.ibm_classic_api_key
}

module "create_port_2_ibm2_connection" {
source = "../../modules/port-connection"

Expand All @@ -28,3 +34,24 @@ module "create_port_2_ibm2_connection" {
zside_sp_name = var.zside_sp_name
additional_info = var.additional_info
}

resource "time_sleep" "wait_dl_connection" {
create_duration = "1m"
}

data "ibm_dl_gateway" "test_ibm_dl_gateway" {
name = var.connection_name
depends_on = [time_sleep.wait_dl_connection]
}

data "ibm_resource_group" "rg" {
name = var.ibm_resource_group_name
}

resource "ibm_dl_gateway_action" "test_dl_gateway_action" {
gateway = data.ibm_dl_gateway.test_ibm_dl_gateway.id
action = var.ibm_gateway_action
global = var.ibm_gateway_global
metered = var.ibm_gateway_metered
resource_group = data.ibm_resource_group.rg.id
}
3 changes: 3 additions & 0 deletions examples/port-2-ibm2-connection/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
output "ibm2_connection_id" {
value = module.create_port_2_ibm2_connection.primary_connection_id
}
output "IBM_Gateway_Action_Id" {
value = ibm_dl_gateway_action.test_dl_gateway_action.id
}
6 changes: 6 additions & 0 deletions examples/port-2-ibm2-connection/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ zside_location = "SV"
zside_sp_name = "IBM Cloud Direct Link 2"
zside_seller_region = "San Jose 2"
additional_info = [{ key = "ASN", value = "14353" }]

ibm_cloud_api_key = "<IBM_Cloud_API_Key",
ibm_classic_username = "<IBM_Classic_Username>"
ibm_classic_api_key = "<IBM_Classic_API_Key"
ibm_resource_group_name = "Equinix"
ibm_gateway_action = "create_gateway_approve"
33 changes: 33 additions & 0 deletions examples/port-2-ibm2-connection/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,36 @@ variable "additional_info" {
type = list(object({ key = string, value = string }))
default = []
}
variable "ibm_cloud_api_key" {
description = "The IBM Cloud platform API key"
type = string
sensitive = true
}
variable "ibm_classic_username" {
description = "The IBM Cloud Classic Infrastructure user name"
type = string
sensitive = true
}
variable "ibm_classic_api_key" {
description = "The IBM Cloud Classic Infrastructure API key"
type = string
sensitive = true
}
variable "ibm_resource_group_name" {
description = "The IBM Resource Group Name"
type = string
}
variable "ibm_gateway_action" {
description = "IBM Approve/reject a pending change request"
type = string
}
variable "ibm_gateway_global" {
description = "Required-Gateway with global routing as true can connect networks outside your associated region"
type = bool
default = true
}
variable "ibm_gateway_metered" {
description = "Metered billing option. If set true gateway usage is billed per GB"
type = bool
default = true
}
6 changes: 5 additions & 1 deletion examples/port-2-ibm2-connection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ terraform {
required_providers {
equinix = {
source = "equinix/equinix"
version = ">= 1.20.0"
version = ">= 1.38.1"
}
ibm = {
source = "IBM-Cloud/ibm"
version = ">= 1.12.0"
}
}
}
Loading