From 6f4434605a584f3c35afcc8983a4b798a3d9f7e0 Mon Sep 17 00:00:00 2001 From: Srushti Patel <137830748+srushti-patl@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:32:33 -0700 Subject: [PATCH] CXF-100793 Adding Creating FCR with Marketplace Subscription example (#127) * feat: Adding Creating FCR with Marketplace subscription example * nit: removing extra space * fix:Changing resource & data source names and updating README.md files. * nit: Updating data source reference. * fix: Updating equinix provider version and README.md file --- .../README.md | 11 ++++ .../main.tf | 41 +++++++++++++++ .../outputs.tf | 3 ++ .../terraform.tfvars.example | 14 +++++ .../varaibles.tf | 52 +++++++++++++++++++ .../versions.tf | 9 ++++ 6 files changed, 130 insertions(+) create mode 100644 examples/cloud-router-marketplace-susbscription/README.md create mode 100644 examples/cloud-router-marketplace-susbscription/main.tf create mode 100644 examples/cloud-router-marketplace-susbscription/outputs.tf create mode 100644 examples/cloud-router-marketplace-susbscription/terraform.tfvars.example create mode 100644 examples/cloud-router-marketplace-susbscription/varaibles.tf create mode 100644 examples/cloud-router-marketplace-susbscription/versions.tf diff --git a/examples/cloud-router-marketplace-susbscription/README.md b/examples/cloud-router-marketplace-susbscription/README.md new file mode 100644 index 0000000..588a4cb --- /dev/null +++ b/examples/cloud-router-marketplace-susbscription/README.md @@ -0,0 +1,11 @@ +# Fabric Cloud Router Creation with Market Place Susbscription + +This example shows how to create a Fabric Cloud Router using Market Place Subscription, which can be generated through various CloudRouter Service Providers. + +It leverages the Equinix Terraform Provider to setup the Fabric Cloud Router based on the parameters you have provided to this example; or based on the pattern +you see used in this example it will allow you to create a more specific use case for your own needs. + +See example usage below for details on how to use this example. + + + diff --git a/examples/cloud-router-marketplace-susbscription/main.tf b/examples/cloud-router-marketplace-susbscription/main.tf new file mode 100644 index 0000000..dc30987 --- /dev/null +++ b/examples/cloud-router-marketplace-susbscription/main.tf @@ -0,0 +1,41 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +data "equinix_fabric_market_place_subscription" "subscription" { + uuid = var.marketplace_subscription_uuid +} + +locals { + entitlement = flatten([ + for entitlement in data.equinix_fabric_market_place_subscription.subscription.entitlements : [ + for asset in entitlement.asset : asset.package + ] + ]) +} + +resource "equinix_fabric_cloud_router" "create_fcr_marketplace_subscription"{ + name = var.fcr_name + type = var.fcr_type + notifications{ + type = var.notifications_type + emails = var.notifications_emails + } + order { + purchase_order_number = var.purchase_order_number + } + location { + metro_code = var.fcr_location + } + package { + code = local.entitlement[1].code + } + project { + project_id = var.project_id + } + marketplace_subscription{ + type = var.marketplace_subscription_type + uuid = data.equinix_fabric_market_place_subscription.subscription.uuid + } +} diff --git a/examples/cloud-router-marketplace-susbscription/outputs.tf b/examples/cloud-router-marketplace-susbscription/outputs.tf new file mode 100644 index 0000000..2873f5d --- /dev/null +++ b/examples/cloud-router-marketplace-susbscription/outputs.tf @@ -0,0 +1,3 @@ +output "cloud_router_id" { + value = equinix_fabric_cloud_router.create_fcr_marketplace_subscription.id +} diff --git a/examples/cloud-router-marketplace-susbscription/terraform.tfvars.example b/examples/cloud-router-marketplace-susbscription/terraform.tfvars.example new file mode 100644 index 0000000..e8e6c87 --- /dev/null +++ b/examples/cloud-router-marketplace-susbscription/terraform.tfvars.example @@ -0,0 +1,14 @@ +equinix_client_id = "" +equinix_client_secret = "" + +fcr_location = "SV" +fcr_name = "terra_fcr_marketplace" +fcr_package = "ADVANCED" +fcr_type = "XF_ROUTER" +notifications_emails = ["diginpanthers@gmail.com"] +notifications_type = "ALL" +project_id = "" +purchase_order_number = "1-323292" + +marketplace_subscription_type = "AWS_MARKETPLACE_SUBSCRIPTION", +marketplace_subscription_uuid = "" diff --git a/examples/cloud-router-marketplace-susbscription/varaibles.tf b/examples/cloud-router-marketplace-susbscription/varaibles.tf new file mode 100644 index 0000000..dabdbce --- /dev/null +++ b/examples/cloud-router-marketplace-susbscription/varaibles.tf @@ -0,0 +1,52 @@ +variable "equinix_client_id" { + description = "Equinix client ID (consumer key), obtained after registering app in the developer platform" + type = string + sensitive = true +} +variable "equinix_client_secret" { + description = "Equinix client secret ID (consumer secret), obtained after registering app in the developer platform" + type = string + sensitive = true +} +variable "fcr_name" { + description = "Fabric Cloud Router Name" + type = string +} +variable "fcr_type" { + description = "Fabric Cloud Router Type like XF_ROUTER" + type = string +} +variable "notifications_type" { + description = "Notification Type - ALL is the only type currently supported" + type = string + default = "ALL" +} +variable "notifications_emails" { + description = "Array of contact emails" + type = list(string) +} +variable "purchase_order_number" { + description = "Purchase order number" + type = string +} +variable "fcr_location" { + description = "Fabric Cloud Router Location" + type = string +} +variable "fcr_package" { + description = "Fabric Cloud Router Package like LAB, ADVANCED, STANDARD, PREMIUM" + type = string +} +variable "project_id" { + description = "Subscriber-assigned project ID" + type = string +} +variable "marketplace_subscription_type" { + description = "Marketplace subscription type" + type = string +} +variable "marketplace_subscription_uuid" { + description = "Marketplace subscription UUID" + type = string + sensitive = true +} diff --git a/examples/cloud-router-marketplace-susbscription/versions.tf b/examples/cloud-router-marketplace-susbscription/versions.tf new file mode 100644 index 0000000..03bc596 --- /dev/null +++ b/examples/cloud-router-marketplace-susbscription/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.5.4" + required_providers { + equinix = { + source = "equinix/equinix" + version = ">= 2.5.0" + } + } +}