diff --git a/docs/data-sources/fabric_cloud_router.md b/docs/data-sources/fabric_cloud_router.md
index 4fe254dbe..d5e2eca6d 100644
--- a/docs/data-sources/fabric_cloud_router.md
+++ b/docs/data-sources/fabric_cloud_router.md
@@ -79,6 +79,7 @@ output "type" {
- `href` (String) Fabric Cloud Router URI information
- `id` (String) The ID of this resource.
- `location` (Set of Object) Fabric Cloud Router location (see [below for nested schema](#nestedatt--location))
+- `marketplace_subscription` (Set of Object) Equinix Fabric Entity for Marketplace Subscription (see [below for nested schema](#nestedatt--marketplace_subscription))
- `name` (String) Fabric Cloud Router name. An alpha-numeric 24 characters string which can include only hyphens and underscores
- `notifications` (List of Object) Preferences for notifications on Fabric Cloud Router configuration or status changes (see [below for nested schema](#nestedatt--notifications))
- `order` (Set of Object) Order information related to this Fabric Cloud Router (see [below for nested schema](#nestedatt--order))
@@ -125,6 +126,15 @@ Read-Only:
- `region` (String)
+
+### Nested Schema for `marketplace_subscription`
+
+Read-Only:
+
+- `type` (String)
+- `uuid` (String)
+
+
### Nested Schema for `notifications`
diff --git a/docs/data-sources/fabric_cloud_routers.md b/docs/data-sources/fabric_cloud_routers.md
index 199ef3c59..66f227d30 100644
--- a/docs/data-sources/fabric_cloud_routers.md
+++ b/docs/data-sources/fabric_cloud_routers.md
@@ -160,6 +160,7 @@ Read-Only:
- `equinix_asn` (Number)
- `href` (String)
- `location` (Set of Object) (see [below for nested schema](#nestedobjatt--data--location))
+- `marketplace_subscription` (Set of Object) (see [below for nested schema](#nestedobjatt--data--marketplace_subscription))
- `name` (String)
- `notifications` (List of Object) (see [below for nested schema](#nestedobjatt--data--notifications))
- `order` (Set of Object) (see [below for nested schema](#nestedobjatt--data--order))
@@ -207,6 +208,15 @@ Read-Only:
- `region` (String)
+
+### Nested Schema for `data.marketplace_subscription`
+
+Read-Only:
+
+- `type` (String)
+- `uuid` (String)
+
+
### Nested Schema for `data.notifications`
diff --git a/docs/resources/fabric_cloud_router.md b/docs/resources/fabric_cloud_router.md
index 41d696c7a..7d5979969 100644
--- a/docs/resources/fabric_cloud_router.md
+++ b/docs/resources/fabric_cloud_router.md
@@ -12,6 +12,7 @@ Additional documentation:
## Example Usage
+Fabric Cloud Router
```terraform
resource "equinix_fabric_cloud_router" "new_cloud_router"{
name = "Router-SV"
@@ -38,12 +39,39 @@ resource "equinix_fabric_cloud_router" "new_cloud_router"{
}
```
+Fabric Cloud Router with Marketplace Subscription id
+```terraform
+resource "equinix_fabric_cloud_router" "new_cloud_router"{
+ name = "Router-SV"
+ type = "XF_ROUTER"
+ notifications{
+ type = "ALL"
+ emails = ["example@equinix.com","test1@equinix.com"]
+ }
+ order {
+ purchase_order_number = "1-323292"
+ }
+ location {
+ metro_code = "SV"
+ }
+ package {
+ code = "STANDARD"
+ }
+ project {
+ project_id = "776847000642406"
+ }
+ marketplace_subscription {
+ type = "AWS_MARKETPLACE_SUBSCRIPTION"
+ uuid = "2823b8ae07-a2a2-45b4-a658-c3542bb24e9"
+ }
+}
+```
+
## Schema
### Required
-- `account` (Block Set, Min: 1, Max: 1) Customer account information that is associated with this Fabric Cloud Router (see [below for nested schema](#nestedblock--account))
- `location` (Block Set, Min: 1, Max: 1) Fabric Cloud Router location (see [below for nested schema](#nestedblock--location))
- `name` (String) Fabric Cloud Router name. An alpha-numeric 24 characters string which can include only hyphens and underscores
- `notifications` (Block List, Min: 1) Preferences for notifications on Fabric Cloud Router configuration or status changes (see [below for nested schema](#nestedblock--notifications))
@@ -53,8 +81,10 @@ resource "equinix_fabric_cloud_router" "new_cloud_router"{
### Optional
+- `account` (Block Set, Max: 1) Customer account information that is associated with this Fabric Cloud Router (see [below for nested schema](#nestedblock--account))
- `description` (String) Customer-provided Fabric Cloud Router description
- `href` (String) Fabric Cloud Router URI information
+- `marketplace_subscription` (Block Set, Max: 1) Equinix Fabric Entity for Marketplace Subscription (see [below for nested schema](#nestedblock--marketplace_subscription))
- `order` (Block Set, Max: 1) Order information related to this Fabric Cloud Router (see [below for nested schema](#nestedblock--order))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
- `uuid` (String) Equinix-assigned Fabric Cloud Router identifier
@@ -71,14 +101,6 @@ resource "equinix_fabric_cloud_router" "new_cloud_router"{
- `id` (String) The ID of this resource.
- `state` (String) Fabric Cloud Router overall state
-
-### Nested Schema for `account`
-
-Optional:
-
-- `account_number` (Number) Account Number
-
-
### Nested Schema for `location`
@@ -120,6 +142,26 @@ Optional:
- `project_id` (String) Project Id
+
+### Nested Schema for `account`
+
+Required:
+
+- `account_number` (Number) Account Number
+
+
+
+### Nested Schema for `marketplace_subscription`
+
+Required:
+
+- `uuid` (String) Equinix-assigned Marketplace Subscription identifier
+
+Optional:
+
+- `type` (String) Marketplace Subscription type like; AWS_MARKETPLACE_SUBSCRIPTION
+
+
### Nested Schema for `order`
diff --git a/equinix/resource_fabric_cloud_router.go b/equinix/resource_fabric_cloud_router.go
index 2a88ea9c1..7fea9ca08 100644
--- a/equinix/resource_fabric_cloud_router.go
+++ b/equinix/resource_fabric_cloud_router.go
@@ -34,8 +34,7 @@ func fabricCloudRouterAccountSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_number": {
Type: schema.TypeInt,
- Computed: true,
- Optional: true,
+ Required: true,
Description: "Account Number",
},
}
@@ -57,6 +56,22 @@ func fabricCloudRouterProjectSch() map[string]*schema.Schema {
}
}
+func fabricMarketplaceSubscriptionSch() map[string]*schema.Schema {
+ return map[string]*schema.Schema{
+ "type": {
+ Type: schema.TypeString,
+ Computed: true,
+ Optional: true,
+ Description: "Marketplace Subscription type like; AWS_MARKETPLACE_SUBSCRIPTION",
+ },
+ "uuid": {
+ Type: schema.TypeString,
+ Required: true,
+ Description: "Equinix-assigned Marketplace Subscription identifier",
+ },
+ }
+}
+
func fabricCloudRouterResourceSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"uuid": {
@@ -133,9 +148,20 @@ func fabricCloudRouterResourceSchema() map[string]*schema.Schema {
Schema: fabricCloudRouterProjectSch(),
},
},
+ "marketplace_subscription": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Computed: true,
+ Description: "Equinix Fabric Entity for Marketplace Subscription",
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: fabricMarketplaceSubscriptionSch(),
+ },
+ },
"account": {
Type: schema.TypeSet,
- Required: true,
+ Optional: true,
+ Computed: true,
Description: "Customer account information that is associated with this Fabric Cloud Router",
MaxItems: 1,
Elem: &schema.Resource{
@@ -214,7 +240,7 @@ Additional documentation:
}
func accountCloudRouterTerraformToGo(accountList []interface{}) fabricv4.SimplifiedAccount {
- if accountList == nil {
+ if len(accountList) == 0 {
return fabricv4.SimplifiedAccount{}
}
simplifiedAccount := fabricv4.SimplifiedAccount{}
@@ -248,6 +274,23 @@ func projectCloudRouterTerraformToGo(projectTerraform []interface{}) fabricv4.Pr
return project
}
+func marketplaceSubscriptionCloudRouterTerraformToGo(marketplaceSubscriptionTerraform []interface{}) fabricv4.MarketplaceSubscription {
+ if len(marketplaceSubscriptionTerraform) == 0 {
+ return fabricv4.MarketplaceSubscription{}
+ }
+ marketplaceSubscription := fabricv4.MarketplaceSubscription{}
+ marketplaceSubscriptionMap := marketplaceSubscriptionTerraform[0].(map[string]interface{})
+ subscriptionUUID := marketplaceSubscriptionMap["uuid"].(string)
+ subscriptionType := marketplaceSubscriptionMap["type"].(string)
+ if subscriptionUUID != "" {
+ marketplaceSubscription.SetUuid(subscriptionUUID)
+ }
+ if subscriptionType != "" {
+ marketplaceSubscription.SetType(fabricv4.MarketplaceSubscriptionType(subscriptionType))
+ }
+
+ return marketplaceSubscription
+}
func resourceFabricCloudRouterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*config.Config).NewFabricClientForSDK(d)
@@ -283,6 +326,11 @@ func resourceFabricCloudRouterCreate(ctx context.Context, d *schema.ResourceData
createCloudRouterRequest.SetOrder(order)
}
+ if marketplaceSubscriptionTerraform, ok := d.GetOk("marketplace_subscription"); ok {
+ marketplaceSubscription := marketplaceSubscriptionCloudRouterTerraformToGo(marketplaceSubscriptionTerraform.(*schema.Set).List())
+ createCloudRouterRequest.SetMarketplaceSubscription(marketplaceSubscription)
+ }
+
start := time.Now()
fcr, _, err := client.CloudRoutersApi.CreateCloudRouter(ctx).CloudRouterPostRequest(createCloudRouterRequest).Execute()
if err != nil {
@@ -320,6 +368,7 @@ func fabricCloudRouterMap(fcr *fabricv4.CloudRouter) map[string]interface{} {
notifications := fcr.GetNotifications()
project := fcr.GetProject()
order := fcr.GetOrder()
+ marketplaceSubscription := fcr.GetMarketplaceSubscription()
return map[string]interface{}{
"name": fcr.GetName(),
"uuid": fcr.GetUuid(),
@@ -339,6 +388,7 @@ func fabricCloudRouterMap(fcr *fabricv4.CloudRouter) map[string]interface{} {
"distinct_ipv6_prefixes_count": fcr.GetDistinctIpv6PrefixesCount(),
"connections_count": fcr.GetConnectionsCount(),
"order": equinix_fabric_schema.OrderGoToTerraform(&order),
+ "marketplace_subscription": marketplaceSubscriptionCloudRouterGoToTerraform(&marketplaceSubscription),
}
}
@@ -377,6 +427,19 @@ func packageCloudRouterGoToTerraform(packageType *fabricv4.CloudRouterPostReques
)
return packageSet
}
+func marketplaceSubscriptionCloudRouterGoToTerraform(subscription *fabricv4.MarketplaceSubscription) *schema.Set {
+ if subscription == nil {
+ return nil
+ }
+ mappedSubscription := make(map[string]interface{})
+ mappedSubscription["type"] = string(subscription.GetType())
+ mappedSubscription["uuid"] = subscription.GetUuid()
+
+ subscriptionSet := schema.NewSet(
+ schema.HashResource(&schema.Resource{Schema: fabricMarketplaceSubscriptionSch()}),
+ []interface{}{mappedSubscription})
+ return subscriptionSet
+}
func getCloudRouterUpdateRequest(conn *fabricv4.CloudRouter, d *schema.ResourceData) (fabricv4.CloudRouterChangeOperation, error) {
changeOps := fabricv4.CloudRouterChangeOperation{}
existingName := conn.GetName()
diff --git a/examples/resources/equinix_fabric_cloud_router/resource.tf b/examples/resources/equinix_fabric_cloud_router/example_1.tf
similarity index 100%
rename from examples/resources/equinix_fabric_cloud_router/resource.tf
rename to examples/resources/equinix_fabric_cloud_router/example_1.tf
diff --git a/examples/resources/equinix_fabric_cloud_router/example_2.tf b/examples/resources/equinix_fabric_cloud_router/example_2.tf
new file mode 100644
index 000000000..552a095ac
--- /dev/null
+++ b/examples/resources/equinix_fabric_cloud_router/example_2.tf
@@ -0,0 +1,24 @@
+resource "equinix_fabric_cloud_router" "new_cloud_router"{
+ name = "Router-SV"
+ type = "XF_ROUTER"
+ notifications{
+ type = "ALL"
+ emails = ["example@equinix.com","test1@equinix.com"]
+ }
+ order {
+ purchase_order_number = "1-323292"
+ }
+ location {
+ metro_code = "SV"
+ }
+ package {
+ code = "STANDARD"
+ }
+ project {
+ project_id = "776847000642406"
+ }
+ marketplace_subscription {
+ type = "AWS_MARKETPLACE_SUBSCRIPTION"
+ uuid = "2823b8ae07-a2a2-45b4-a658-c3542bb24e9"
+ }
+}
diff --git a/templates/resources/fabric_cloud_router.md.tmpl b/templates/resources/fabric_cloud_router.md.tmpl
new file mode 100644
index 000000000..f1a4ca8bd
--- /dev/null
+++ b/templates/resources/fabric_cloud_router.md.tmpl
@@ -0,0 +1,25 @@
+---
+subcategory: "Fabric"
+---
+
+{{/* This template serves as a starting point for documentation generation, and can be customized with hardcoded values and/or doc gen templates.
+
+For example, the {{ .SchemaMarkdown }} template can be used to replace manual schema documentation if descriptions of schema attributes are added in the provider source code. */ -}}
+
+# equinix_fabric_cloud_router (Resource)
+
+Fabric V4 API compatible resource allows creation and management of [Equinix Fabric Cloud Router](https://docs.equinix.com/en-us/Content/Interconnection/FCR/FCR-intro.htm#HowItWorks).
+
+Additional documentation:
+* Getting Started: https://docs.equinix.com/en-us/Content/Interconnection/FCR/FCR-intro.htm#HowItWorks
+* API: https://developer.equinix.com/dev-docs/fabric/api-reference/fabric-v4-apis#fabric-cloud-routers
+
+## Example Usage
+
+Fabric Cloud Router
+{{tffile "examples/resources/equinix_fabric_cloud_router/example_1.tf"}}
+
+Fabric Cloud Router with Marketplace Subscription id
+{{tffile "examples/resources/equinix_fabric_cloud_router/example_2.tf"}}
+
+{{ .SchemaMarkdown | trimspace }}