diff --git a/equinix/data_source_fabric_network.go b/equinix/data_source_fabric_network.go new file mode 100755 index 000000000..e73c42093 --- /dev/null +++ b/equinix/data_source_fabric_network.go @@ -0,0 +1,39 @@ +package equinix + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func readFabricNetworkResourceSchema() map[string]*schema.Schema { + sch := FabricNetworkResourceSchema() + for key, _ := range sch { + if key == "uuid" { + sch[key].Required = true + sch[key].Optional = false + sch[key].Computed = false + } else { + sch[key].Required = false + sch[key].Optional = false + sch[key].Computed = true + sch[key].MaxItems = 0 + sch[key].ValidateFunc = nil + } + } + return sch +} +func dataSourceNetwork() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceNetworkRead, + Schema: readFabricNetworkResourceSchema(), + Description: "Fabric V4 API compatible data resource that allow user to fetch Fabric Network for a given UUID\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + } +} + +func dataSourceNetworkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + uuid, _ := d.Get("uuid").(string) + d.SetId(uuid) + return resourceFabricNetworkRead(ctx, d, meta) +} diff --git a/equinix/fabric_mapping_helper.go b/equinix/fabric_mapping_helper.go index def7ef650..baac07932 100644 --- a/equinix/fabric_mapping_helper.go +++ b/equinix/fabric_mapping_helper.go @@ -2,11 +2,10 @@ package equinix import ( "fmt" - "log" - v4 "github.com/equinix-labs/fabric-go/fabric/v4" "github.com/equinix/terraform-provider-equinix/internal/converters" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "log" ) func serviceTokenToFabric(serviceTokenRequest []interface{}) (v4.ServiceToken, error) { @@ -538,14 +537,17 @@ func notificationToTerra(notifications []v4.SimplifiedNotification) []map[string } func locationToTerra(location *v4.SimplifiedLocation) *schema.Set { + if location == nil { + return nil + } locations := []*v4.SimplifiedLocation{location} mappedLocations := make([]interface{}, len(locations)) - for i, location := range locations { + for i, loc := range locations { mappedLocations[i] = map[string]interface{}{ - "region": location.Region, - "metro_name": location.MetroName, - "metro_code": location.MetroCode, - "ibx": location.Ibx, + "region": loc.Region, + "metro_name": loc.MetroName, + "metro_code": loc.MetroCode, + "ibx": loc.Ibx, } } locationSet := schema.NewSet( diff --git a/equinix/provider.go b/equinix/provider.go index 9547c0d50..7797c6ef0 100644 --- a/equinix/provider.go +++ b/equinix/provider.go @@ -83,6 +83,7 @@ func Provider() *schema.Provider { "equinix_fabric_routing_protocol": dataSourceRoutingProtocol(), "equinix_fabric_connection": dataSourceFabricConnection(), "equinix_fabric_cloud_router": dataSourceCloudRouter(), + "equinix_fabric_network": dataSourceNetwork(), "equinix_fabric_port": dataSourceFabricPort(), "equinix_fabric_ports": dataSourceFabricGetPortsByName(), "equinix_fabric_service_profile": dataSourceFabricServiceProfileReadByUuid(), @@ -120,6 +121,7 @@ func Provider() *schema.Provider { "equinix_ecx_l2_connection_accepter": resourceECXL2ConnectionAccepter(), "equinix_ecx_l2_serviceprofile": resourceECXL2ServiceProfile(), "equinix_fabric_cloud_router": resourceCloudRouter(), + "equinix_fabric_network": resourceNetwork(), "equinix_fabric_connection": resourceFabricConnection(), "equinix_fabric_routing_protocol": resourceFabricRoutingProtocol(), "equinix_fabric_service_profile": resourceFabricServiceProfile(), diff --git a/equinix/resource_fabric_network.go b/equinix/resource_fabric_network.go new file mode 100755 index 000000000..dd6420b74 --- /dev/null +++ b/equinix/resource_fabric_network.go @@ -0,0 +1,418 @@ +package equinix + +import ( + "context" + "fmt" + v4 "github.com/equinix-labs/fabric-go/fabric/v4" + "github.com/equinix/terraform-provider-equinix/internal/config" + equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "log" + "strings" + "time" +) + +func FabricNetworkChangeSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "href": { + Type: schema.TypeString, + Computed: true, + Description: "href", + }, + "uuid": { + Type: schema.TypeString, + Computed: true, + Description: "UUID of Network Change", + }, + "type": { + Type: schema.TypeString, + Computed: true, + Description: "network change type: NETWORK_CREATION, NETWORK_UPDATE, NETWORK_DELETION", + }, + } +} +func FabricNetworkOperationSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "equinix_status": { + Type: schema.TypeString, + Computed: true, + Description: "Network operation status", + }, + } +} +func FabricNetworkProjectSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "project_id": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: "Project Id", + }, + } +} +func FabricNetworkResourceSchema() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Fabric Network URI information", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "Fabric Network name. An alpha-numeric 24 characters string which can include only hyphens and underscores", + }, + "state": { + Type: schema.TypeString, + Computed: true, + Description: "Fabric Network overall state", + }, + "scope": { + Type: schema.TypeString, + Required: true, + Description: "Fabric Network scope", + }, + "type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"IPWAN", "EPLAN", "EVPLAN"}, true), + Description: "Supported Network types - EVPLAN, EPLAN, IPWAN", + }, + "location": { + Type: schema.TypeSet, + Computed: true, + Optional: true, + Description: "Fabric Network location", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: createLocationSch(), + }, + }, + "project": { + Type: schema.TypeSet, + Computed: true, + Optional: true, + Description: "Fabric Network project", + Elem: &schema.Resource{ + Schema: FabricNetworkProjectSch(), + }, + }, + "operation": { + Type: schema.TypeSet, + Computed: true, + Description: "Network operation information that is associated with this Fabric Network", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: FabricNetworkOperationSch(), + }, + }, + "change": { + Type: schema.TypeSet, + Computed: true, + Description: "Change information related to this Fabric Network", + MaxItems: 1, + Elem: &schema.Resource{ + Schema: FabricNetworkChangeSch(), + }, + }, + "notifications": { + Type: schema.TypeList, + Required: true, + Description: "Preferences for notifications on Fabric Network configuration or status changes", + Elem: &schema.Resource{ + Schema: createNotificationSch(), + }, + }, + "change_log": { + Type: schema.TypeSet, + Computed: true, + Description: "Captures Fabric Network lifecycle change information", + Elem: &schema.Resource{ + Schema: createChangeLogSch(), + }, + }, + } +} +func resourceNetwork() *schema.Resource { + return &schema.Resource{ + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(6 * time.Minute), + Update: schema.DefaultTimeout(10 * time.Minute), + Delete: schema.DefaultTimeout(6 * time.Minute), + Read: schema.DefaultTimeout(6 * time.Minute), + }, + ReadContext: resourceFabricNetworkRead, + CreateContext: resourceFabricNetworkCreate, + UpdateContext: resourceFabricNetworkUpdate, + DeleteContext: resourceFabricNetworkDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Schema: FabricNetworkResourceSchema(), + + Description: "Fabric V4 API compatible resource allows creation and management of Equinix Fabric Network\n\n~> **Note** Equinix Fabric v4 resources and datasources are currently in Beta. The interfaces related to `equinix_fabric_` resources and datasources may change ahead of general availability. Please, do not hesitate to report any problems that you experience by opening a new [issue](https://github.com/equinix/terraform-provider-equinix/issues/new?template=bug.md)", + } +} + +func resourceFabricNetworkCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*config.Config).FabricClient + ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*config.Config).FabricAuthToken) + schemaNotifications := d.Get("notifications").([]interface{}) + notifications := notificationToFabric(schemaNotifications) + schemaLocation := d.Get("location").(*schema.Set).List() + location := locationToFabric(schemaLocation) + project := v4.Project{} + schemaProject := d.Get("project").(*schema.Set).List() + if len(schemaProject) != 0 { + project = projectToFabric(schemaProject) + } + netType := v4.NetworkType(d.Get("type").(string)) + netScope := v4.NetworkScope(d.Get("scope").(string)) + + createRequest := v4.NetworkPostRequest{ + Name: d.Get("name").(string), + Type_: &netType, + Scope: &netScope, + Location: &location, + Notifications: notifications, + Project: &project, + } + + fabricNetwork, _, err := client.NetworksApi.CreateNetwork(ctx, createRequest) + if err != nil { + return diag.FromErr(err) + } + d.SetId(fabricNetwork.Uuid) + + if _, err = waitUntilFabricNetworkIsProvisioned(d.Id(), meta, ctx); err != nil { + return diag.Errorf("error waiting for Network (%s) to be created: %s", d.Id(), err) + } + + return resourceFabricNetworkRead(ctx, d, meta) +} + +func resourceFabricNetworkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*config.Config).FabricClient + ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*config.Config).FabricAuthToken) + fabricNetwork, _, err := client.NetworksApi.GetNetworkByUuid(ctx, d.Id()) + if err != nil { + log.Printf("[WARN] Fabric Network %s not found , error %s", d.Id(), err) + if !strings.Contains(err.Error(), "500") { + d.SetId("") + } + return diag.FromErr(err) + } + d.SetId(fabricNetwork.Uuid) + return setFabricNetworkMap(d, fabricNetwork) +} +func FabricNetworkOperationToTerra(operation *v4.NetworkOperation) *schema.Set { + if operation == nil { + return nil + } + operations := []*v4.NetworkOperation{operation} + mappedOperations := make([]interface{}, len(operations)) + for _, operation := range operations { + mappedOperation := make(map[string]interface{}) + mappedOperation["equinix_status"] = string(*operation.EquinixStatus) + mappedOperations = append(mappedOperations, mappedOperation) + } + + operationSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: FabricNetworkOperationSch()}), + mappedOperations, + ) + return operationSet +} +func simplifiedFabricNetworkChangeToTerra(networkChange *v4.SimplifiedNetworkChange) *schema.Set { + changes := []*v4.SimplifiedNetworkChange{networkChange} + mappedChanges := make([]interface{}, len(changes)) + for _, change := range changes { + mappedChange := make(map[string]interface{}) + mappedChange["href"] = change.Href + mappedChange["type"] = string(*change.Type_) + mappedChange["uuid"] = change.Uuid + mappedChanges = append(mappedChanges, mappedChange) + } + + changeSet := schema.NewSet( + schema.HashResource(&schema.Resource{Schema: FabricNetworkChangeSch()}), + mappedChanges, + ) + return changeSet +} + +func setFabricNetworkMap(d *schema.ResourceData, nt v4.Network) diag.Diagnostics { + diags := diag.Diagnostics{} + err := equinix_schema.SetMap(d, map[string]interface{}{ + "name": nt.Name, + "type": nt.Type_, + "scope": nt.Scope, + "state": nt.State, + "operation": FabricNetworkOperationToTerra(nt.Operation), + "change": simplifiedFabricNetworkChangeToTerra(nt.Change), + "location": locationToTerra(nt.Location), + "notifications": notificationToTerra(nt.Notifications), + "project": projectToTerra(nt.Project), + "change_log": changeLogToTerra(nt.ChangeLog), + }) + if err != nil { + return diag.FromErr(err) + } + return diags +} +func getFabricNetworkUpdateRequest(network v4.Network, d *schema.ResourceData) (v4.NetworkChangeOperation, error) { + changeOps := v4.NetworkChangeOperation{} + existingName := network.Name + updateNameVal := d.Get("name") + + log.Printf("existing name %s, Update Name Request %s ", existingName, updateNameVal) + + if existingName != updateNameVal { + changeOps = v4.NetworkChangeOperation{Op: "replace", Path: "/name", Value: &updateNameVal} + } else { + return changeOps, fmt.Errorf("nothing to update for the Fabric Network: %s", existingName) + } + return changeOps, nil +} +func resourceFabricNetworkUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client := meta.(*config.Config).FabricClient + ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*config.Config).FabricAuthToken) + dbConn, err := waitUntilFabricNetworkIsProvisioned(d.Id(), meta, ctx) + if err != nil { + if !strings.Contains(err.Error(), "500") { + d.SetId("") + } + return diag.Errorf("either timed out or errored out while fetching Fabric Network for uuid %s and error %v", d.Id(), err) + } + // TO-DO + update, err := getFabricNetworkUpdateRequest(dbConn, d) + if err != nil { + return diag.FromErr(err) + } + updates := []v4.NetworkChangeOperation{update} + _, res, err := client.NetworksApi.UpdateNetworkByUuid(ctx, updates, d.Id()) + if err != nil { + return diag.FromErr(fmt.Errorf("error response for the Fabric Network update, response %v, error %v", res, err)) + } + updateFg := v4.Network{} + updateFg, err = waitForFabricNetworkUpdateCompletion(d.Id(), meta, ctx) + + if err != nil { + if !strings.Contains(err.Error(), "500") { + d.SetId("") + } + return diag.FromErr(fmt.Errorf("errored while waiting for successful Fabric Network update, response %v, error %v", res, err)) + } + + d.SetId(updateFg.Uuid) + return setFabricNetworkMap(d, updateFg) +} + +func waitForFabricNetworkUpdateCompletion(uuid string, meta interface{}, ctx context.Context) (v4.Network, error) { + log.Printf("Waiting for Network update to complete, uuid %s", uuid) + stateConf := &resource.StateChangeConf{ + Target: []string{string(v4.PROVISIONED_NetworkEquinixStatus)}, + Refresh: func() (interface{}, string, error) { + client := meta.(*config.Config).FabricClient + dbConn, _, err := client.NetworksApi.GetNetworkByUuid(ctx, uuid) + if err != nil { + return "", "", err + } + return dbConn, string(*dbConn.Operation.EquinixStatus), nil + }, + Timeout: 2 * time.Minute, + Delay: 30 * time.Second, + MinTimeout: 30 * time.Second, + } + + inter, err := stateConf.WaitForStateContext(ctx) + dbConn := v4.Network{} + + if err == nil { + dbConn = inter.(v4.Network) + } + return dbConn, err +} + +func waitUntilFabricNetworkIsProvisioned(uuid string, meta interface{}, ctx context.Context) (v4.Network, error) { + log.Printf("Waiting for Fabric Network to be provisioned, uuid %s", uuid) + stateConf := &resource.StateChangeConf{ + Pending: []string{ + string(v4.PROVISIONING_NetworkEquinixStatus), + }, + Target: []string{ + string(v4.PROVISIONED_NetworkEquinixStatus), + }, + Refresh: func() (interface{}, string, error) { + client := meta.(*config.Config).FabricClient + dbConn, _, err := client.NetworksApi.GetNetworkByUuid(ctx, uuid) + if err != nil { + return "", "", err + } + return dbConn, string(*dbConn.Operation.EquinixStatus), nil + }, + Timeout: 5 * time.Minute, + Delay: 30 * time.Second, + MinTimeout: 30 * time.Second, + } + + inter, err := stateConf.WaitForStateContext(ctx) + dbConn := v4.Network{} + + if err == nil { + dbConn = inter.(v4.Network) + } + return dbConn, err +} + +func resourceFabricNetworkDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + diags := diag.Diagnostics{} + client := meta.(*config.Config).FabricClient + ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*config.Config).FabricAuthToken) + _, resp, err := client.NetworksApi.DeleteNetworkByUuid(ctx, d.Id()) + if err != nil { + errors, ok := err.(v4.GenericSwaggerError).Model().([]v4.ModelError) + if ok { + // EQ-3040055 = There is an existing update in REQUESTED state + if hasModelErrorCode(errors, "EQ-3040055") { + return diags + } + } + return diag.FromErr(fmt.Errorf("error response for the Fabric Network delete. Error %v and response %v", err, resp)) + } + + err = waitUntilFabricNetworkDeprovisioned(d.Id(), meta, ctx) + if err != nil { + return diag.FromErr(fmt.Errorf("API call failed while waiting for resource deletion. Error %v", err)) + } + return diags +} + +func waitUntilFabricNetworkDeprovisioned(uuid string, meta interface{}, ctx context.Context) error { + log.Printf("Waiting for Fabric Network to be deprovisioned, uuid %s", uuid) + stateConf := &resource.StateChangeConf{ + Pending: []string{ + string(v4.DEPROVISIONING_NetworkEquinixStatus), + }, + Target: []string{ + string(v4.DEPROVISIONED_NetworkEquinixStatus), + }, + Refresh: func() (interface{}, string, error) { + client := meta.(*config.Config).FabricClient + dbConn, _, err := client.NetworksApi.GetNetworkByUuid(ctx, uuid) + if err != nil { + return "", "", err + } + return dbConn, string(*dbConn.Operation.EquinixStatus), nil + }, + Timeout: 5 * time.Minute, + Delay: 30 * time.Second, + MinTimeout: 30 * time.Second, + } + + _, err := stateConf.WaitForStateContext(ctx) + return err +} diff --git a/equinix/resource_fabric_network_acc_test.go b/equinix/resource_fabric_network_acc_test.go new file mode 100644 index 000000000..1b5e94254 --- /dev/null +++ b/equinix/resource_fabric_network_acc_test.go @@ -0,0 +1,91 @@ +package equinix + +import ( + "context" + "fmt" + "testing" + + "github.com/equinix/terraform-provider-equinix/internal/config" + + v4 "github.com/equinix-labs/fabric-go/fabric/v4" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccNetworkCreate(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: checkNetworkDelete, + Steps: []resource.TestStep{ + { + Config: testAccNetworkCreateConfig("Ipwan_tf_acc_test"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "equinix_fabric_network.test", "name", "network_acc_test"), + ), + ExpectNonEmptyPlan: false, + }, + { + Config: testAccNetworkCreateConfig("Ipwan_tf_acc_update"), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "equinix_fabric_network.test", "name", "network_name_update"), + ), + ExpectNonEmptyPlan: false, + }, + }, + }) +} + +func checkNetworkDelete(s *terraform.State) error { + ctx := context.Background() + ctx = context.WithValue(ctx, v4.ContextAccessToken, testAccProvider.Meta().(*config.Config).FabricAuthToken) + for _, rs := range s.RootModule().Resources { + if rs.Type != "equinix_fabric_network" { + continue + } + err := waitUntilNetworkDeprovisioned(rs.Primary.ID, testAccProvider.Meta(), ctx) + if err != nil { + return fmt.Errorf("API call failed while waiting for resource deletion") + } + } + return nil +} + +func testAccNetworkCreateConfig(name string) string { + return fmt.Sprintf(`resource "equinix_fabric_network" "test"{ + type = "EVPLAN" + name = "%s" + scope = "GLOBAL" + notifications{ + type = "ALL" + emails = [ + "test@equinix.com", + "test1@equinix.com" + ] + } + }`, name) +} + +func TestAccNetworkRead(t *testing.T) { + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccNetworkReadConfig(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "equinix_fabric_network.test", "name", "network_acc_test"), + ), + }, + }, + }) +} + +func testAccNetworkReadConfig() string { + return `data "equinix_fabric_network" "test" { + uuid = "" + }` +} diff --git a/examples/fabric/v4/network/README.md b/examples/fabric/v4/network/README.md new file mode 100644 index 000000000..48e7d4c9c --- /dev/null +++ b/examples/fabric/v4/network/README.md @@ -0,0 +1,34 @@ +# ECX Fabric network CRUD operations +This example shows how to create Fabric network + +Note: Each time you need to create a new Fabric Network resource, +make a copy of the base folder - examples/fabric/v4/network and CD into this folder to perform all the CRUD operations. + +## Define values for the Fabric network create +At minimum, you must set below variables in `terraform.tfvars` file: + - `equinix_client_id` - Equinix client ID (consumer key), obtained after + registering app in the developer platform + - `equinix_client_secret` - Equinix client secret ID (consumer secret), + obtained same way as above + - `network_name` - Name of ECX Fabric network + - `network_type` - Fabric network type + - `network_scope` - Fabric network scope + - `notifications_type` - notification type + - `notifications_emails` - List of emails + +## Initialize +- First step is to initialize the terraform directory/resource we are going to work on. +In the given example, the folder to perform CRUD operations on an network resource can be found at examples/fabric-cloud-router/. + +- Change directory into - `CD examples/fabric-cloud-router/` +- Initialize Terraform plugins - `terraform init` + +## Fabric network : Create, Read, Update and Delete(CRUD) operations + Note: `–auto-approve` command does not prompt the user for validating the applying config. Remove it to get a prompt to confirm the operation. + +| Operation | Command | Description | +|:----------|:---------------------------------:|---------------------------------------------------------------------------:| +| CREATE | `terraform apply –auto-approve` | Creates an network resource | +| READ | `terraform show` | Reads/Shows the current state of the network resource | +| UPDATE | `terraform apply -refresh` | Updates the network resource with values provided in the terraform.tfvars file | +| DELETE | `terraform destroy –auto-approve` | Deletes the created network resource | \ No newline at end of file diff --git a/examples/fabric/v4/network/main.tf b/examples/fabric/v4/network/main.tf new file mode 100644 index 000000000..c3eede7cb --- /dev/null +++ b/examples/fabric/v4/network/main.tf @@ -0,0 +1,23 @@ +provider "equinix" { + client_id = var.equinix_client_id + client_secret = var.equinix_client_secret +} + +resource "equinix_fabric_network" "test"{ + name = var.network_name + type = var.network_type + scope = var.network_scope + + notifications{ + type=var.notifications_type + emails=var.notifications_emails + } + project { + project_id= var.project_id + } +} + +output "network_result" { + value = equinix_fabric_network.test.id +} + diff --git a/examples/fabric/v4/network/terraform.tf b/examples/fabric/v4/network/terraform.tf new file mode 100644 index 000000000..fd41df1c0 --- /dev/null +++ b/examples/fabric/v4/network/terraform.tf @@ -0,0 +1,7 @@ +terraform { + required_providers { + equinix = { + source = "equinix/equinix" + } + } +} diff --git a/examples/fabric/v4/network/terraform.tfvars.example b/examples/fabric/v4/network/terraform.tfvars.example new file mode 100644 index 000000000..43435e65f --- /dev/null +++ b/examples/fabric/v4/network/terraform.tfvars.example @@ -0,0 +1,9 @@ +equinix_client_id = "" +equinix_client_secret = "" + +network_name = "terraform_fabric_network_example" +network_type = "IPWAN" +network_scope = "GLOBAL" +notifications_type = "ALL" +notifications_emails = ["example@equinix.com","test1@equinix.com"] +project_id = "1234568910" \ No newline at end of file diff --git a/examples/fabric/v4/network/variables.tf b/examples/fabric/v4/network/variables.tf new file mode 100644 index 000000000..e02586f34 --- /dev/null +++ b/examples/fabric/v4/network/variables.tf @@ -0,0 +1,9 @@ +variable "equinix_client_id" {} +variable "equinix_client_secret" {} + +variable "network_name" {} +variable "network_type" {} +variable "notifications_type" {} +variable "notifications_emails" {} +variable "project_id" {} +variable "network_scope" {}