diff --git a/apstra/blueprint/freeform_endpoint.go b/apstra/blueprint/freeform_endpoint.go index bd266a23..15d39198 100644 --- a/apstra/blueprint/freeform_endpoint.go +++ b/apstra/blueprint/freeform_endpoint.go @@ -3,22 +3,21 @@ package blueprint import ( "context" "fmt" + "net" + "strings" + "github.com/Juniper/apstra-go-sdk/apstra" "github.com/Juniper/terraform-provider-apstra/apstra/utils" "github.com/hashicorp/terraform-plugin-framework-nettypes/cidrtypes" "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" dataSourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/diag" resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "net" - "strings" ) type freeformEndpoint struct { @@ -27,6 +26,7 @@ type freeformEndpoint struct { TransformationId types.Int64 `tfsdk:"transformation_id"` Ipv4Address cidrtypes.IPv4Prefix `tfsdk:"ipv4_address"` Ipv6Address cidrtypes.IPv6Prefix `tfsdk:"ipv6_address"` + Tags types.Set `tfsdk:"tags"` } func (o freeformEndpoint) attrTypes() map[string]attr.Type { @@ -36,6 +36,7 @@ func (o freeformEndpoint) attrTypes() map[string]attr.Type { "transformation_id": types.Int64Type, "ipv4_address": cidrtypes.IPv4PrefixType{}, "ipv6_address": cidrtypes.IPv6PrefixType{}, + "tags": types.SetType{ElemType: types.StringType}, } } @@ -43,26 +44,31 @@ func (o freeformEndpoint) DatasourceAttributes() map[string]dataSourceSchema.Att return map[string]dataSourceSchema.Attribute{ "interface_name": dataSourceSchema.StringAttribute{ Computed: true, - MarkdownDescription: "the interface name", + MarkdownDescription: "The interface name, as found in the associated Device Profile, e.g. `xe-0/0/0`", }, "interface_id": dataSourceSchema.StringAttribute{ Computed: true, - MarkdownDescription: "Graph node ID of the attached interface for this side of the link endpoint ", + MarkdownDescription: "Graph node ID of the associated interface", }, "transformation_id": dataSourceSchema.Int64Attribute{ Computed: true, - MarkdownDescription: "ID of the transformation in the device profile", + MarkdownDescription: "ID # of the transformation in the Device Profile", }, "ipv4_address": dataSourceSchema.StringAttribute{ Computed: true, - MarkdownDescription: "Ipv4 address of the interface", + MarkdownDescription: "Ipv4 address of the interface in CIDR notation", CustomType: cidrtypes.IPv4PrefixType{}, }, "ipv6_address": dataSourceSchema.StringAttribute{ Computed: true, - MarkdownDescription: "Ipv6 address of the interface", + MarkdownDescription: "Ipv6 address of the interface in CIDR notation", CustomType: cidrtypes.IPv6PrefixType{}, }, + "tags": dataSourceSchema.SetAttribute{ + MarkdownDescription: "Set of Tags applied to the interface", + Computed: true, + ElementType: types.StringType, + }, } } @@ -70,34 +76,38 @@ func (o freeformEndpoint) ResourceAttributes() map[string]resourceSchema.Attribu return map[string]resourceSchema.Attribute{ "interface_name": resourceSchema.StringAttribute{ Required: true, - MarkdownDescription: "the interface name", - PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()}, + MarkdownDescription: "The interface name, as found in the associated Device Profile, e.g. `xe-0/0/0`", Validators: []validator.String{stringvalidator.LengthAtLeast(1)}, }, "interface_id": resourceSchema.StringAttribute{ Computed: true, - MarkdownDescription: "Graph node ID of the attached interface for this side of the link endpoint.", + MarkdownDescription: "Graph node ID of the associated interface", }, "transformation_id": resourceSchema.Int64Attribute{ Required: true, - MarkdownDescription: "ID of the transformation in the device profile", - PlanModifiers: []planmodifier.Int64{int64planmodifier.RequiresReplace()}, + MarkdownDescription: "ID # of the transformation in the Device Profile", Validators: []validator.Int64{int64validator.AtLeast(1)}, }, "ipv4_address": resourceSchema.StringAttribute{ Optional: true, - MarkdownDescription: "Ipv4 address of the interface", + MarkdownDescription: "Ipv4 address of the interface in CIDR notation", CustomType: cidrtypes.IPv4PrefixType{}, }, "ipv6_address": resourceSchema.StringAttribute{ Optional: true, - MarkdownDescription: "Ipv6 address of the interface", + MarkdownDescription: "Ipv6 address of the interface in CIDR notation", CustomType: cidrtypes.IPv6PrefixType{}, }, + "tags": resourceSchema.SetAttribute{ + MarkdownDescription: "Set of Tags applied to the interface", + Optional: true, + ElementType: types.StringType, + Validators: []validator.Set{setvalidator.SizeAtLeast(1)}, + }, } } -func (o *freeformEndpoint) request(systemId string) *apstra.FreeformEndpoint { +func (o *freeformEndpoint) request(ctx context.Context, systemId string, diags *diag.Diagnostics) *apstra.FreeformEndpoint { var ipNet4, ipNet6 *net.IPNet if !o.Ipv4Address.IsNull() { var ip4 net.IP @@ -110,6 +120,9 @@ func (o *freeformEndpoint) request(systemId string) *apstra.FreeformEndpoint { ipNet6.IP = ip6 } + var tags []string + diags.Append(o.Tags.ElementsAs(ctx, &tags, false)...) + return &apstra.FreeformEndpoint{ SystemId: apstra.ObjectId(systemId), Interface: apstra.FreeformInterface{ @@ -118,12 +131,13 @@ func (o *freeformEndpoint) request(systemId string) *apstra.FreeformEndpoint { TransformationId: int(o.TransformationId.ValueInt64()), Ipv4Address: ipNet4, Ipv6Address: ipNet6, + Tags: tags, }, }, } } -func (o *freeformEndpoint) loadApiData(_ context.Context, in apstra.FreeformEndpoint, diags *diag.Diagnostics) { +func (o *freeformEndpoint) loadApiData(ctx context.Context, in apstra.FreeformEndpoint, diags *diag.Diagnostics) { if in.Interface.Id == nil { diags.AddError( fmt.Sprintf("api returned nil interface Id for system %s", in.SystemId), @@ -134,7 +148,6 @@ func (o *freeformEndpoint) loadApiData(_ context.Context, in apstra.FreeformEndp o.InterfaceName = types.StringValue(in.Interface.Data.IfName) o.InterfaceId = types.StringValue(in.Interface.Id.String()) - //o.SystemId = types.StringValue(in.SystemId.String()) o.TransformationId = types.Int64Value(int64(in.Interface.Data.TransformationId)) o.Ipv4Address = cidrtypes.NewIPv4PrefixValue(in.Interface.Data.Ipv4Address.String()) if strings.Contains(o.Ipv4Address.ValueString(), "nil") { @@ -144,6 +157,7 @@ func (o *freeformEndpoint) loadApiData(_ context.Context, in apstra.FreeformEndp if strings.Contains(o.Ipv6Address.ValueString(), "nil") { o.Ipv6Address = cidrtypes.NewIPv6PrefixNull() } + o.Tags = utils.SetValueOrNull(ctx, types.StringType, in.Interface.Data.Tags, diags) } func newFreeformEndpointMap(ctx context.Context, in [2]apstra.FreeformEndpoint, diags *diag.Diagnostics) types.Map { diff --git a/apstra/blueprint/freeform_link.go b/apstra/blueprint/freeform_link.go index ab83b1b0..85e563e1 100644 --- a/apstra/blueprint/freeform_link.go +++ b/apstra/blueprint/freeform_link.go @@ -3,18 +3,18 @@ package blueprint import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier" "regexp" "github.com/Juniper/apstra-go-sdk/apstra" "github.com/Juniper/terraform-provider-apstra/apstra/utils" + "github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" dataSourceSchema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/mapplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" @@ -110,7 +110,8 @@ func (o FreeformLink) ResourceAttributes() map[string]resourceSchema.Attribute { MarkdownDescription: "Freeform Link name as shown in the Web UI.", Required: true, Validators: []validator.String{ - stringvalidator.RegexMatches(regexp.MustCompile("^[a-zA-Z0-9.-_]+$"), "name may consist only of the following characters : a-zA-Z0-9.-_")}, + stringvalidator.RegexMatches(regexp.MustCompile("^[a-zA-Z0-9.-_]+$"), "name may consist only of the following characters : a-zA-Z0-9.-_"), + }, }, "speed": resourceSchema.StringAttribute{ MarkdownDescription: "Speed of the Freeform Link.", @@ -159,7 +160,7 @@ func (o *FreeformLink) Request(ctx context.Context, diags *diag.Diagnostics) *ap var epArray [2]apstra.FreeformEndpoint var i int for systemId, endpoint := range endpoints { - epArray[i] = *endpoint.request(systemId) + epArray[i] = *endpoint.request(ctx, systemId, diags) i++ } diff --git a/apstra/resource_freeform_link_integration_test.go b/apstra/resource_freeform_link_integration_test.go index 858b2311..4b854531 100644 --- a/apstra/resource_freeform_link_integration_test.go +++ b/apstra/resource_freeform_link_integration_test.go @@ -5,12 +5,12 @@ package tfapstra_test import ( "context" "fmt" - "github.com/Juniper/apstra-go-sdk/apstra" "math/rand" "net" "strconv" "testing" + "github.com/Juniper/apstra-go-sdk/apstra" tfapstra "github.com/Juniper/terraform-provider-apstra/apstra" testutils "github.com/Juniper/terraform-provider-apstra/apstra/test_utils" "github.com/hashicorp/go-version" @@ -22,20 +22,20 @@ const ( resourceFreeformLinkHcl = ` resource %q %q { blueprint_id = %q - name = %q - tags = %s - endpoints = { + name = %q + tags = %s + endpoints = { %q = { interface_name = %q transformation_id = %d - ipv4_address = %s - ipv6_address = %s + ipv4_address = %s + ipv6_address = %s }, %q = { interface_name = %q transformation_id = %d - ipv4_address = %s - ipv6_address = %s + ipv4_address = %s + ipv6_address = %s } } } @@ -91,11 +91,13 @@ func (o resourceFreeformLink) testChecks(t testing.TB, rType, rName string) test result.append(t, "TestCheckResourceAttr", "endpoints."+endpoint.SystemId.String()+".interface_name", endpoint.Interface.Data.IfName) result.append(t, "TestCheckResourceAttr", "endpoints."+endpoint.SystemId.String()+".transformation_id", strconv.Itoa(endpoint.Interface.Data.TransformationId)) result.append(t, "TestCheckResourceAttrSet", "endpoints."+endpoint.SystemId.String()+".interface_id") + if endpoint.Interface.Data.Ipv4Address != nil { result.append(t, "TestCheckResourceAttr", "endpoints."+endpoint.SystemId.String()+".ipv4_address", endpoint.Interface.Data.Ipv4Address.String()) } else { result.append(t, "TestCheckNoResourceAttr", "endpoints."+endpoint.SystemId.String()+".ipv4_address") } + if endpoint.Interface.Data.Ipv6Address != nil { result.append(t, "TestCheckResourceAttr", "endpoints."+endpoint.SystemId.String()+".ipv6_address", endpoint.Interface.Data.Ipv6Address.String()) } else { @@ -110,12 +112,14 @@ func TestResourceFreeformLink(t *testing.T) { ctx := context.Background() client := testutils.GetTestClient(t, ctx) apiVersion := version.Must(version.NewVersion(client.ApiVersion())) + // create a blueprint bp, sysIds := testutils.FfBlueprintB(t, ctx, 2) type testStep struct { config resourceFreeformLink } + type testCase struct { apiVersionConstraints version.Constraints steps []testStep @@ -166,8 +170,8 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[0], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/0", - TransformationId: 1, + IfName: "ge-0/0/1", + TransformationId: 2, Ipv4Address: &net.IPNet{IP: net.ParseIP("192.168.10.1"), Mask: net.CIDRMask(30, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::3"), Mask: net.CIDRMask(64, 128)}, Tags: randomStrings(rand.Intn(10)+2, 6), @@ -178,8 +182,8 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[1], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/0", - TransformationId: 1, + IfName: "ge-0/0/1", + TransformationId: 2, Ipv4Address: &net.IPNet{IP: net.ParseIP("192.168.10.2"), Mask: net.CIDRMask(30, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::4"), Mask: net.CIDRMask(64, 128)}, Tags: randomStrings(rand.Intn(10)+2, 6), @@ -198,7 +202,7 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[0], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/0", + IfName: "ge-0/0/3", TransformationId: 1, Ipv4Address: nil, Ipv6Address: nil, @@ -210,7 +214,7 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[1], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/0", + IfName: "ge-0/0/3", TransformationId: 1, Ipv4Address: nil, Ipv6Address: nil, @@ -220,7 +224,8 @@ func TestResourceFreeformLink(t *testing.T) { }, }, }, - }}, + }, + }, }, "start_maximal": { steps: []testStep{ @@ -234,7 +239,7 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[0], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/5", + IfName: "ge-0/0/4", TransformationId: 1, Ipv4Address: &net.IPNet{IP: net.ParseIP("10.1.1.1"), Mask: net.CIDRMask(30, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::1"), Mask: net.CIDRMask(64, 128)}, @@ -246,7 +251,7 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[1], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/5", + IfName: "ge-0/0/4", TransformationId: 1, Ipv4Address: &net.IPNet{IP: net.ParseIP("10.1.1.2"), Mask: net.CIDRMask(30, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::2"), Mask: net.CIDRMask(64, 128)}, @@ -267,7 +272,7 @@ func TestResourceFreeformLink(t *testing.T) { Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ IfName: "ge-0/0/5", - TransformationId: 1, + TransformationId: 2, Ipv4Address: nil, Ipv6Address: nil, Tags: nil, @@ -279,7 +284,7 @@ func TestResourceFreeformLink(t *testing.T) { Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ IfName: "ge-0/0/5", - TransformationId: 1, + TransformationId: 2, Ipv4Address: nil, Ipv6Address: nil, Tags: nil, @@ -299,7 +304,7 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[0], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/5", + IfName: "ge-0/0/6", TransformationId: 1, Ipv4Address: &net.IPNet{IP: net.ParseIP("10.2.1.1"), Mask: net.CIDRMask(30, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::3"), Mask: net.CIDRMask(64, 128)}, @@ -311,7 +316,7 @@ func TestResourceFreeformLink(t *testing.T) { SystemId: sysIds[1], Interface: apstra.FreeformInterface{ Data: &apstra.FreeformInterfaceData{ - IfName: "ge-0/0/5", + IfName: "ge-0/0/6", TransformationId: 1, Ipv4Address: &net.IPNet{IP: net.ParseIP("10.2.1.2"), Mask: net.CIDRMask(30, 32)}, Ipv6Address: &net.IPNet{IP: net.ParseIP("2001:db8::4"), Mask: net.CIDRMask(64, 128)}, diff --git a/docs/data-sources/freeform_link.md b/docs/data-sources/freeform_link.md index 02fa941c..577350c7 100644 --- a/docs/data-sources/freeform_link.md +++ b/docs/data-sources/freeform_link.md @@ -16,35 +16,15 @@ At least one optional attribute is required. ## Example Usage ```terraform -# here we build a link block - -resource "apstra_freeform_link" "test" { - blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" - name = "link_a_b" - speed = "1g" - tags = ["a", "b"] - endpoints = [ - { - system_id = "-CEYpa9xZ5chndvu0OY" - interface_name = "ge-0/0/3" - transformation_id = 1 - }, - { - system_id = "ySBRdHvl2KZmWKLhkIk" - interface_name = "ge-0/0/3" - transformation_id = 1 - } - ] -} +# This example pulls details from a link in a Freeform blueprint data "apstra_freeform_link" "test" { blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" - id = apstra_freeform_link.test.id + id = "SkY0hved7LajZY7WNzU" } output "test_Link_out" { value = data.apstra_freeform_link.test } - //output #test_Link_out = { # "aggregate_link_id" = tostring(null) @@ -102,8 +82,9 @@ Link Type. An 'ethernet' link is a normal front-panel interface. An 'aggregate_l Read-Only: -- `interface_id` (String) Graph node ID of the attached interface for this side of the link endpoint -- `interface_name` (String) the interface name -- `ipv4_address` (String) Ipv4 address of the interface -- `ipv6_address` (String) Ipv6 address of the interface -- `transformation_id` (Number) ID of the transformation in the device profile +- `interface_id` (String) Graph node ID of the associated interface +- `interface_name` (String) The interface name, as found in the associated Device Profile, e.g. `xe-0/0/0` +- `ipv4_address` (String) Ipv4 address of the interface in CIDR notation +- `ipv6_address` (String) Ipv6 address of the interface in CIDR notation +- `tags` (Set of String) Set of Tags applied to the interface +- `transformation_id` (Number) ID # of the transformation in the Device Profile diff --git a/docs/resources/freeform_link.md b/docs/resources/freeform_link.md index c422089c..a5da4d69 100644 --- a/docs/resources/freeform_link.md +++ b/docs/resources/freeform_link.md @@ -13,62 +13,28 @@ This resource creates a Link in a Freeform Blueprint. ## Example Usage ```terraform +# This example creates a link between systems "-CEYpa9xZ5chndvu0OY" and +# "ySBRdHvl2KZmWKLhkIk" in a Freeform Blueprint + resource "apstra_freeform_link" "test" { blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" name = "link_a_b" - speed = "1g" tags = ["a", "b"] endpoints = [ { - system_id = "-CEYpa9xZ5chndvu0OY" - interface_name = "ge-0/0/3" + system_id = "-CEYpa9xZ5chndvu0OY" + interface_name = "ge-0/0/3" transformation_id = 1 + tags = ["prod", "native_1000BASE-T"] }, { - system_id = "ySBRdHvl2KZmWKLhkIk" - interface_name = "ge-0/0/3" + system_id = "ySBRdHvl2KZmWKLhkIk" + interface_name = "ge-0/0/3" transformation_id = 1 + tags = ["prod", "requires_transceiver"] } ] } - -data "apstra_freeform_link" "test" { - blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" - id = apstra_freeform_link.test.id -} - -output "test_Link_out" { value = data.apstra_freeform_link.test } - - -//output -#test_Link_out = { -# "aggregate_link_id" = tostring(null) -# "blueprint_id" = "043c5787-66e8-41c7-8925-c7e52fbe6e32" -# "endpoints" = tomap({ -# "-CEYpa9xZ5chndvu0OY" = { -# "interface_id" = "c459DMed3P42wapAtUY" -# "interface_name" = "ge-0/0/3" -# "ipv4_address" = tostring(null) -# "ipv6_address" = tostring(null) -# "transformation_id" = 1 -# } -# "ySBRdHvl2KZmWKLhkIk" = { -# "interface_id" = "1wWgi25jmyZ5NBy45dA" -# "interface_name" = "ge-0/0/3" -# "ipv4_address" = tostring(null) -# "ipv6_address" = tostring(null) -# "transformation_id" = 1 -# } -# }) -# "id" = "SkY0hved7LajZY7WNzU" -# "name" = "link_a_b" -# "speed" = "10G" -# "tags" = toset([ -# "a", -# "b", -# ]) -# "type" = "ethernet" -#} ``` @@ -96,17 +62,18 @@ output "test_Link_out" { value = data.apstra_freeform_link.test } Required: -- `interface_name` (String) the interface name -- `transformation_id` (Number) ID of the transformation in the device profile +- `interface_name` (String) The interface name, as found in the associated Device Profile, e.g. `xe-0/0/0` +- `transformation_id` (Number) ID # of the transformation in the Device Profile Optional: -- `ipv4_address` (String) Ipv4 address of the interface -- `ipv6_address` (String) Ipv6 address of the interface +- `ipv4_address` (String) Ipv4 address of the interface in CIDR notation +- `ipv6_address` (String) Ipv6 address of the interface in CIDR notation +- `tags` (Set of String) Set of Tags applied to the interface Read-Only: -- `interface_id` (String) Graph node ID of the attached interface for this side of the link endpoint. +- `interface_id` (String) Graph node ID of the associated interface diff --git a/examples/data-sources/apstra_freeform_link/example.tf b/examples/data-sources/apstra_freeform_link/example.tf index eb4f616f..49e2da15 100644 --- a/examples/data-sources/apstra_freeform_link/example.tf +++ b/examples/data-sources/apstra_freeform_link/example.tf @@ -1,32 +1,12 @@ -# here we build a link block - -resource "apstra_freeform_link" "test" { - blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" - name = "link_a_b" - speed = "1g" - tags = ["a", "b"] - endpoints = [ - { - system_id = "-CEYpa9xZ5chndvu0OY" - interface_name = "ge-0/0/3" - transformation_id = 1 - }, - { - system_id = "ySBRdHvl2KZmWKLhkIk" - interface_name = "ge-0/0/3" - transformation_id = 1 - } - ] -} +# This example pulls details from a link in a Freeform blueprint data "apstra_freeform_link" "test" { blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" - id = apstra_freeform_link.test.id + id = "SkY0hved7LajZY7WNzU" } output "test_Link_out" { value = data.apstra_freeform_link.test } - //output #test_Link_out = { # "aggregate_link_id" = tostring(null) diff --git a/examples/resources/apstra_freeform_link/example.tf b/examples/resources/apstra_freeform_link/example.tf index a2d678e4..9960863d 100644 --- a/examples/resources/apstra_freeform_link/example.tf +++ b/examples/resources/apstra_freeform_link/example.tf @@ -1,56 +1,22 @@ +# This example creates a link between systems "-CEYpa9xZ5chndvu0OY" and +# "ySBRdHvl2KZmWKLhkIk" in a Freeform Blueprint + resource "apstra_freeform_link" "test" { blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" name = "link_a_b" - speed = "1g" tags = ["a", "b"] endpoints = [ { - system_id = "-CEYpa9xZ5chndvu0OY" - interface_name = "ge-0/0/3" + system_id = "-CEYpa9xZ5chndvu0OY" + interface_name = "ge-0/0/3" transformation_id = 1 + tags = ["prod", "native_1000BASE-T"] }, { - system_id = "ySBRdHvl2KZmWKLhkIk" - interface_name = "ge-0/0/3" + system_id = "ySBRdHvl2KZmWKLhkIk" + interface_name = "ge-0/0/3" transformation_id = 1 + tags = ["prod", "requires_transceiver"] } ] } - -data "apstra_freeform_link" "test" { - blueprint_id = "043c5787-66e8-41c7-8925-c7e52fbe6e32" - id = apstra_freeform_link.test.id -} - -output "test_Link_out" { value = data.apstra_freeform_link.test } - - -//output -#test_Link_out = { -# "aggregate_link_id" = tostring(null) -# "blueprint_id" = "043c5787-66e8-41c7-8925-c7e52fbe6e32" -# "endpoints" = tomap({ -# "-CEYpa9xZ5chndvu0OY" = { -# "interface_id" = "c459DMed3P42wapAtUY" -# "interface_name" = "ge-0/0/3" -# "ipv4_address" = tostring(null) -# "ipv6_address" = tostring(null) -# "transformation_id" = 1 -# } -# "ySBRdHvl2KZmWKLhkIk" = { -# "interface_id" = "1wWgi25jmyZ5NBy45dA" -# "interface_name" = "ge-0/0/3" -# "ipv4_address" = tostring(null) -# "ipv6_address" = tostring(null) -# "transformation_id" = 1 -# } -# }) -# "id" = "SkY0hved7LajZY7WNzU" -# "name" = "link_a_b" -# "speed" = "10G" -# "tags" = toset([ -# "a", -# "b", -# ]) -# "type" = "ethernet" -#} \ No newline at end of file