From 1e9dfb0e02f35124540a27b3b9eb153d3e74079a Mon Sep 17 00:00:00 2001 From: akinross Date: Fri, 31 May 2024 11:36:29 +0200 Subject: [PATCH] [minor_change] Add datasource and resource for fvFBRoute in aci_vrf_fallback_route and aci_vrf_fallback_route_group --- docs/data-sources/annotation.md | 4 +- ...> relation_to_vrf_fallback_route_group.md} | 16 +- docs/data-sources/tag.md | 4 +- docs/data-sources/vrf_fallback_route.md | 62 ++ docs/data-sources/vrf_fallback_route_group.md | 7 + docs/resources/annotation.md | 4 +- ...> relation_to_vrf_fallback_route_group.md} | 32 +- docs/resources/tag.md | 4 +- docs/resources/vrf_fallback_route.md | 125 ++++ docs/resources/vrf_fallback_route_group.md | 23 + .../data-source.tf} | 2 +- .../provider.tf | 0 .../aci_vrf_fallback_route/data-source.tf | 5 + .../aci_vrf_fallback_route}/provider.tf | 0 .../provider.tf | 14 + .../resource-all-attributes.tf | 2 +- .../resource.tf} | 2 +- .../aci_vrf_fallback_route/provider.tf | 14 + .../resource-all-attributes.tf | 21 + .../aci_vrf_fallback_route/resource.tf | 5 + .../resource-all-attributes.tf | 9 + gen/definitions/classes.yaml | 14 +- gen/definitions/properties.yaml | 21 + gen/generator.go | 14 +- gen/meta/fvFBRoute.json | 647 ++++++++++++++++++ gen/templates/resource.go.tmpl | 2 +- gen/templates/testvars.yaml.tmpl | 2 +- gen/testvars/fvFBRGroup.yaml | 7 + gen/testvars/fvFBRoute.yaml | 45 ++ ...i_relation_to_vrf_fallback_route_group.go} | 30 +- ...ation_to_vrf_fallback_route_group_test.go} | 14 +- .../data_source_aci_vrf_fallback_route.go | 161 +++++ ...ata_source_aci_vrf_fallback_route_group.go | 28 + ...data_source_aci_vrf_fallback_route_test.go | 53 ++ internal/provider/provider.go | 3 + ...i_relation_to_fallback_route_group_test.go | 231 ------- ...i_relation_to_vrf_fallback_route_group.go} | 50 +- ...lation_to_vrf_fallback_route_group_test.go | 231 +++++++ .../resource_aci_vrf_fallback_route.go | 608 ++++++++++++++++ .../resource_aci_vrf_fallback_route_group.go | 160 ++++- ...ource_aci_vrf_fallback_route_group_test.go | 29 + .../resource_aci_vrf_fallback_route_test.go | 248 +++++++ main.go | 3 + 43 files changed, 2633 insertions(+), 323 deletions(-) rename docs/data-sources/{relation_to_fallback_route_group.md => relation_to_vrf_fallback_route_group.md} (83%) create mode 100644 docs/data-sources/vrf_fallback_route.md rename docs/resources/{relation_to_fallback_route_group.md => relation_to_vrf_fallback_route_group.md} (70%) create mode 100644 docs/resources/vrf_fallback_route.md rename examples/{resources/aci_relation_to_fallback_route_group/resource.tf => data-sources/aci_relation_to_vrf_fallback_route_group/data-source.tf} (61%) rename examples/data-sources/{aci_relation_to_fallback_route_group => aci_relation_to_vrf_fallback_route_group}/provider.tf (100%) create mode 100644 examples/data-sources/aci_vrf_fallback_route/data-source.tf rename examples/{resources/aci_relation_to_fallback_route_group => data-sources/aci_vrf_fallback_route}/provider.tf (100%) create mode 100644 examples/resources/aci_relation_to_vrf_fallback_route_group/provider.tf rename examples/resources/{aci_relation_to_fallback_route_group => aci_relation_to_vrf_fallback_route_group}/resource-all-attributes.tf (77%) rename examples/{data-sources/aci_relation_to_fallback_route_group/data-source.tf => resources/aci_relation_to_vrf_fallback_route_group/resource.tf} (55%) create mode 100644 examples/resources/aci_vrf_fallback_route/provider.tf create mode 100644 examples/resources/aci_vrf_fallback_route/resource-all-attributes.tf create mode 100644 examples/resources/aci_vrf_fallback_route/resource.tf create mode 100644 gen/meta/fvFBRoute.json create mode 100644 gen/testvars/fvFBRoute.yaml rename internal/provider/{data_source_aci_relation_to_fallback_route_group.go => data_source_aci_relation_to_vrf_fallback_route_group.go} (81%) rename internal/provider/{data_source_aci_relation_to_fallback_route_group_test.go => data_source_aci_relation_to_vrf_fallback_route_group_test.go} (70%) create mode 100644 internal/provider/data_source_aci_vrf_fallback_route.go create mode 100644 internal/provider/data_source_aci_vrf_fallback_route_test.go delete mode 100644 internal/provider/resource_aci_relation_to_fallback_route_group_test.go rename internal/provider/{resource_aci_relation_to_fallback_route_group.go => resource_aci_relation_to_vrf_fallback_route_group.go} (92%) create mode 100644 internal/provider/resource_aci_relation_to_vrf_fallback_route_group_test.go create mode 100644 internal/provider/resource_aci_vrf_fallback_route.go create mode 100644 internal/provider/resource_aci_vrf_fallback_route_test.go diff --git a/docs/data-sources/annotation.md b/docs/data-sources/annotation.md index 8a28ab9f1..a48ded753 100644 --- a/docs/data-sources/annotation.md +++ b/docs/data-sources/annotation.md @@ -60,6 +60,7 @@ data "aci_annotation" "example_application_epg" { - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) + - [aci_vrf_fallback_route](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route) ([fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) @@ -67,13 +68,12 @@ data "aci_annotation" "example_application_epg" { - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) + - [aci_relation_to_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_vrf_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/data-sources/relation_to_fallback_route_group.md b/docs/data-sources/relation_to_vrf_fallback_route_group.md similarity index 83% rename from docs/data-sources/relation_to_fallback_route_group.md rename to docs/data-sources/relation_to_vrf_fallback_route_group.md index da9da0235..cf9471711 100644 --- a/docs/data-sources/relation_to_fallback_route_group.md +++ b/docs/data-sources/relation_to_vrf_fallback_route_group.md @@ -4,15 +4,15 @@ # More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). subcategory: "L3Out" layout: "aci" -page_title: "ACI: aci_relation_to_fallback_route_group" -sidebar_current: "docs-aci-data-source-aci_relation_to_fallback_route_group" +page_title: "ACI: aci_relation_to_vrf_fallback_route_group" +sidebar_current: "docs-aci-data-source-aci_relation_to_vrf_fallback_route_group" description: |- - Data source for Relation To Fallback Route Group + Data source for Relation To VRF Fallback Route Group --- -# aci_relation_to_fallback_route_group # +# aci_relation_to_vrf_fallback_route_group # -Data source for Relation To Fallback Route Group +Data source for Relation To VRF Fallback Route Group ## API Information ## @@ -30,7 +30,7 @@ Data source for Relation To Fallback Route Group ```hcl -data "aci_relation_to_fallback_route_group" "example_l3_outside" { +data "aci_relation_to_vrf_fallback_route_group" "example_l3_outside" { parent_dn = aci_l3_outside.example.id target_dn = aci_vrf_fallback_route_group.test.id } @@ -47,8 +47,8 @@ data "aci_relation_to_fallback_route_group" "example_l3_outside" { ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the Relation To Fallback Route Group object. -* `annotation` (annotation) - (string) The annotation of the Relation To Fallback Route Group object. +* `id` - (string) The distinguished name (DN) of the Relation To VRF Fallback Route Group object. +* `annotation` (annotation) - (string) The annotation of the Relation To VRF Fallback Route Group object. * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. * `key` (key) - (string) The key used to uniquely identify this configuration object. diff --git a/docs/data-sources/tag.md b/docs/data-sources/tag.md index 55e36e99e..ad0d03dd4 100644 --- a/docs/data-sources/tag.md +++ b/docs/data-sources/tag.md @@ -60,6 +60,7 @@ data "aci_tag" "example_application_epg" { - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) + - [aci_vrf_fallback_route](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route) ([fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) @@ -67,13 +68,12 @@ data "aci_tag" "example_application_epg" { - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) + - [aci_relation_to_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_vrf_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. ### Read-Only ### diff --git a/docs/data-sources/vrf_fallback_route.md b/docs/data-sources/vrf_fallback_route.md new file mode 100644 index 000000000..0f251a213 --- /dev/null +++ b/docs/data-sources/vrf_fallback_route.md @@ -0,0 +1,62 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Networking" +layout: "aci" +page_title: "ACI: aci_vrf_fallback_route" +sidebar_current: "docs-aci-data-source-aci_vrf_fallback_route" +description: |- + Data source for VRF Fallback Route +--- + +# aci_vrf_fallback_route # + +Data source for VRF Fallback Route + +## API Information ## + +* Class: [fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview) + +* Supported in ACI versions: 5.2(4d) and later. + +* Distinguished Name Format: `uni/tn-{name}/ctx-{name}/fbrg-{name}/pfx-[{fbrPrefix}]` + +## GUI Information ## + +* Location: `Tenants -> Networking -> VRFs -> Policy -> Fallback Route Group -> Fallback Routes` + +## Example Usage ## + +```hcl + +data "aci_vrf_fallback_route" "example_vrf_fallback_route_group" { + parent_dn = aci_vrf_fallback_route_group.example.id + prefix_address = "2.2.2.3/24" +} + +``` + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) +* `prefix_address` (fbrPrefix) - (string) The prefix address of the VRF Fallback Route object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the VRF Fallback Route object. +* `annotation` (annotation) - (string) The annotation of the VRF Fallback Route object. +* `description` (descr) - (string) The description of the VRF Fallback Route object. +* `name` (name) - (string) The name of the VRF Fallback Route object. +* `name_alias` (nameAlias) - (string) The name alias of the VRF Fallback Route object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. diff --git a/docs/data-sources/vrf_fallback_route_group.md b/docs/data-sources/vrf_fallback_route_group.md index 03c295100..97525141c 100644 --- a/docs/data-sources/vrf_fallback_route_group.md +++ b/docs/data-sources/vrf_fallback_route_group.md @@ -59,6 +59,13 @@ data "aci_vrf_fallback_route_group" "example_vrf" { * `name_alias` (nameAlias) - (string) The name alias of the VRF Fallback Route Group Member object. * `fallback_member` (rnhAddr) - (string) The address of the VRF Fallback Route Group Member object. +* `vrf_fallback_routes` - (list) A list of VRF Fallback Routes (ACI object [fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview)). + * `annotation` (annotation) - (string) The annotation of the VRF Fallback Route object. + * `description` (descr) - (string) The description of the VRF Fallback Route object. + * `prefix_address` (fbrPrefix) - (string) The prefix address of the VRF Fallback Route object. + * `name` (name) - (string) The name of the VRF Fallback Route object. + * `name_alias` (nameAlias) - (string) The name alias of the VRF Fallback Route object. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). This attribute is supported in ACI versions: 3.2(1l) and later. * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/resources/annotation.md b/docs/resources/annotation.md index 85e946ee4..9b3b2e357 100644 --- a/docs/resources/annotation.md +++ b/docs/resources/annotation.md @@ -69,6 +69,7 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) + - [aci_vrf_fallback_route](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route) ([fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) @@ -76,13 +77,12 @@ All examples for the Annotation resource can be found in the [examples](https:// - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) + - [aci_relation_to_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_vrf_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/resources/relation_to_fallback_route_group.md b/docs/resources/relation_to_vrf_fallback_route_group.md similarity index 70% rename from docs/resources/relation_to_fallback_route_group.md rename to docs/resources/relation_to_vrf_fallback_route_group.md index c7acf8bd1..28a591c43 100644 --- a/docs/resources/relation_to_fallback_route_group.md +++ b/docs/resources/relation_to_vrf_fallback_route_group.md @@ -4,15 +4,15 @@ # More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). subcategory: "L3Out" layout: "aci" -page_title: "ACI: aci_relation_to_fallback_route_group" -sidebar_current: "docs-aci-resource-aci_relation_to_fallback_route_group" +page_title: "ACI: aci_relation_to_vrf_fallback_route_group" +sidebar_current: "docs-aci-resource-aci_relation_to_vrf_fallback_route_group" description: |- - Manages ACI Relation To Fallback Route Group + Manages ACI Relation To VRF Fallback Route Group --- -# aci_relation_to_fallback_route_group # +# aci_relation_to_vrf_fallback_route_group # -Manages ACI Relation To Fallback Route Group +Manages ACI Relation To VRF Fallback Route Group @@ -30,23 +30,23 @@ Manages ACI Relation To Fallback Route Group ## Example Usage ## -The configuration snippet below creates a Relation To Fallback Route Group with only required attributes. +The configuration snippet below creates a Relation To VRF Fallback Route Group with only required attributes. ```hcl -resource "aci_relation_to_fallback_route_group" "example_l3_outside" { +resource "aci_relation_to_vrf_fallback_route_group" "example_l3_outside" { parent_dn = aci_l3_outside.example.id target_dn = aci_vrf_fallback_route_group.test.id } ``` -The configuration snippet below shows all possible attributes of the Relation To Fallback Route Group. +The configuration snippet below shows all possible attributes of the Relation To VRF Fallback Route Group. !> This example might not be valid configuration and is only used to show all possible attributes. ```hcl -resource "aci_relation_to_fallback_route_group" "full_example_l3_outside" { +resource "aci_relation_to_vrf_fallback_route_group" "full_example_l3_outside" { parent_dn = aci_l3_outside.example.id annotation = "annotation" target_dn = aci_vrf_fallback_route_group.test.id @@ -66,7 +66,7 @@ resource "aci_relation_to_fallback_route_group" "full_example_l3_outside" { ``` -All examples for the Relation To Fallback Route Group resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_to_fallback_route_group) folder. +All examples for the Relation To VRF Fallback Route Group resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_relation_to_vrf_fallback_route_group) folder. ## Schema ## @@ -78,11 +78,11 @@ All examples for the Relation To Fallback Route Group resource can be found in t ### Read-Only ### -* `id` - (string) The distinguished name (DN) of the Relation To Fallback Route Group object. +* `id` - (string) The distinguished name (DN) of the Relation To VRF Fallback Route Group object. ### Optional ### -* `annotation` (annotation) - (string) The annotation of the Relation To Fallback Route Group object. +* `annotation` (annotation) - (string) The annotation of the Relation To VRF Fallback Route Group object. - Default: `orchestrator:terraform` * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. @@ -101,18 +101,18 @@ All examples for the Relation To Fallback Route Group resource can be found in t ## Importing -An existing Relation To Fallback Route Group can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: +An existing Relation To VRF Fallback Route Group can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: ``` -terraform import aci_relation_to_fallback_route_group.example_l3_outside uni/tn-{name}/out-{name}/rsoutToFBRGroup-[{tDn}] +terraform import aci_relation_to_vrf_fallback_route_group.example_l3_outside uni/tn-{name}/out-{name}/rsoutToFBRGroup-[{tDn}] ``` -Starting in Terraform version 1.5, an existing Relation To Fallback Route Group can be imported +Starting in Terraform version 1.5, an existing Relation To VRF Fallback Route Group can be imported using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: ``` import { id = "uni/tn-{name}/out-{name}/rsoutToFBRGroup-[{tDn}]" - to = aci_relation_to_fallback_route_group.example_l3_outside + to = aci_relation_to_vrf_fallback_route_group.example_l3_outside } ``` diff --git a/docs/resources/tag.md b/docs/resources/tag.md index d879337bc..542bc94b2 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -69,6 +69,7 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_endpoint_tag_mac](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/endpoint_tag_mac) ([fvEpMacTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvEpMacTag/overview)) - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) - [aci_vrf_fallback_route_group_member](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group_member) ([fvFBRMember](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRMember/overview)) + - [aci_vrf_fallback_route](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route) ([fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview)) - [aci_tenant](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tenant) ([fvTenant](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvTenant/overview)) - [aci_l3out_consumer_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_consumer_label) ([l3extConsLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extConsLbl/overview)) - [aci_logical_node_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_profile) ([l3extLNodeP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extLNodeP/overview)) @@ -76,13 +77,12 @@ All examples for the Tag resource can be found in the [examples](https://github. - [aci_l3_outside](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3_outside) ([l3extOut](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extOut/overview)) - [aci_l3out_provider_label](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_provider_label) ([l3extProvLbl](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extProvLbl/overview)) - [aci_logical_node_to_fabric_node](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/logical_node_to_fabric_node) ([l3extRsNodeL3OutAtt](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsNodeL3OutAtt/overview)) - - [aci_relation_to_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) + - [aci_relation_to_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_vrf_fallback_route_group) ([l3extRsOutToFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsOutToFBRGroup/overview)) - [aci_l3out_redistribute_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_redistribute_policy) ([l3extRsRedistributePol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/l3extRsRedistributePol/overview)) - [aci_external_management_network_instance_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_instance_profile) ([mgmtInstP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtInstP/overview)) - [aci_relation_to_consumed_out_of_band_contract](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/relation_to_consumed_out_of_band_contract) ([mgmtRsOoBCons](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtRsOoBCons/overview)) - [aci_external_management_network_subnet](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/external_management_network_subnet) ([mgmtSubnet](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mgmtSubnet/overview)) - [aci_l3out_node_sid_profile](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/l3out_node_sid_profile) ([mplsNodeSidP](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/mplsNodeSidP/overview)) - - [aci_netflow_exporter_policy](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/netflow_exporter_policy) ([netflowExporterPol](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/netflowExporterPol/overview)) * `key` (key) - (string) The key used to uniquely identify this configuration object. * `value` (value) - (string) The value of the property. diff --git a/docs/resources/vrf_fallback_route.md b/docs/resources/vrf_fallback_route.md new file mode 100644 index 000000000..2589f3946 --- /dev/null +++ b/docs/resources/vrf_fallback_route.md @@ -0,0 +1,125 @@ +--- +# Documentation generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). +subcategory: "Networking" +layout: "aci" +page_title: "ACI: aci_vrf_fallback_route" +sidebar_current: "docs-aci-resource-aci_vrf_fallback_route" +description: |- + Manages ACI VRF Fallback Route +--- + +# aci_vrf_fallback_route # + +Manages ACI VRF Fallback Route + + -> This resource should not be used in combination with the `vrf_fallback_route_group` nested attributes of other resources for the same object. Doing so will result in unexpected behaviour. + + +## API Information ## + +* Class: [fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview) + +* Supported in ACI versions: 5.2(4d) and later. + +* Distinguished Name Format: `uni/tn-{name}/ctx-{name}/fbrg-{name}/pfx-[{fbrPrefix}]` + +## GUI Information ## + +* Location: `Tenants -> Networking -> VRFs -> Policy -> Fallback Route Group -> Fallback Routes` + +## Example Usage ## + +The configuration snippet below creates a VRF Fallback Route with only required attributes. + +```hcl + +resource "aci_vrf_fallback_route" "example_vrf_fallback_route_group" { + parent_dn = aci_vrf_fallback_route_group.example.id + prefix_address = "2.2.2.3/24" +} + +``` +The configuration snippet below shows all possible attributes of the VRF Fallback Route. + +!> This example might not be valid configuration and is only used to show all possible attributes. + +```hcl + +resource "aci_vrf_fallback_route" "full_example_vrf_fallback_route_group" { + parent_dn = aci_vrf_fallback_route_group.example.id + annotation = "annotation" + description = "description" + prefix_address = "2.2.2.3/24" + name = "name" + name_alias = "name_alias" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} + +``` + +All examples for the VRF Fallback Route resource can be found in the [examples](https://github.com/CiscoDevNet/terraform-provider-aci/tree/master/examples/resources/aci_vrf_fallback_route) folder. + +## Schema ## + +### Required ### + +* `parent_dn` - (string) The distinguished name (DN) of the parent object, possible resources: + - [aci_vrf_fallback_route_group](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route_group) ([fvFBRGroup](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRGroup/overview)) +* `prefix_address` (fbrPrefix) - (string) The prefix address of the VRF Fallback Route object. + +### Read-Only ### + +* `id` - (string) The distinguished name (DN) of the VRF Fallback Route object. + +### Optional ### + +* `annotation` (annotation) - (string) The annotation of the VRF Fallback Route object. + - Default: `orchestrator:terraform` +* `description` (descr) - (string) The description of the VRF Fallback Route object. +* `name` (name) - (string) The name of the VRF Fallback Route object. +* `name_alias` (nameAlias) - (string) The name alias of the VRF Fallback Route object. + +* `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +* `tags` - (list) A list of Tags (ACI object [tagTag](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagTag/overview)). Tags can also be configured using a separate [aci_tag](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/tag) resource. This attribute is supported in ACI versions: 3.2(1l) and later. + + #### Required #### + + * `key` (key) - (string) The key used to uniquely identify this configuration object. + * `value` (value) - (string) The value of the property. + +## Importing + +An existing VRF Fallback Route can be [imported](https://www.terraform.io/docs/import/index.html) into this resource with its distinguished name (DN), via the following command: + +``` +terraform import aci_vrf_fallback_route.example_vrf_fallback_route_group uni/tn-{name}/ctx-{name}/fbrg-{name}/pfx-[{fbrPrefix}] +``` + +Starting in Terraform version 1.5, an existing VRF Fallback Route can be imported +using [import blocks](https://developer.hashicorp.com/terraform/language/import) via the following configuration: + +``` +import { + id = "uni/tn-{name}/ctx-{name}/fbrg-{name}/pfx-[{fbrPrefix}]" + to = aci_vrf_fallback_route.example_vrf_fallback_route_group +} +``` diff --git a/docs/resources/vrf_fallback_route_group.md b/docs/resources/vrf_fallback_route_group.md index dbfacd95f..07bbe7bdb 100644 --- a/docs/resources/vrf_fallback_route_group.md +++ b/docs/resources/vrf_fallback_route_group.md @@ -61,6 +61,15 @@ resource "aci_vrf_fallback_route_group" "full_example_vrf" { fallback_member = "2.2.2.2" } ] + vrf_fallback_routes = [ + { + annotation = "annotation_1" + description = "description_1" + prefix_address = "2.2.2.2/24" + name = "name_1" + name_alias = "name_alias_1" + } + ] annotations = [ { key = "key_0" @@ -112,6 +121,20 @@ All examples for the VRF Fallback Route Group resource can be found in the [exam * `name` (name) - (string) The name of the VRF Fallback Route Group Member object. * `name_alias` (nameAlias) - (string) The name alias of the VRF Fallback Route Group Member object. +* `vrf_fallback_routes` - (list) A list of VRF Fallback Routes (ACI object [fvFBRoute](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/fvFBRoute/overview)). VRF Fallback Routes can also be configured using a separate [aci_vrf_fallback_route](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/vrf_fallback_route) resource. + + #### Required #### + + * `prefix_address` (fbrPrefix) - (string) The prefix address of the VRF Fallback Route object. + + #### Optional #### + + * `annotation` (annotation) - (string) The annotation of the VRF Fallback Route object. + - Default: `orchestrator:terraform` + * `description` (descr) - (string) The description of the VRF Fallback Route object. + * `name` (name) - (string) The name of the VRF Fallback Route object. + * `name_alias` (nameAlias) - (string) The name alias of the VRF Fallback Route object. + * `annotations` - (list) A list of Annotations (ACI object [tagAnnotation](https://pubhub.devnetcloud.com/media/model-doc-latest/docs/app/index.html#/objects/tagAnnotation/overview)). Annotations can also be configured using a separate [aci_annotation](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/annotation) resource. This attribute is supported in ACI versions: 3.2(1l) and later. #### Required #### diff --git a/examples/resources/aci_relation_to_fallback_route_group/resource.tf b/examples/data-sources/aci_relation_to_vrf_fallback_route_group/data-source.tf similarity index 61% rename from examples/resources/aci_relation_to_fallback_route_group/resource.tf rename to examples/data-sources/aci_relation_to_vrf_fallback_route_group/data-source.tf index 7649dd8fd..b0fae40d5 100644 --- a/examples/resources/aci_relation_to_fallback_route_group/resource.tf +++ b/examples/data-sources/aci_relation_to_vrf_fallback_route_group/data-source.tf @@ -1,5 +1,5 @@ -resource "aci_relation_to_fallback_route_group" "example_l3_outside" { +data "aci_relation_to_vrf_fallback_route_group" "example_l3_outside" { parent_dn = aci_l3_outside.example.id target_dn = aci_vrf_fallback_route_group.test.id } diff --git a/examples/data-sources/aci_relation_to_fallback_route_group/provider.tf b/examples/data-sources/aci_relation_to_vrf_fallback_route_group/provider.tf similarity index 100% rename from examples/data-sources/aci_relation_to_fallback_route_group/provider.tf rename to examples/data-sources/aci_relation_to_vrf_fallback_route_group/provider.tf diff --git a/examples/data-sources/aci_vrf_fallback_route/data-source.tf b/examples/data-sources/aci_vrf_fallback_route/data-source.tf new file mode 100644 index 000000000..62147fd78 --- /dev/null +++ b/examples/data-sources/aci_vrf_fallback_route/data-source.tf @@ -0,0 +1,5 @@ + +data "aci_vrf_fallback_route" "example_vrf_fallback_route_group" { + parent_dn = aci_vrf_fallback_route_group.example.id + prefix_address = "2.2.2.3/24" +} diff --git a/examples/resources/aci_relation_to_fallback_route_group/provider.tf b/examples/data-sources/aci_vrf_fallback_route/provider.tf similarity index 100% rename from examples/resources/aci_relation_to_fallback_route_group/provider.tf rename to examples/data-sources/aci_vrf_fallback_route/provider.tf diff --git a/examples/resources/aci_relation_to_vrf_fallback_route_group/provider.tf b/examples/resources/aci_relation_to_vrf_fallback_route_group/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_relation_to_vrf_fallback_route_group/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_relation_to_fallback_route_group/resource-all-attributes.tf b/examples/resources/aci_relation_to_vrf_fallback_route_group/resource-all-attributes.tf similarity index 77% rename from examples/resources/aci_relation_to_fallback_route_group/resource-all-attributes.tf rename to examples/resources/aci_relation_to_vrf_fallback_route_group/resource-all-attributes.tf index 34cbde73b..1c98a788d 100644 --- a/examples/resources/aci_relation_to_fallback_route_group/resource-all-attributes.tf +++ b/examples/resources/aci_relation_to_vrf_fallback_route_group/resource-all-attributes.tf @@ -1,5 +1,5 @@ -resource "aci_relation_to_fallback_route_group" "full_example_l3_outside" { +resource "aci_relation_to_vrf_fallback_route_group" "full_example_l3_outside" { parent_dn = aci_l3_outside.example.id annotation = "annotation" target_dn = aci_vrf_fallback_route_group.test.id diff --git a/examples/data-sources/aci_relation_to_fallback_route_group/data-source.tf b/examples/resources/aci_relation_to_vrf_fallback_route_group/resource.tf similarity index 55% rename from examples/data-sources/aci_relation_to_fallback_route_group/data-source.tf rename to examples/resources/aci_relation_to_vrf_fallback_route_group/resource.tf index 147b177a0..4f5837ae0 100644 --- a/examples/data-sources/aci_relation_to_fallback_route_group/data-source.tf +++ b/examples/resources/aci_relation_to_vrf_fallback_route_group/resource.tf @@ -1,5 +1,5 @@ -data "aci_relation_to_fallback_route_group" "example_l3_outside" { +resource "aci_relation_to_vrf_fallback_route_group" "example_l3_outside" { parent_dn = aci_l3_outside.example.id target_dn = aci_vrf_fallback_route_group.test.id } diff --git a/examples/resources/aci_vrf_fallback_route/provider.tf b/examples/resources/aci_vrf_fallback_route/provider.tf new file mode 100644 index 000000000..975fca093 --- /dev/null +++ b/examples/resources/aci_vrf_fallback_route/provider.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + aci = { + source = "ciscodevnet/aci" + } + } +} + +provider "aci" { + username = "" + password = "" + url = "" + insecure = true +} \ No newline at end of file diff --git a/examples/resources/aci_vrf_fallback_route/resource-all-attributes.tf b/examples/resources/aci_vrf_fallback_route/resource-all-attributes.tf new file mode 100644 index 000000000..6edb6c17c --- /dev/null +++ b/examples/resources/aci_vrf_fallback_route/resource-all-attributes.tf @@ -0,0 +1,21 @@ + +resource "aci_vrf_fallback_route" "full_example_vrf_fallback_route_group" { + parent_dn = aci_vrf_fallback_route_group.example.id + annotation = "annotation" + description = "description" + prefix_address = "2.2.2.3/24" + name = "name" + name_alias = "name_alias" + annotations = [ + { + key = "key_0" + value = "value_1" + } + ] + tags = [ + { + key = "key_0" + value = "value_1" + } + ] +} diff --git a/examples/resources/aci_vrf_fallback_route/resource.tf b/examples/resources/aci_vrf_fallback_route/resource.tf new file mode 100644 index 000000000..14f5f4f7d --- /dev/null +++ b/examples/resources/aci_vrf_fallback_route/resource.tf @@ -0,0 +1,5 @@ + +resource "aci_vrf_fallback_route" "example_vrf_fallback_route_group" { + parent_dn = aci_vrf_fallback_route_group.example.id + prefix_address = "2.2.2.3/24" +} diff --git a/examples/resources/aci_vrf_fallback_route_group/resource-all-attributes.tf b/examples/resources/aci_vrf_fallback_route_group/resource-all-attributes.tf index b62d8fdf0..d4122c20d 100644 --- a/examples/resources/aci_vrf_fallback_route_group/resource-all-attributes.tf +++ b/examples/resources/aci_vrf_fallback_route_group/resource-all-attributes.tf @@ -14,6 +14,15 @@ resource "aci_vrf_fallback_route_group" "full_example_vrf" { fallback_member = "2.2.2.2" } ] + vrf_fallback_routes = [ + { + annotation = "annotation_1" + description = "description_1" + prefix_address = "2.2.2.2/24" + name = "name_1" + name_alias = "name_alias_1" + } + ] annotations = [ { key = "key_0" diff --git a/gen/definitions/classes.yaml b/gen/definitions/classes.yaml index a28175ee5..d425fc485 100644 --- a/gen/definitions/classes.yaml +++ b/gen/definitions/classes.yaml @@ -146,6 +146,7 @@ fvFBRGroup: resource_name: "vrf_fallback_route_group" children: - "fvFBRMember" + - "fvFBRoute" contained_by: - "fvCtx" ui_locations: @@ -154,16 +155,23 @@ fvFBRGroup: fvFBRMember: resource_name: "vrf_fallback_route_group_member" - contained_by: - - "fvFBRGroup" ui_locations: - "Tenants -> Networking -> VRFs -> Policy -> Fallback Route Group -> Fallback Members" sub_category: "Networking" resource_notes: - "This resource should not be used in combination with the `vrf_fallback_route_group` nested attributes of other resources for the same object. Doing so will result in unexpected behaviour." +fvFBRoute: + resource_name: "vrf_fallback_route" + max_one_class_allowed: true + ui_locations: + - "Tenants -> Networking -> VRFs -> Policy -> Fallback Route Group -> Fallback Routes" + sub_category: "Networking" + resource_notes: + - "This resource should not be used in combination with the `vrf_fallback_route_group` nested attributes of other resources for the same object. Doing so will result in unexpected behaviour." + l3extRsOutToFBRGroup: - resource_name: "relation_to_fallback_route_group" + resource_name: "relation_to_vrf_fallback_route_group" ui_locations: - "Tenants -> Networking -> L3Outs -> Policy -> Main -> Fallback Route Group" sub_category: "L3Out" diff --git a/gen/definitions/properties.yaml b/gen/definitions/properties.yaml index 16d746eb3..77d4db438 100644 --- a/gen/definitions/properties.yaml +++ b/gen/definitions/properties.yaml @@ -192,6 +192,27 @@ fvFBRMember: parent_dn: "aci_vrf_fallback_route_group.test.id" class_in_parent: false +fvFBRoute: + overwrites: + fbr_prefix: "prefix_address" + documentation: + fbrPrefix: "The prefix address of the %s object." + test_values: + default: + prefix_address: "2.2.2.2/24" + resource_required: + prefix_address: "2.2.2.3/24" + datasource_required: + prefix_address: "2.2.2.3/24" + datasource_non_existing: + prefix_address: "2.2.2.4/24" + test_values_for_parent: + - prefix_address: "2.2.2.2/24" + parents: + - class_name: "fvFBRGroup" + parent_dependency: "fvCtx" + parent_dn: "aci_vrf_fallback_route_group.test.id" + l3extRsOutToFBRGroup: documentation: tDn: "The distinguished name of the VRF Fallback Route Group object." diff --git a/gen/generator.go b/gen/generator.go index ba1228518..3a2de7066 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -666,6 +666,7 @@ type Model struct { Parents []string UiLocations []string IdentifiedBy []interface{} + MaxOneClassAllowed bool DnFormats []interface{} Properties map[string]Property NamedProperties map[string]Property @@ -875,6 +876,17 @@ func (m *Model) SetClassDnFormats(classDetails interface{}) { func (m *Model) SetClassIdentifiers(classDetails interface{}) { m.IdentifiedBy = uniqueInterfaceSlice(classDetails.(map[string]interface{})["identifiedBy"].([]interface{})) + m.setMax1Entry() +} + +func (m *Model) setMax1Entry() { + if v, ok := m.Definitions.Classes[m.PkgName]; ok { + for key, value := range v.(map[interface{}]interface{}) { + if key.(string) == "max_one_class_allowed" { + m.MaxOneClassAllowed = value.(bool) + } + } + } } func (m *Model) SetClassChildren(classDetails interface{}, pkgNames []string) { @@ -1534,7 +1546,7 @@ func setDocumentationData(m *Model, definitions Definitions) { // Add child class references to documentation when resource name is known for _, child := range m.Contains { match, _ := regexp.MatchString("[Rs][A-Z][^\r\n\t\f\v]", child) // match all Rs classes - if !match { + if !match && !slices.Contains(m.ChildClasses, child) { resourceName := GetResourceName(child, definitions) if !slices.Contains(excludeChildResourceNamesFromDocs, resourceName) { // exclude anotation children since they will be included into the resource when possible m.DocumentationChildren = append(m.DocumentationChildren, fmt.Sprintf("[%s_%s](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/%s)", providerName, resourceName, resourceName)) diff --git a/gen/meta/fvFBRoute.json b/gen/meta/fvFBRoute.json new file mode 100644 index 000000000..3528fb8d8 --- /dev/null +++ b/gen/meta/fvFBRoute.json @@ -0,0 +1,647 @@ +{ + "fv:FBRoute": { + "contains": { + "aaa:RbacAnnotation": "", + "fault:Delegate": "", + "tag:Annotation": "", + "tag:Tag": "" + }, + "rnMap": { + "annotationKey-": "tag:Annotation", + "fd-": "fault:Delegate", + "rbacDom-": "aaa:RbacAnnotation", + "tagKey-": "tag:Tag" + }, + "identifiedBy": [ + "fbrPrefix" + ], + "rnFormat": "pfx-[{fbrPrefix}]", + "containedBy": { + "fv:FBRGroup": "" + }, + "superClasses": [ + "fv:AFBRoute", + "pol:Comp", + "pol:Obj", + "naming:NamedObject" + ], + "subClasses": { + + }, + "relationFrom": { + + }, + "relationTo": { + + }, + "dnFormats": [ + "uni/tn-{name}/ctx-{name}/fbrg-{name}/pfx-[{fbrPrefix}]" + ], + "writeAccess": [ + "admin", + "tenant-connectivity" + ], + "readAccess": [ + "admin", + "tenant-connectivity" + ], + "faults": { + + }, + "events": { + "E4218967": "creation||fv:FBRoute", + "E4218968": "modification||fv:FBRoute", + "E4218969": "deletion||fv:FBRoute" + }, + "stats": { + + }, + "versions": "5.2(4d)-", + "isAbstract": false, + "isConfigurable": true, + "isContextRoot": false, + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false, + "isEncrypted": false, + "isExportable": true, + "isPersistent": true, + "isSubjectToQuota": false, + "isObservable": false, + "hasStats": false, + "isStat": false, + "isFaultable": false, + "isDomainable": false, + "isHealthScorable": false, + "shouldCollectHealthStats": false, + "healthCollectionSource": "faults", + "hasEventRules": false, + "abstractionLayer": "logical", + "apicNxProcessing": false, + "monitoringPolicySource": "Parent", + "isCreatableDeletable": "always", + "platformFlavors": [ + + ], + "classId": "19110", + "className": "FBRoute", + "classPkg": "fv", + "featureTag": "", + "moCategory": "Regular", + "label": "Fallback Route", + "properties": { + "annotation": { + "versions": "5.2(4d)-", + "comment": [ + "User annotation. Suggested format orchestrator:value" + ], + "isConfigurable": true, + "propGlobalId": "65399", + "propLocalId": "8719", + "label": "Annotation", + "baseType": "string:Basic", + "modelType": "mo:Annotation", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "childAction": { + "versions": "1.0(1e)-", + "comment": [ + "Delete or ignore. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "4", + "propLocalId": "5", + "label": "childAction", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationChildAction", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "16384", "localName": "deleteAll", + "platformFlavors": [ + + ], + "label": "Delete All "}, + { "value": "8192", "localName": "deleteNonPresent", + "platformFlavors": [ + + ], + "label": "Delete Non Present "}, + { "value": "4096", "localName": "ignore", + "platformFlavors": [ + + ], + "label": "Ignore "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "descr": { + "versions": "1.0(1e)-", + "comment": [ + "Specifies the description of a policy component." + ], + "isConfigurable": true, + "propGlobalId": "5582", + "propLocalId": "28", + "label": "Description", + "baseType": "string:Basic", + "modelType": "naming:Descr", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": true, + "likeProp": "naming:Described:descr", + "validators": [ + {"min" : 0, "max": 128, + "regexs": [ + {"regex" : "^[a-zA-Z0-9\\\\!#$%()*,-./:;@ _{|}~?&+]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "dn": { + "versions": "1.0(1e)-", + "comment": [ + "A tag or metadata is a non-hierarchical keyword or term assigned to the fabric module." + ], + "isConfigurable": false, + "propGlobalId": "1", + "propLocalId": "2", + "label": "dn", + "baseType": "reference:BinRef", + "modelType": "reference:BinRef", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "extMngdBy": { + "versions": "5.2(4d)-", + "comment": [ + "Indicates which orchestrator is managing this MO" + ], + "isConfigurable": false, + "propGlobalId": "65400", + "propLocalId": "8023", + "label": "Managed By", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ExtMngdByType", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "undefined", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "1", "localName": "msc", + "platformFlavors": [ + + ], + "label": "MSC "}, + { "value": "0", "localName": "undefined", + "platformFlavors": [ + + ], + "label": "Undefined "} + ], + "default": "undefined", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "fbrPrefix": { + "versions": "5.2(4d)-", + "comment": [ + "Fallback Route addr" + ], + "isConfigurable": true, + "propGlobalId": "65382", + "propLocalId": "14500", + "label": "Fallback Route Address", + "baseType": "address:Ip", + "modelType": "address:Ip", + "needsPropDelimiters": true, + "uitype": "string", + "createOnly": false, + "readWrite": false, + "readOnly": false, + "isNaming": true, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validateAsIPv4OrIPv6": true, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "lcOwn": { + "versions": "1.0(1e)-", + "comment": [ + "A value that indicates how this object was created. For internal use only." + ], + "isConfigurable": false, + "propGlobalId": "9", + "propLocalId": "9", + "label": "lcOwn", + "baseType": "scalar:Enum8", + "modelType": "mo:Owner", + "needsPropDelimiters": false, + "uitype": "enum", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "local", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "4", "localName": "implicit", + "platformFlavors": [ + + ], + "label": "Implicit "}, + { "value": "0", "localName": "local", + "platformFlavors": [ + + ], + "label": "Local "}, + { "value": "1", "localName": "policy", + "platformFlavors": [ + + ], + "label": "Policy "}, + { "value": "2", "localName": "replica", + "platformFlavors": [ + + ], + "label": "Replica "}, + { "value": "3", "localName": "resolveOnBehalf", + "platformFlavors": [ + + ], + "label": "Resolved On Behalf "} + ], + "default": "local", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "modTs": { + "versions": "1.0(1e)-", + "comment": [ + "The time when this object was last modified." + ], + "isConfigurable": false, + "propGlobalId": "7", + "propLocalId": "7", + "label": "modTs", + "baseType": "scalar:Date", + "modelType": "mo:TStamp", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "never", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "}, + { "value": "0", "localName": "never", + "platformFlavors": [ + + ], + "label": "Never "} + ], + "default": "never", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "name": { + "versions": "1.0(1e)-", + "comment": [ + "null" + ], + "isConfigurable": true, + "propGlobalId": "4991", + "propLocalId": "13", + "label": "Name", + "baseType": "string:Basic", + "modelType": "naming:Name", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": true, + "isLike": false, + "validators": [ + {"min" : 0, "max": 64, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "nameAlias": { + "versions": "2.2(1k)-", + "isConfigurable": true, + "propGlobalId": "28417", + "propLocalId": "6719", + "label": "Display Name", + "baseType": "string:Basic", + "modelType": "naming:NameAlias", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 63, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.-]+$", "type": "include"} + ] + } + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "rn": { + "versions": "1.0(1e)-", + "comment": [ + "Identifies an object from its siblings within the context of its parent object. The distinguished name contains a sequence of relative names." + ], + "isConfigurable": false, + "propGlobalId": "2", + "propLocalId": "3", + "label": "rn", + "baseType": "reference:BinRN", + "modelType": "reference:BinRN", + "needsPropDelimiters": true, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "status": { + "versions": "1.0(1e)-", + "comment": [ + "The upgrade status. This property is for internal use only." + ], + "isConfigurable": false, + "propGlobalId": "3", + "propLocalId": "4", + "label": "status", + "baseType": "scalar:Bitmask32", + "modelType": "mo:ModificationStatus", + "needsPropDelimiters": false, + "uitype": "bitmask", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validValues": [ + { "value": "2", "localName": "created", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be created. An error is returned if the object already exists. \nIn the return value of a setter method: indicates that an object has been created. \n" + ], + "label": "Created "}, + { "value": "8", "localName": "deleted", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be deleted. \nIn the return value of a setter method: indicates that an object has been deleted.\n" + ], + "label": "Deleted "}, + { "value": "4", "localName": "modified", + "platformFlavors": [ + + ], + "comment": [ + "In a setter method: specifies that an object should be modified \nIn the return value of a setter method: indicates that an object has been modified.\n" + ], + "label": "Modified "} + ], + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "uid": { + "versions": "1.0(1e)-", + "comment": [ + "A unique identifier for this object." + ], + "isConfigurable": false, + "propGlobalId": "8", + "propLocalId": "8", + "label": "uid", + "baseType": "scalar:Uint16", + "modelType": "scalar:Uint16", + "needsPropDelimiters": false, + "uitype": "auto", + "createOnly": false, + "readWrite": false, + "readOnly": true, + "isNaming": false, + "secure": false, + "implicit": true, + "mandatory": false, + "isOverride": false, + "isLike": false, + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + }, + "userdom": { + "versions": "5.0(1k)-", + "isConfigurable": true, + "propGlobalId": "60657", + "propLocalId": "13244", + "label": "userdom", + "baseType": "string:Basic", + "modelType": "mo:UserDomType", + "needsPropDelimiters": false, + "uitype": "string", + "createOnly": false, + "readWrite": true, + "readOnly": false, + "isNaming": false, + "secure": false, + "implicit": false, + "mandatory": false, + "isOverride": false, + "isLike": false, + "validators": [ + {"min" : 0, "max": 1024, + "regexs": [ + {"regex" : "^[a-zA-Z0-9_.:-]+$", "type": "include"} + ] + } + ], + "validValues": [ + { "value": "all", "localName": "defaultValue", + "platformFlavors": [ + + ], + "label": " "} + ], + "default": "all", + "platformFlavors": [ + + ], + "isNxosConverged": false, + "isDeprecated": false, + "isHidden": false + } + } + } +} diff --git a/gen/templates/resource.go.tmpl b/gen/templates/resource.go.tmpl index e91b2fd43..64ac8b67e 100644 --- a/gen/templates/resource.go.tmpl +++ b/gen/templates/resource.go.tmpl @@ -188,7 +188,7 @@ func (r *{{.ResourceClassName}}Resource) Schema(ctx context.Context, req resourc PlanModifiers: []planmodifier.Set{ setplanmodifier.UseStateForUnknown(), }, - {{- if not .IdentifiedBy}} + {{- if or (not .IdentifiedBy) .MaxOneClassAllowed}} Validators: []validator.Set{ setvalidator.SizeAtMost(1), }, diff --git a/gen/templates/testvars.yaml.tmpl b/gen/templates/testvars.yaml.tmpl index fc638fd13..c5865a705 100644 --- a/gen/templates/testvars.yaml.tmpl +++ b/gen/templates/testvars.yaml.tmpl @@ -55,7 +55,7 @@ all: children: {{- range $key, $value := .Children}}{{$name := .ResourceName}}{{$child_deletable := .AllowDelete}} {{.ResourceName}}: - {{- if not .IdentifiedBy}} + {{- if or (not .IdentifiedBy) .MaxOneClassAllowed}} - {{ range .Properties}}{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}: {{$length := len .ValidValues}}{{if ne $length 0}}"{{ index .ValidValues 0 }}"{{else if not .IsNaming}}"{{overwriteProperty .PkgName .SnakeCaseName $.Definitions}}_1"{{- else}}"{{lookupChildTestValue .PkgName $.ResourceName .SnakeCaseName $.TestVars 0 $.Definitions}}"{{- end}} {{ end}} {{- if $child_deletable -}} diff --git a/gen/testvars/fvFBRGroup.yaml b/gen/testvars/fvFBRGroup.yaml index 8fd06febd..64e105071 100644 --- a/gen/testvars/fvFBRGroup.yaml +++ b/gen/testvars/fvFBRGroup.yaml @@ -35,6 +35,13 @@ children: name_alias: "name_alias_2" fallback_member: "2.2.2.3" + vrf_fallback_routes: + - annotation: "annotation_1" + description: "description_1" + prefix_address: "2.2.2.2/24" + name: "name_1" + name_alias: "name_alias_1" + deletable_child: true annotations: - key: "key_0" value: "value_1" diff --git a/gen/testvars/fvFBRoute.yaml b/gen/testvars/fvFBRoute.yaml new file mode 100644 index 000000000..ae162cb4f --- /dev/null +++ b/gen/testvars/fvFBRoute.yaml @@ -0,0 +1,45 @@ +# Code generated by "gen/generator.go"; DO NOT EDIT. +# In order to regenerate this file execute `go generate` from the repository root. +# More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +default: + annotation: "orchestrator:terraform" + description: "" + name: "" + name_alias: "" + +datasource_non_existing: + prefix_address: "2.2.2.4/24" + +datasource_required: + prefix_address: "2.2.2.3/24" + +resource_required: + prefix_address: "2.2.2.3/24" + +all: + annotation: "annotation" + description: "description" + name: "name" + name_alias: "name_alias" + +children: + annotations: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + + tags: + - key: "key_0" + value: "value_1" + + - key: "key_1" + value: "value_2" + +parents: + - class_name: "fvFBRGroup" + parent_dependency: "fvCtx" + parent_dn: "aci_vrf_fallback_route_group.test.id" + class_in_parent: false diff --git a/internal/provider/data_source_aci_relation_to_fallback_route_group.go b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group.go similarity index 81% rename from internal/provider/data_source_aci_relation_to_fallback_route_group.go rename to internal/provider/data_source_aci_relation_to_vrf_fallback_route_group.go index 43ff1992b..f0c93fa19 100644 --- a/internal/provider/data_source_aci_relation_to_fallback_route_group.go +++ b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group.go @@ -28,21 +28,21 @@ type L3extRsOutToFBRGroupDataSource struct { } func (d *L3extRsOutToFBRGroupDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - tflog.Debug(ctx, "Start metadata of datasource: aci_relation_to_fallback_route_group") - resp.TypeName = req.ProviderTypeName + "_relation_to_fallback_route_group" - tflog.Debug(ctx, "End metadata of datasource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start metadata of datasource: aci_relation_to_vrf_fallback_route_group") + resp.TypeName = req.ProviderTypeName + "_relation_to_vrf_fallback_route_group" + tflog.Debug(ctx, "End metadata of datasource: aci_relation_to_vrf_fallback_route_group") } func (d *L3extRsOutToFBRGroupDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - tflog.Debug(ctx, "Start schema of datasource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start schema of datasource: aci_relation_to_vrf_fallback_route_group") resp.Schema = schema.Schema{ // This description is used by the documentation generator and the language server. - MarkdownDescription: "The relation_to_fallback_route_group datasource for the 'l3extRsOutToFBRGroup' class", + MarkdownDescription: "The relation_to_vrf_fallback_route_group datasource for the 'l3extRsOutToFBRGroup' class", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the Relation To Fallback Route Group object.", + MarkdownDescription: "The distinguished name (DN) of the Relation To VRF Fallback Route Group object.", }, "parent_dn": schema.StringAttribute{ Required: true, @@ -50,7 +50,7 @@ func (d *L3extRsOutToFBRGroupDataSource) Schema(ctx context.Context, req datasou }, "annotation": schema.StringAttribute{ Computed: true, - MarkdownDescription: `The annotation of the Relation To Fallback Route Group object.`, + MarkdownDescription: `The annotation of the Relation To VRF Fallback Route Group object.`, }, "target_dn": schema.StringAttribute{ Required: true, @@ -90,11 +90,11 @@ func (d *L3extRsOutToFBRGroupDataSource) Schema(ctx context.Context, req datasou }, }, } - tflog.Debug(ctx, "End schema of datasource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "End schema of datasource: aci_relation_to_vrf_fallback_route_group") } func (d *L3extRsOutToFBRGroupDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { - tflog.Debug(ctx, "Start configure of datasource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start configure of datasource: aci_relation_to_vrf_fallback_route_group") // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -112,11 +112,11 @@ func (d *L3extRsOutToFBRGroupDataSource) Configure(ctx context.Context, req data } d.client = client - tflog.Debug(ctx, "End configure of datasource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "End configure of datasource: aci_relation_to_vrf_fallback_route_group") } func (d *L3extRsOutToFBRGroupDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - tflog.Debug(ctx, "Start read of datasource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start read of datasource: aci_relation_to_vrf_fallback_route_group") var data *L3extRsOutToFBRGroupResourceModel // Read Terraform configuration data into the model @@ -131,19 +131,19 @@ func (d *L3extRsOutToFBRGroupDataSource) Read(ctx context.Context, req datasourc // Create a copy of the Id for when not found during getAndSetL3extRsOutToFBRGroupAttributes cachedId := data.Id.ValueString() - tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) getAndSetL3extRsOutToFBRGroupAttributes(ctx, &resp.Diagnostics, d.client, data) if data.Id.IsNull() { resp.Diagnostics.AddError( - "Failed to read aci_relation_to_fallback_route_group data source", - fmt.Sprintf("The aci_relation_to_fallback_route_group data source with id '%s' has not been found", cachedId), + "Failed to read aci_relation_to_vrf_fallback_route_group data source", + fmt.Sprintf("The aci_relation_to_vrf_fallback_route_group data source with id '%s' has not been found", cachedId), ) return } // Save data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) } diff --git a/internal/provider/data_source_aci_relation_to_fallback_route_group_test.go b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group_test.go similarity index 70% rename from internal/provider/data_source_aci_relation_to_fallback_route_group_test.go rename to internal/provider/data_source_aci_relation_to_vrf_fallback_route_group_test.go index 8795e178a..32c81873b 100644 --- a/internal/provider/data_source_aci_relation_to_fallback_route_group_test.go +++ b/internal/provider/data_source_aci_relation_to_vrf_fallback_route_group_test.go @@ -21,30 +21,30 @@ func TestAccDataSourceL3extRsOutToFBRGroupWithL3extOut(t *testing.T) { Config: testConfigL3extRsOutToFBRGroupDataSourceDependencyWithL3extOut, ExpectNonEmptyPlan: false, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - resource.TestCheckResourceAttr("data.aci_relation_to_fallback_route_group.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + resource.TestCheckResourceAttr("data.aci_relation_to_vrf_fallback_route_group.test", "annotation", "orchestrator:terraform"), ), }, { Config: testConfigL3extRsOutToFBRGroupNotExistingL3extOut, - ExpectError: regexp.MustCompile("Failed to read aci_relation_to_fallback_route_group data source"), + ExpectError: regexp.MustCompile("Failed to read aci_relation_to_vrf_fallback_route_group data source"), }, }, }) } const testConfigL3extRsOutToFBRGroupDataSourceDependencyWithL3extOut = testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut + ` -data "aci_relation_to_fallback_route_group" "test" { +data "aci_relation_to_vrf_fallback_route_group" "test" { parent_dn = aci_l3_outside.test.id target_dn = aci_vrf_fallback_route_group.test.id - depends_on = [aci_relation_to_fallback_route_group.test] + depends_on = [aci_relation_to_vrf_fallback_route_group.test] } ` const testConfigL3extRsOutToFBRGroupNotExistingL3extOut = testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut + ` -data "aci_relation_to_fallback_route_group" "test_non_existing" { +data "aci_relation_to_vrf_fallback_route_group" "test_non_existing" { parent_dn = aci_l3_outside.test.id target_dn = "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group_not_existing" - depends_on = [aci_relation_to_fallback_route_group.test] + depends_on = [aci_relation_to_vrf_fallback_route_group.test] } ` diff --git a/internal/provider/data_source_aci_vrf_fallback_route.go b/internal/provider/data_source_aci_vrf_fallback_route.go new file mode 100644 index 000000000..2411e0961 --- /dev/null +++ b/internal/provider/data_source_aci_vrf_fallback_route.go @@ -0,0 +1,161 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "fmt" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ datasource.DataSource = &FvFBRouteDataSource{} + +func NewFvFBRouteDataSource() datasource.DataSource { + return &FvFBRouteDataSource{} +} + +// FvFBRouteDataSource defines the data source implementation. +type FvFBRouteDataSource struct { + client *client.Client +} + +func (d *FvFBRouteDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of datasource: aci_vrf_fallback_route") + resp.TypeName = req.ProviderTypeName + "_vrf_fallback_route" + tflog.Debug(ctx, "End metadata of datasource: aci_vrf_fallback_route") +} + +func (d *FvFBRouteDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of datasource: aci_vrf_fallback_route") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The vrf_fallback_route datasource for the 'fvFBRoute' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the VRF Fallback Route object.", + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + }, + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the VRF Fallback Route object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the VRF Fallback Route object.`, + }, + "prefix_address": schema.StringAttribute{ + Required: true, + MarkdownDescription: `The prefix address of the VRF Fallback Route object.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the VRF Fallback Route object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the VRF Fallback Route object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of datasource: aci_vrf_fallback_route") +} + +func (d *FvFBRouteDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of datasource: aci_vrf_fallback_route") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + d.client = client + tflog.Debug(ctx, "End configure of datasource: aci_vrf_fallback_route") +} + +func (d *FvFBRouteDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + tflog.Debug(ctx, "Start read of datasource: aci_vrf_fallback_route") + var data *FvFBRouteResourceModel + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setFvFBRouteId(ctx, data) + + // Create a copy of the Id for when not found during getAndSetFvFBRouteAttributes + cachedId := data.Id.ValueString() + + tflog.Debug(ctx, fmt.Sprintf("Read of datasource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) + + getAndSetFvFBRouteAttributes(ctx, &resp.Diagnostics, d.client, data) + + if data.Id.IsNull() { + resp.Diagnostics.AddError( + "Failed to read aci_vrf_fallback_route data source", + fmt.Sprintf("The aci_vrf_fallback_route data source with id '%s' has not been found", cachedId), + ) + return + } + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End read of datasource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) +} diff --git a/internal/provider/data_source_aci_vrf_fallback_route_group.go b/internal/provider/data_source_aci_vrf_fallback_route_group.go index 25948dd50..d5270596a 100644 --- a/internal/provider/data_source_aci_vrf_fallback_route_group.go +++ b/internal/provider/data_source_aci_vrf_fallback_route_group.go @@ -92,6 +92,34 @@ func (d *FvFBRGroupDataSource) Schema(ctx context.Context, req datasource.Schema }, }, }, + "vrf_fallback_routes": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The annotation of the VRF Fallback Route object.`, + }, + "description": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The description of the VRF Fallback Route object.`, + }, + "prefix_address": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The prefix address of the VRF Fallback Route object.`, + }, + "name": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name of the VRF Fallback Route object.`, + }, + "name_alias": schema.StringAttribute{ + Computed: true, + MarkdownDescription: `The name alias of the VRF Fallback Route object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Computed: true, diff --git a/internal/provider/data_source_aci_vrf_fallback_route_test.go b/internal/provider/data_source_aci_vrf_fallback_route_test.go new file mode 100644 index 000000000..50e58ac8f --- /dev/null +++ b/internal/provider/data_source_aci_vrf_fallback_route_test.go @@ -0,0 +1,53 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "regexp" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccDataSourceFvFBRouteWithFvFBRGroup(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfigFvFBRouteDataSourceDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + resource.TestCheckResourceAttr("data.aci_vrf_fallback_route.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("data.aci_vrf_fallback_route.test", "description", ""), + resource.TestCheckResourceAttr("data.aci_vrf_fallback_route.test", "name", ""), + resource.TestCheckResourceAttr("data.aci_vrf_fallback_route.test", "name_alias", ""), + ), + }, + { + Config: testConfigFvFBRouteNotExistingFvFBRGroup, + ExpectError: regexp.MustCompile("Failed to read aci_vrf_fallback_route data source"), + }, + }, + }) +} + +const testConfigFvFBRouteDataSourceDependencyWithFvFBRGroup = testConfigFvFBRouteMinDependencyWithFvFBRGroup + ` +data "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" + depends_on = [aci_vrf_fallback_route.test] +} +` + +const testConfigFvFBRouteNotExistingFvFBRGroup = testConfigFvFBRouteMinDependencyWithFvFBRGroup + ` +data "aci_vrf_fallback_route" "test_non_existing" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.4/24" + depends_on = [aci_vrf_fallback_route.test] +} +` diff --git a/internal/provider/provider.go b/internal/provider/provider.go index ddca36000..1e385a8e2 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" + // temporary unused until muxing is removed // "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" @@ -200,6 +201,7 @@ func (p *AciProvider) Resources(ctx context.Context) []func() resource.Resource NewFvEpMacTagResource, NewFvFBRGroupResource, NewFvFBRMemberResource, + NewFvFBRouteResource, NewL3extConsLblResource, NewL3extProvLblResource, NewL3extRsOutToFBRGroupResource, @@ -225,6 +227,7 @@ func (p *AciProvider) DataSources(ctx context.Context) []func() datasource.DataS NewFvEpMacTagDataSource, NewFvFBRGroupDataSource, NewFvFBRMemberDataSource, + NewFvFBRouteDataSource, NewL3extConsLblDataSource, NewL3extProvLblDataSource, NewL3extRsOutToFBRGroupDataSource, diff --git a/internal/provider/resource_aci_relation_to_fallback_route_group_test.go b/internal/provider/resource_aci_relation_to_fallback_route_group_test.go deleted file mode 100644 index 6d59993bf..000000000 --- a/internal/provider/resource_aci_relation_to_fallback_route_group_test.go +++ /dev/null @@ -1,231 +0,0 @@ -// Code generated by "gen/generator.go"; DO NOT EDIT. -// In order to regenerate this file execute `go generate` from the repository root. -// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). - -package provider - -import ( - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/resource" -) - -func TestAccResourceL3extRsOutToFBRGroupWithL3extOut(t *testing.T) { - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - // Create with minimum config and verify default APIC values - { - Config: testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotation", "orchestrator:terraform"), - ), - }, - // Update with all config and verify default APIC values - { - Config: testConfigL3extRsOutToFBRGroupAllDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotation", "annotation"), - ), - }, - // Update with minimum config and verify config is unchanged - { - Config: testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - ), - }, - // Update with empty strings config or default value - { - Config: testConfigL3extRsOutToFBRGroupResetDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotation", "orchestrator:terraform"), - ), - }, - // Import testing - { - ResourceName: "aci_relation_to_fallback_route_group.test", - ImportState: true, - ImportStateVerify: true, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotation", "orchestrator:terraform"), - ), - }, - // Update with children - { - Config: testConfigL3extRsOutToFBRGroupChildrenDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.1.value", "value_2"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.1.value", "value_2"), - ), - }, - // Import testing with children - { - ResourceName: "aci_relation_to_fallback_route_group.test", - ImportState: true, - ImportStateVerify: true, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotation", "orchestrator:terraform"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.1.value", "value_2"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.1.value", "value_2"), - ), - }, - // Update with children removed from config - { - Config: testConfigL3extRsOutToFBRGroupChildrenRemoveFromConfigDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.1.value", "value_2"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.#", "2"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.key", "key_0"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.value", "value_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.1.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.1.value", "value_2"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.#", "2"), - ), - }, - // Update with children first child removed - { - Config: testConfigL3extRsOutToFBRGroupChildrenRemoveOneDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.0.value", "value_2"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.#", "1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.key", "key_1"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.0.value", "value_2"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.#", "1"), - ), - }, - // Update with all children removed - { - Config: testConfigL3extRsOutToFBRGroupChildrenRemoveAllDependencyWithL3extOut, - ExpectNonEmptyPlan: false, - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "annotations.#", "0"), - resource.TestCheckResourceAttr("aci_relation_to_fallback_route_group.test", "tags.#", "0"), - ), - }, - }, - }) -} - -const testConfigfvFBRGroupMinDependencyWithFvCtx = ` -resource "aci_vrf_fallback_route_group" "test" { - parent_dn = aci_vrf.test.id - name = "fallback_route_group" -} -` - -const testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` -resource "aci_relation_to_fallback_route_group" "test" { - parent_dn = aci_l3_outside.test.id - target_dn = aci_vrf_fallback_route_group.test.id -} -` - -const testConfigL3extRsOutToFBRGroupAllDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` -resource "aci_relation_to_fallback_route_group" "test" { - parent_dn = aci_l3_outside.test.id - target_dn = aci_vrf_fallback_route_group.test.id - annotation = "annotation" -} -` - -const testConfigL3extRsOutToFBRGroupResetDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` -resource "aci_relation_to_fallback_route_group" "test" { - parent_dn = aci_l3_outside.test.id - target_dn = aci_vrf_fallback_route_group.test.id - annotation = "orchestrator:terraform" -} -` -const testConfigL3extRsOutToFBRGroupChildrenDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` -resource "aci_relation_to_fallback_route_group" "test" { - parent_dn = aci_l3_outside.test.id - target_dn = aci_vrf_fallback_route_group.test.id - annotations = [ - { - key = "key_0" - value = "value_1" - }, - { - key = "key_1" - value = "value_2" - }, - ] - tags = [ - { - key = "key_0" - value = "value_1" - }, - { - key = "key_1" - value = "value_2" - }, - ] -} -` - -const testConfigL3extRsOutToFBRGroupChildrenRemoveFromConfigDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` -resource "aci_relation_to_fallback_route_group" "test" { - parent_dn = aci_l3_outside.test.id - target_dn = aci_vrf_fallback_route_group.test.id -} -` - -const testConfigL3extRsOutToFBRGroupChildrenRemoveOneDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` -resource "aci_relation_to_fallback_route_group" "test" { - parent_dn = aci_l3_outside.test.id - target_dn = aci_vrf_fallback_route_group.test.id - annotations = [ - { - key = "key_1" - value = "value_2" - }, - ] - tags = [ - { - key = "key_1" - value = "value_2" - }, - ] -} -` - -const testConfigL3extRsOutToFBRGroupChildrenRemoveAllDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` -resource "aci_relation_to_fallback_route_group" "test" { - parent_dn = aci_l3_outside.test.id - target_dn = aci_vrf_fallback_route_group.test.id - annotations = [] - tags = [] -} -` diff --git a/internal/provider/resource_aci_relation_to_fallback_route_group.go b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go similarity index 92% rename from internal/provider/resource_aci_relation_to_fallback_route_group.go rename to internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go index 008b9e309..9f8e530f5 100644 --- a/internal/provider/resource_aci_relation_to_fallback_route_group.go +++ b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group.go @@ -66,21 +66,21 @@ type L3extRsOutToFBRGroupIdentifier struct { } func (r *L3extRsOutToFBRGroupResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - tflog.Debug(ctx, "Start metadata of resource: aci_relation_to_fallback_route_group") - resp.TypeName = req.ProviderTypeName + "_relation_to_fallback_route_group" - tflog.Debug(ctx, "End metadata of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start metadata of resource: aci_relation_to_vrf_fallback_route_group") + resp.TypeName = req.ProviderTypeName + "_relation_to_vrf_fallback_route_group" + tflog.Debug(ctx, "End metadata of resource: aci_relation_to_vrf_fallback_route_group") } func (r *L3extRsOutToFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { - tflog.Debug(ctx, "Start schema of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start schema of resource: aci_relation_to_vrf_fallback_route_group") resp.Schema = schema.Schema{ // This description is used by the documentation generator and the language server. - MarkdownDescription: "The relation_to_fallback_route_group resource for the 'l3extRsOutToFBRGroup' class", + MarkdownDescription: "The relation_to_vrf_fallback_route_group resource for the 'l3extRsOutToFBRGroup' class", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - MarkdownDescription: "The distinguished name (DN) of the Relation To Fallback Route Group object.", + MarkdownDescription: "The distinguished name (DN) of the Relation To VRF Fallback Route Group object.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -100,7 +100,7 @@ func (r *L3extRsOutToFBRGroupResource) Schema(ctx context.Context, req resource. stringplanmodifier.UseStateForUnknown(), }, Default: stringdefault.StaticString(globalAnnotation), - MarkdownDescription: `The annotation of the Relation To Fallback Route Group object.`, + MarkdownDescription: `The annotation of the Relation To VRF Fallback Route Group object.`, }, "target_dn": schema.StringAttribute{ Required: true, @@ -164,11 +164,11 @@ func (r *L3extRsOutToFBRGroupResource) Schema(ctx context.Context, req resource. }, }, } - tflog.Debug(ctx, "End schema of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "End schema of resource: aci_relation_to_vrf_fallback_route_group") } func (r *L3extRsOutToFBRGroupResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { - tflog.Debug(ctx, "Start configure of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start configure of resource: aci_relation_to_vrf_fallback_route_group") // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -186,11 +186,11 @@ func (r *L3extRsOutToFBRGroupResource) Configure(ctx context.Context, req resour } r.client = client - tflog.Debug(ctx, "End configure of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "End configure of resource: aci_relation_to_vrf_fallback_route_group") } func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - tflog.Debug(ctx, "Start create of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start create of resource: aci_relation_to_vrf_fallback_route_group") // On create retrieve information on current state prior to making any changes in order to determine child delete operations var stateData *L3extRsOutToFBRGroupResourceModel resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) @@ -208,7 +208,7 @@ func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource. setL3extRsOutToFBRGroupId(ctx, data) - tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsOutToFBRGroupResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) @@ -231,11 +231,11 @@ func (r *L3extRsOutToFBRGroupResource) Create(ctx context.Context, req resource. // Save data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) } func (r *L3extRsOutToFBRGroupResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - tflog.Debug(ctx, "Start read of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start read of resource: aci_relation_to_vrf_fallback_route_group") var data *L3extRsOutToFBRGroupResourceModel // Read Terraform prior state data into the model @@ -245,7 +245,7 @@ func (r *L3extRsOutToFBRGroupResource) Read(ctx context.Context, req resource.Re return } - tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) getAndSetL3extRsOutToFBRGroupAttributes(ctx, &resp.Diagnostics, r.client, data) @@ -257,11 +257,11 @@ func (r *L3extRsOutToFBRGroupResource) Read(ctx context.Context, req resource.Re resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } - tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) } func (r *L3extRsOutToFBRGroupResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - tflog.Debug(ctx, "Start update of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start update of resource: aci_relation_to_vrf_fallback_route_group") var data *L3extRsOutToFBRGroupResourceModel var stateData *L3extRsOutToFBRGroupResourceModel @@ -273,7 +273,7 @@ func (r *L3extRsOutToFBRGroupResource) Update(ctx context.Context, req resource. return } - tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) var tagAnnotationPlan, tagAnnotationState []TagAnnotationL3extRsOutToFBRGroupResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) @@ -297,11 +297,11 @@ func (r *L3extRsOutToFBRGroupResource) Update(ctx context.Context, req resource. // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) - tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) } func (r *L3extRsOutToFBRGroupResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - tflog.Debug(ctx, "Start delete of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start delete of resource: aci_relation_to_vrf_fallback_route_group") var data *L3extRsOutToFBRGroupResourceModel // Read Terraform prior state data into the model @@ -311,7 +311,7 @@ func (r *L3extRsOutToFBRGroupResource) Delete(ctx context.Context, req resource. return } - tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "l3extRsOutToFBRGroup", data.Id.ValueString()) if resp.Diagnostics.HasError() { return @@ -320,18 +320,18 @@ func (r *L3extRsOutToFBRGroupResource) Delete(ctx context.Context, req resource. if resp.Diagnostics.HasError() { return } - tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_relation_to_fallback_route_group with id '%s'", data.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_relation_to_vrf_fallback_route_group with id '%s'", data.Id.ValueString())) } func (r *L3extRsOutToFBRGroupResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - tflog.Debug(ctx, "Start import state of resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "Start import state of resource: aci_relation_to_vrf_fallback_route_group") resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) var stateData *L3extRsOutToFBRGroupResourceModel resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) - tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_relation_to_fallback_route_group with id '%s'", stateData.Id.ValueString())) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_relation_to_vrf_fallback_route_group with id '%s'", stateData.Id.ValueString())) - tflog.Debug(ctx, "End import of state resource: aci_relation_to_fallback_route_group") + tflog.Debug(ctx, "End import of state resource: aci_relation_to_vrf_fallback_route_group") } func getAndSetL3extRsOutToFBRGroupAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *L3extRsOutToFBRGroupResourceModel) { diff --git a/internal/provider/resource_aci_relation_to_vrf_fallback_route_group_test.go b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group_test.go new file mode 100644 index 000000000..8f599cb69 --- /dev/null +++ b/internal/provider/resource_aci_relation_to_vrf_fallback_route_group_test.go @@ -0,0 +1,231 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceL3extRsOutToFBRGroupWithL3extOut(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigL3extRsOutToFBRGroupAllDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotation", "annotation"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigL3extRsOutToFBRGroupResetDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotation", "orchestrator:terraform"), + ), + }, + // Import testing + { + ResourceName: "aci_relation_to_vrf_fallback_route_group.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotation", "orchestrator:terraform"), + ), + }, + // Update with children + { + Config: testConfigL3extRsOutToFBRGroupChildrenDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.1.value", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_relation_to_vrf_fallback_route_group.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "target_dn", "uni/tn-test_tenant/ctx-test_vrf/fbrg-fallback_route_group"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.1.value", "value_2"), + ), + }, + // Update with children removed from config + { + Config: testConfigL3extRsOutToFBRGroupChildrenRemoveFromConfigDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigL3extRsOutToFBRGroupChildrenRemoveOneDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigL3extRsOutToFBRGroupChildrenRemoveAllDependencyWithL3extOut, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_relation_to_vrf_fallback_route_group.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigfvFBRGroupMinDependencyWithFvCtx = ` +resource "aci_vrf_fallback_route_group" "test" { + parent_dn = aci_vrf.test.id + name = "fallback_route_group" +} +` + +const testConfigL3extRsOutToFBRGroupMinDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` +resource "aci_relation_to_vrf_fallback_route_group" "test" { + parent_dn = aci_l3_outside.test.id + target_dn = aci_vrf_fallback_route_group.test.id +} +` + +const testConfigL3extRsOutToFBRGroupAllDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` +resource "aci_relation_to_vrf_fallback_route_group" "test" { + parent_dn = aci_l3_outside.test.id + target_dn = aci_vrf_fallback_route_group.test.id + annotation = "annotation" +} +` + +const testConfigL3extRsOutToFBRGroupResetDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` +resource "aci_relation_to_vrf_fallback_route_group" "test" { + parent_dn = aci_l3_outside.test.id + target_dn = aci_vrf_fallback_route_group.test.id + annotation = "orchestrator:terraform" +} +` +const testConfigL3extRsOutToFBRGroupChildrenDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` +resource "aci_relation_to_vrf_fallback_route_group" "test" { + parent_dn = aci_l3_outside.test.id + target_dn = aci_vrf_fallback_route_group.test.id + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigL3extRsOutToFBRGroupChildrenRemoveFromConfigDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` +resource "aci_relation_to_vrf_fallback_route_group" "test" { + parent_dn = aci_l3_outside.test.id + target_dn = aci_vrf_fallback_route_group.test.id +} +` + +const testConfigL3extRsOutToFBRGroupChildrenRemoveOneDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` +resource "aci_relation_to_vrf_fallback_route_group" "test" { + parent_dn = aci_l3_outside.test.id + target_dn = aci_vrf_fallback_route_group.test.id + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigL3extRsOutToFBRGroupChildrenRemoveAllDependencyWithL3extOut = testConfigfvFBRGroupMinDependencyWithFvCtx + testConfigL3extOutMinDependencyWithFvTenant + ` +resource "aci_relation_to_vrf_fallback_route_group" "test" { + parent_dn = aci_l3_outside.test.id + target_dn = aci_vrf_fallback_route_group.test.id + annotations = [] + tags = [] +} +` diff --git a/internal/provider/resource_aci_vrf_fallback_route.go b/internal/provider/resource_aci_vrf_fallback_route.go new file mode 100644 index 000000000..1993f8c5d --- /dev/null +++ b/internal/provider/resource_aci_vrf_fallback_route.go @@ -0,0 +1,608 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "context" + "encoding/json" + "fmt" + "reflect" + "strings" + + "github.com/ciscoecosystem/aci-go-client/v2/client" + "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" +) + +// Ensure provider defined types fully satisfy framework interfaces. +var _ resource.Resource = &FvFBRouteResource{} +var _ resource.ResourceWithImportState = &FvFBRouteResource{} + +func NewFvFBRouteResource() resource.Resource { + return &FvFBRouteResource{} +} + +// FvFBRouteResource defines the resource implementation. +type FvFBRouteResource struct { + client *client.Client +} + +// FvFBRouteResourceModel describes the resource data model. +type FvFBRouteResourceModel struct { + Id types.String `tfsdk:"id"` + ParentDn types.String `tfsdk:"parent_dn"` + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + FbrPrefix types.String `tfsdk:"prefix_address"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` + TagAnnotation types.Set `tfsdk:"annotations"` + TagTag types.Set `tfsdk:"tags"` +} + +// TagAnnotationFvFBRouteResourceModel describes the resource data model for the children without relation ships. +type TagAnnotationFvFBRouteResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +// TagTagFvFBRouteResourceModel describes the resource data model for the children without relation ships. +type TagTagFvFBRouteResourceModel struct { + Key types.String `tfsdk:"key"` + Value types.String `tfsdk:"value"` +} + +type FvFBRouteIdentifier struct { + FbrPrefix types.String +} + +func (r *FvFBRouteResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + tflog.Debug(ctx, "Start metadata of resource: aci_vrf_fallback_route") + resp.TypeName = req.ProviderTypeName + "_vrf_fallback_route" + tflog.Debug(ctx, "End metadata of resource: aci_vrf_fallback_route") +} + +func (r *FvFBRouteResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + tflog.Debug(ctx, "Start schema of resource: aci_vrf_fallback_route") + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "The vrf_fallback_route resource for the 'fvFBRoute' class", + + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + MarkdownDescription: "The distinguished name (DN) of the VRF Fallback Route object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "parent_dn": schema.StringAttribute{ + Required: true, + MarkdownDescription: "The distinguished name (DN) of the parent object.", + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + }, + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + Default: stringdefault.StaticString(globalAnnotation), + MarkdownDescription: `The annotation of the VRF Fallback Route object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the VRF Fallback Route object.`, + }, + "prefix_address": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + stringplanmodifier.RequiresReplace(), + }, + MarkdownDescription: `The prefix address of the VRF Fallback Route object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name of the VRF Fallback Route object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the VRF Fallback Route object.`, + }, + "annotations": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + "tags": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "key": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The key used to uniquely identify this configuration object.`, + }, + "value": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The value of the property.`, + }, + }, + }, + }, + }, + } + tflog.Debug(ctx, "End schema of resource: aci_vrf_fallback_route") +} + +func (r *FvFBRouteResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + tflog.Debug(ctx, "Start configure of resource: aci_vrf_fallback_route") + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + + client, ok := req.ProviderData.(*client.Client) + + if !ok { + resp.Diagnostics.AddError( + "Unexpected Resource Configure Type", + fmt.Sprintf("Expected *client.Client, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + + return + } + + r.client = client + tflog.Debug(ctx, "End configure of resource: aci_vrf_fallback_route") +} + +func (r *FvFBRouteResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + tflog.Debug(ctx, "Start create of resource: aci_vrf_fallback_route") + // On create retrieve information on current state prior to making any changes in order to determine child delete operations + var stateData *FvFBRouteResourceModel + resp.Diagnostics.Append(req.Plan.Get(ctx, &stateData)...) + setFvFBRouteId(ctx, stateData) + getAndSetFvFBRouteAttributes(ctx, &resp.Diagnostics, r.client, stateData) + + var data *FvFBRouteResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + setFvFBRouteId(ctx, data) + + tflog.Debug(ctx, fmt.Sprintf("Create of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRouteResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getFvFBRouteCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + + getAndSetFvFBRouteAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End create of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) +} + +func (r *FvFBRouteResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + tflog.Debug(ctx, "Start read of resource: aci_vrf_fallback_route") + var data *FvFBRouteResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Read of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) + + getAndSetFvFBRouteAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + if data.Id.IsNull() { + var emptyData *FvFBRouteResourceModel + resp.Diagnostics.Append(resp.State.Set(ctx, &emptyData)...) + } else { + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + } + + tflog.Debug(ctx, fmt.Sprintf("End read of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) +} + +func (r *FvFBRouteResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + tflog.Debug(ctx, "Start update of resource: aci_vrf_fallback_route") + var data *FvFBRouteResourceModel + var stateData *FvFBRouteResourceModel + + // Read Terraform plan data into the model + resp.Diagnostics.Append(req.Plan.Get(ctx, &data)...) + resp.Diagnostics.Append(req.State.Get(ctx, &stateData)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Update of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) + + var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRouteResourceModel + data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) + stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) + var tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel + data.TagTag.ElementsAs(ctx, &tagTagPlan, false) + stateData.TagTag.ElementsAs(ctx, &tagTagState, false) + jsonPayload := getFvFBRouteCreateJsonPayload(ctx, &resp.Diagnostics, data, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + + if resp.Diagnostics.HasError() { + return + } + + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + + if resp.Diagnostics.HasError() { + return + } + + getAndSetFvFBRouteAttributes(ctx, &resp.Diagnostics, r.client, data) + + // Save updated data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + tflog.Debug(ctx, fmt.Sprintf("End update of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) +} + +func (r *FvFBRouteResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + tflog.Debug(ctx, "Start delete of resource: aci_vrf_fallback_route") + var data *FvFBRouteResourceModel + + // Read Terraform prior state data into the model + resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + + if resp.Diagnostics.HasError() { + return + } + + tflog.Debug(ctx, fmt.Sprintf("Delete of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) + jsonPayload := GetDeleteJsonPayload(ctx, &resp.Diagnostics, "fvFBRoute", data.Id.ValueString()) + if resp.Diagnostics.HasError() { + return + } + DoRestRequest(ctx, &resp.Diagnostics, r.client, fmt.Sprintf("api/mo/%s.json", data.Id.ValueString()), "POST", jsonPayload) + if resp.Diagnostics.HasError() { + return + } + tflog.Debug(ctx, fmt.Sprintf("End delete of resource aci_vrf_fallback_route with id '%s'", data.Id.ValueString())) +} + +func (r *FvFBRouteResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + tflog.Debug(ctx, "Start import state of resource: aci_vrf_fallback_route") + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + + var stateData *FvFBRouteResourceModel + resp.Diagnostics.Append(resp.State.Get(ctx, &stateData)...) + tflog.Debug(ctx, fmt.Sprintf("Import state of resource aci_vrf_fallback_route with id '%s'", stateData.Id.ValueString())) + + tflog.Debug(ctx, "End import of state resource: aci_vrf_fallback_route") +} + +func getAndSetFvFBRouteAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *FvFBRouteResourceModel) { + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "fvFBRoute,tagAnnotation,tagTag"), "GET", nil) + + if diags.HasError() { + return + } + if requestData.Search("imdata").Search("fvFBRoute").Data() != nil { + classReadInfo := requestData.Search("imdata").Search("fvFBRoute").Data().([]interface{}) + if len(classReadInfo) == 1 { + attributes := classReadInfo[0].(map[string]interface{})["attributes"].(map[string]interface{}) + for attributeName, attributeValue := range attributes { + if attributeName == "dn" { + data.Id = basetypes.NewStringValue(attributeValue.(string)) + setFvFBRouteParentDn(ctx, attributeValue.(string), data) + } + if attributeName == "annotation" { + data.Annotation = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "descr" { + data.Descr = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "fbrPrefix" { + data.FbrPrefix = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "name" { + data.Name = basetypes.NewStringValue(attributeValue.(string)) + } + if attributeName == "nameAlias" { + data.NameAlias = basetypes.NewStringValue(attributeValue.(string)) + } + } + TagAnnotationFvFBRouteList := make([]TagAnnotationFvFBRouteResourceModel, 0) + TagTagFvFBRouteList := make([]TagTagFvFBRouteResourceModel, 0) + _, ok := classReadInfo[0].(map[string]interface{})["children"] + if ok { + children := classReadInfo[0].(map[string]interface{})["children"].([]interface{}) + for _, child := range children { + for childClassName, childClassDetails := range child.(map[string]interface{}) { + childAttributes := childClassDetails.(map[string]interface{})["attributes"].(map[string]interface{}) + if childClassName == "tagAnnotation" { + TagAnnotationFvFBRoute := TagAnnotationFvFBRouteResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagAnnotationFvFBRoute.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagAnnotationFvFBRoute.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagAnnotationFvFBRouteList = append(TagAnnotationFvFBRouteList, TagAnnotationFvFBRoute) + } + if childClassName == "tagTag" { + TagTagFvFBRoute := TagTagFvFBRouteResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "key" { + TagTagFvFBRoute.Key = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "value" { + TagTagFvFBRoute.Value = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + TagTagFvFBRouteList = append(TagTagFvFBRouteList, TagTagFvFBRoute) + } + } + } + } + tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationFvFBRouteList) + data.TagAnnotation = tagAnnotationSet + tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagFvFBRouteList) + data.TagTag = tagTagSet + } else { + diags.AddError( + "too many results in response", + fmt.Sprintf("%v matches returned for class 'fvFBRoute'. Please report this issue to the provider developers.", len(classReadInfo)), + ) + } + } else { + data.Id = basetypes.NewStringNull() + } +} + +func getFvFBRouteRn(ctx context.Context, data *FvFBRouteResourceModel) string { + rn := "pfx-[{fbrPrefix}]" + for _, identifier := range []string{"fbrPrefix"} { + fieldName := fmt.Sprintf("%s%s", strings.ToUpper(identifier[:1]), identifier[1:]) + fieldValue := reflect.ValueOf(data).Elem().FieldByName(fieldName).Interface().(basetypes.StringValue).ValueString() + rn = strings.ReplaceAll(rn, fmt.Sprintf("{%s}", identifier), fieldValue) + } + return rn +} + +func setFvFBRouteParentDn(ctx context.Context, dn string, data *FvFBRouteResourceModel) { + bracketIndex := 0 + rnIndex := 0 + for i := len(dn) - 1; i >= 0; i-- { + if string(dn[i]) == "]" { + bracketIndex = bracketIndex + 1 + } else if string(dn[i]) == "[" { + bracketIndex = bracketIndex - 1 + } else if string(dn[i]) == "/" && bracketIndex == 0 { + rnIndex = i + break + } + } + data.ParentDn = basetypes.NewStringValue(dn[:rnIndex]) +} + +func setFvFBRouteId(ctx context.Context, data *FvFBRouteResourceModel) { + rn := getFvFBRouteRn(ctx, data) + data.Id = types.StringValue(fmt.Sprintf("%s/%s", data.ParentDn.ValueString(), rn)) +} + +func getFvFBRouteTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvFBRouteResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRouteResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagAnnotation.IsUnknown() { + tagAnnotationIdentifiers := []TagAnnotationIdentifier{} + for _, tagAnnotation := range tagAnnotationPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagAnnotation.Key.IsUnknown() { + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + } + if !tagAnnotation.Value.IsUnknown() { + childMap["attributes"]["value"] = tagAnnotation.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + tagAnnotationIdentifier := TagAnnotationIdentifier{} + tagAnnotationIdentifier.Key = tagAnnotation.Key + tagAnnotationIdentifiers = append(tagAnnotationIdentifiers, tagAnnotationIdentifier) + } + for _, tagAnnotation := range tagAnnotationState { + delete := true + for _, tagAnnotationIdentifier := range tagAnnotationIdentifiers { + if tagAnnotationIdentifier.Key == tagAnnotation.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagAnnotation.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagAnnotation": childMap}) + } + } + } else { + data.TagAnnotation = types.SetNull(data.TagAnnotation.ElementType(ctx)) + } + + return childPayloads +} +func getFvFBRouteTagTagChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvFBRouteResourceModel, tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.TagTag.IsUnknown() { + tagTagIdentifiers := []TagTagIdentifier{} + for _, tagTag := range tagTagPlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !tagTag.Key.IsUnknown() { + childMap["attributes"]["key"] = tagTag.Key.ValueString() + } + if !tagTag.Value.IsUnknown() { + childMap["attributes"]["value"] = tagTag.Value.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + tagTagIdentifier := TagTagIdentifier{} + tagTagIdentifier.Key = tagTag.Key + tagTagIdentifiers = append(tagTagIdentifiers, tagTagIdentifier) + } + for _, tagTag := range tagTagState { + delete := true + for _, tagTagIdentifier := range tagTagIdentifiers { + if tagTagIdentifier.Key == tagTag.Key { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["key"] = tagTag.Key.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"tagTag": childMap}) + } + } + } else { + data.TagTag = types.SetNull(data.TagTag.ElementType(ctx)) + } + + return childPayloads +} + +func getFvFBRouteCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvFBRouteResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRouteResourceModel, tagTagPlan, tagTagState []TagTagFvFBRouteResourceModel) *container.Container { + payloadMap := map[string]interface{}{} + payloadMap["attributes"] = map[string]string{} + childPayloads := []map[string]interface{}{} + + TagAnnotationchildPayloads := getFvFBRouteTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) + if TagAnnotationchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagAnnotationchildPayloads...) + + TagTagchildPayloads := getFvFBRouteTagTagChildPayloads(ctx, diags, data, tagTagPlan, tagTagState) + if TagTagchildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, TagTagchildPayloads...) + + payloadMap["children"] = childPayloads + if !data.Annotation.IsNull() && !data.Annotation.IsUnknown() { + payloadMap["attributes"].(map[string]string)["annotation"] = data.Annotation.ValueString() + } + if !data.Descr.IsNull() && !data.Descr.IsUnknown() { + payloadMap["attributes"].(map[string]string)["descr"] = data.Descr.ValueString() + } + if !data.FbrPrefix.IsNull() && !data.FbrPrefix.IsUnknown() { + payloadMap["attributes"].(map[string]string)["fbrPrefix"] = data.FbrPrefix.ValueString() + } + if !data.Name.IsNull() && !data.Name.IsUnknown() { + payloadMap["attributes"].(map[string]string)["name"] = data.Name.ValueString() + } + if !data.NameAlias.IsNull() && !data.NameAlias.IsUnknown() { + payloadMap["attributes"].(map[string]string)["nameAlias"] = data.NameAlias.ValueString() + } + + payload, err := json.Marshal(map[string]interface{}{"fvFBRoute": payloadMap}) + if err != nil { + diags.AddError( + "Marshalling of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + + jsonPayload, err := container.ParseJSON(payload) + + if err != nil { + diags.AddError( + "Construction of json payload failed", + fmt.Sprintf("Err: %s. Please report this issue to the provider developers.", err), + ) + return nil + } + return jsonPayload +} diff --git a/internal/provider/resource_aci_vrf_fallback_route_group.go b/internal/provider/resource_aci_vrf_fallback_route_group.go index a1f9c231b..81717de26 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group.go @@ -13,6 +13,7 @@ import ( "github.com/ciscoecosystem/aci-go-client/v2/client" "github.com/ciscoecosystem/aci-go-client/v2/container" + "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -21,6 +22,7 @@ import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema/setplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types/basetypes" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -48,6 +50,7 @@ type FvFBRGroupResourceModel struct { Name types.String `tfsdk:"name"` NameAlias types.String `tfsdk:"name_alias"` FvFBRMember types.Set `tfsdk:"vrf_fallback_route_group_members"` + FvFBRoute types.Set `tfsdk:"vrf_fallback_routes"` TagAnnotation types.Set `tfsdk:"annotations"` TagTag types.Set `tfsdk:"tags"` } @@ -61,6 +64,15 @@ type FvFBRMemberFvFBRGroupResourceModel struct { RnhAddr types.String `tfsdk:"fallback_member"` } +// FvFBRouteFvFBRGroupResourceModel describes the resource data model for the children without relation ships. +type FvFBRouteFvFBRGroupResourceModel struct { + Annotation types.String `tfsdk:"annotation"` + Descr types.String `tfsdk:"description"` + FbrPrefix types.String `tfsdk:"prefix_address"` + Name types.String `tfsdk:"name"` + NameAlias types.String `tfsdk:"name_alias"` +} + // TagAnnotationFvFBRGroupResourceModel describes the resource data model for the children without relation ships. type TagAnnotationFvFBRGroupResourceModel struct { Key types.String `tfsdk:"key"` @@ -189,6 +201,60 @@ func (r *FvFBRGroupResource) Schema(ctx context.Context, req resource.SchemaRequ }, }, }, + "vrf_fallback_routes": schema.SetNestedAttribute{ + MarkdownDescription: ``, + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.Set{ + setplanmodifier.UseStateForUnknown(), + }, + Validators: []validator.Set{ + setvalidator.SizeAtMost(1), + }, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "annotation": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The annotation of the VRF Fallback Route object.`, + }, + "description": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The description of the VRF Fallback Route object.`, + }, + "prefix_address": schema.StringAttribute{ + Required: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The prefix address of the VRF Fallback Route object.`, + }, + "name": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name of the VRF Fallback Route object.`, + }, + "name_alias": schema.StringAttribute{ + Optional: true, + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + MarkdownDescription: `The name alias of the VRF Fallback Route object.`, + }, + }, + }, + }, "annotations": schema.SetNestedAttribute{ MarkdownDescription: ``, Optional: true, @@ -292,13 +358,16 @@ func (r *FvFBRGroupResource) Create(ctx context.Context, req resource.CreateRequ var fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel data.FvFBRMember.ElementsAs(ctx, &fvFBRMemberPlan, false) stateData.FvFBRMember.ElementsAs(ctx, &fvFBRMemberState, false) + var fvFBRoutePlan, fvFBRouteState []FvFBRouteFvFBRGroupResourceModel + data.FvFBRoute.ElementsAs(ctx, &fvFBRoutePlan, false) + stateData.FvFBRoute.ElementsAs(ctx, &fvFBRouteState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, fvFBRMemberPlan, fvFBRMemberState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, fvFBRMemberPlan, fvFBRMemberState, fvFBRoutePlan, fvFBRouteState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -360,13 +429,16 @@ func (r *FvFBRGroupResource) Update(ctx context.Context, req resource.UpdateRequ var fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel data.FvFBRMember.ElementsAs(ctx, &fvFBRMemberPlan, false) stateData.FvFBRMember.ElementsAs(ctx, &fvFBRMemberState, false) + var fvFBRoutePlan, fvFBRouteState []FvFBRouteFvFBRGroupResourceModel + data.FvFBRoute.ElementsAs(ctx, &fvFBRoutePlan, false) + stateData.FvFBRoute.ElementsAs(ctx, &fvFBRouteState, false) var tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel data.TagAnnotation.ElementsAs(ctx, &tagAnnotationPlan, false) stateData.TagAnnotation.ElementsAs(ctx, &tagAnnotationState, false) var tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel data.TagTag.ElementsAs(ctx, &tagTagPlan, false) stateData.TagTag.ElementsAs(ctx, &tagTagState, false) - jsonPayload := getFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, fvFBRMemberPlan, fvFBRMemberState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) + jsonPayload := getFvFBRGroupCreateJsonPayload(ctx, &resp.Diagnostics, data, fvFBRMemberPlan, fvFBRMemberState, fvFBRoutePlan, fvFBRouteState, tagAnnotationPlan, tagAnnotationState, tagTagPlan, tagTagState) if resp.Diagnostics.HasError() { return @@ -420,7 +492,7 @@ func (r *FvFBRGroupResource) ImportState(ctx context.Context, req resource.Impor } func getAndSetFvFBRGroupAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *FvFBRGroupResourceModel) { - requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "fvFBRGroup,fvFBRMember,tagAnnotation,tagTag"), "GET", nil) + requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=children&rsp-subtree-class=%s", data.Id.ValueString(), "fvFBRGroup,fvFBRMember,fvFBRoute,tagAnnotation,tagTag"), "GET", nil) if diags.HasError() { return @@ -448,6 +520,7 @@ func getAndSetFvFBRGroupAttributes(ctx context.Context, diags *diag.Diagnostics, } } FvFBRMemberFvFBRGroupList := make([]FvFBRMemberFvFBRGroupResourceModel, 0) + FvFBRouteFvFBRGroupList := make([]FvFBRouteFvFBRGroupResourceModel, 0) TagAnnotationFvFBRGroupList := make([]TagAnnotationFvFBRGroupResourceModel, 0) TagTagFvFBRGroupList := make([]TagTagFvFBRGroupResourceModel, 0) _, ok := classReadInfo[0].(map[string]interface{})["children"] @@ -477,6 +550,27 @@ func getAndSetFvFBRGroupAttributes(ctx context.Context, diags *diag.Diagnostics, } FvFBRMemberFvFBRGroupList = append(FvFBRMemberFvFBRGroupList, FvFBRMemberFvFBRGroup) } + if childClassName == "fvFBRoute" { + FvFBRouteFvFBRGroup := FvFBRouteFvFBRGroupResourceModel{} + for childAttributeName, childAttributeValue := range childAttributes { + if childAttributeName == "annotation" { + FvFBRouteFvFBRGroup.Annotation = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "descr" { + FvFBRouteFvFBRGroup.Descr = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "fbrPrefix" { + FvFBRouteFvFBRGroup.FbrPrefix = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "name" { + FvFBRouteFvFBRGroup.Name = basetypes.NewStringValue(childAttributeValue.(string)) + } + if childAttributeName == "nameAlias" { + FvFBRouteFvFBRGroup.NameAlias = basetypes.NewStringValue(childAttributeValue.(string)) + } + } + FvFBRouteFvFBRGroupList = append(FvFBRouteFvFBRGroupList, FvFBRouteFvFBRGroup) + } if childClassName == "tagAnnotation" { TagAnnotationFvFBRGroup := TagAnnotationFvFBRGroupResourceModel{} for childAttributeName, childAttributeValue := range childAttributes { @@ -506,6 +600,8 @@ func getAndSetFvFBRGroupAttributes(ctx context.Context, diags *diag.Diagnostics, } fvFBRMemberSet, _ := types.SetValueFrom(ctx, data.FvFBRMember.ElementType(ctx), FvFBRMemberFvFBRGroupList) data.FvFBRMember = fvFBRMemberSet + fvFBRouteSet, _ := types.SetValueFrom(ctx, data.FvFBRoute.ElementType(ctx), FvFBRouteFvFBRGroupList) + data.FvFBRoute = fvFBRouteSet tagAnnotationSet, _ := types.SetValueFrom(ctx, data.TagAnnotation.ElementType(ctx), TagAnnotationFvFBRGroupList) data.TagAnnotation = tagAnnotationSet tagTagSet, _ := types.SetValueFrom(ctx, data.TagTag.ElementType(ctx), TagTagFvFBRGroupList) @@ -602,6 +698,56 @@ func getFvFBRGroupFvFBRMemberChildPayloads(ctx context.Context, diags *diag.Diag return childPayloads } +func getFvFBRGroupFvFBRouteChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvFBRGroupResourceModel, fvFBRoutePlan, fvFBRouteState []FvFBRouteFvFBRGroupResourceModel) []map[string]interface{} { + + childPayloads := []map[string]interface{}{} + if !data.FvFBRoute.IsUnknown() { + fvFBRouteIdentifiers := []FvFBRouteIdentifier{} + for _, fvFBRoute := range fvFBRoutePlan { + childMap := map[string]map[string]interface{}{"attributes": {}} + if !fvFBRoute.Annotation.IsUnknown() { + childMap["attributes"]["annotation"] = fvFBRoute.Annotation.ValueString() + } else { + childMap["attributes"]["annotation"] = globalAnnotation + } + if !fvFBRoute.Descr.IsUnknown() { + childMap["attributes"]["descr"] = fvFBRoute.Descr.ValueString() + } + if !fvFBRoute.FbrPrefix.IsUnknown() { + childMap["attributes"]["fbrPrefix"] = fvFBRoute.FbrPrefix.ValueString() + } + if !fvFBRoute.Name.IsUnknown() { + childMap["attributes"]["name"] = fvFBRoute.Name.ValueString() + } + if !fvFBRoute.NameAlias.IsUnknown() { + childMap["attributes"]["nameAlias"] = fvFBRoute.NameAlias.ValueString() + } + childPayloads = append(childPayloads, map[string]interface{}{"fvFBRoute": childMap}) + fvFBRouteIdentifier := FvFBRouteIdentifier{} + fvFBRouteIdentifier.FbrPrefix = fvFBRoute.FbrPrefix + fvFBRouteIdentifiers = append(fvFBRouteIdentifiers, fvFBRouteIdentifier) + } + for _, fvFBRoute := range fvFBRouteState { + delete := true + for _, fvFBRouteIdentifier := range fvFBRouteIdentifiers { + if fvFBRouteIdentifier.FbrPrefix == fvFBRoute.FbrPrefix { + delete = false + break + } + } + if delete { + childMap := map[string]map[string]interface{}{"attributes": {}} + childMap["attributes"]["status"] = "deleted" + childMap["attributes"]["fbrPrefix"] = fvFBRoute.FbrPrefix.ValueString() + childPayloads = append(childPayloads, map[string]interface{}{"fvFBRoute": childMap}) + } + } + } else { + data.FvFBRoute = types.SetNull(data.FvFBRoute.ElementType(ctx)) + } + + return childPayloads +} func getFvFBRGroupTagAnnotationChildPayloads(ctx context.Context, diags *diag.Diagnostics, data *FvFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel) []map[string]interface{} { childPayloads := []map[string]interface{}{} @@ -681,7 +827,7 @@ func getFvFBRGroupTagTagChildPayloads(ctx context.Context, diags *diag.Diagnosti return childPayloads } -func getFvFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvFBRGroupResourceModel, fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel) *container.Container { +func getFvFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics, data *FvFBRGroupResourceModel, fvFBRMemberPlan, fvFBRMemberState []FvFBRMemberFvFBRGroupResourceModel, fvFBRoutePlan, fvFBRouteState []FvFBRouteFvFBRGroupResourceModel, tagAnnotationPlan, tagAnnotationState []TagAnnotationFvFBRGroupResourceModel, tagTagPlan, tagTagState []TagTagFvFBRGroupResourceModel) *container.Container { payloadMap := map[string]interface{}{} payloadMap["attributes"] = map[string]string{} childPayloads := []map[string]interface{}{} @@ -692,6 +838,12 @@ func getFvFBRGroupCreateJsonPayload(ctx context.Context, diags *diag.Diagnostics } childPayloads = append(childPayloads, FvFBRMemberchildPayloads...) + FvFBRoutechildPayloads := getFvFBRGroupFvFBRouteChildPayloads(ctx, diags, data, fvFBRoutePlan, fvFBRouteState) + if FvFBRoutechildPayloads == nil { + return nil + } + childPayloads = append(childPayloads, FvFBRoutechildPayloads...) + TagAnnotationchildPayloads := getFvFBRGroupTagAnnotationChildPayloads(ctx, diags, data, tagAnnotationPlan, tagAnnotationState) if TagAnnotationchildPayloads == nil { return nil diff --git a/internal/provider/resource_aci_vrf_fallback_route_group_test.go b/internal/provider/resource_aci_vrf_fallback_route_group_test.go index 9978f34be..4c3cd0797 100644 --- a/internal/provider/resource_aci_vrf_fallback_route_group_test.go +++ b/internal/provider/resource_aci_vrf_fallback_route_group_test.go @@ -96,6 +96,11 @@ func TestAccResourceFvFBRGroupWithFvCtx(t *testing.T) { resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.fallback_member", "2.2.2.3"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.name", "name_2"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.prefix_address", "2.2.2.2/24"), ), }, // Import testing with children @@ -126,6 +131,11 @@ func TestAccResourceFvFBRGroupWithFvCtx(t *testing.T) { resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.fallback_member", "2.2.2.3"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.name", "name_2"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.name_alias", "name_alias_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.prefix_address", "2.2.2.2/24"), ), }, // Update with children removed from config @@ -154,6 +164,12 @@ func TestAccResourceFvFBRGroupWithFvCtx(t *testing.T) { resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.name", "name_2"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.1.name_alias", "name_alias_2"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.#", "2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.annotation", "annotation_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.description", "description_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.name", "name_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.name_alias", "name_alias_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.0.prefix_address", "2.2.2.2/24"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.#", "1"), ), }, // Update with children first child removed @@ -173,6 +189,7 @@ func TestAccResourceFvFBRGroupWithFvCtx(t *testing.T) { resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.0.name", "name_2"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.0.name_alias", "name_alias_2"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.#", "1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.#", "0"), ), }, // Update with all children removed @@ -183,6 +200,7 @@ func TestAccResourceFvFBRGroupWithFvCtx(t *testing.T) { resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "annotations.#", "0"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "tags.#", "0"), resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_route_group_members.#", "0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route_group.test", "vrf_fallback_routes.#", "0"), ), }, }, @@ -255,6 +273,15 @@ resource "aci_vrf_fallback_route_group" "test" { name_alias = "name_alias_2" }, ] + vrf_fallback_routes = [ + { + annotation = "annotation_1" + description = "description_1" + name = "name_1" + name_alias = "name_alias_1" + prefix_address = "2.2.2.2/24" + }, + ] } ` @@ -290,6 +317,7 @@ resource "aci_vrf_fallback_route_group" "test" { name_alias = "name_alias_2" }, ] + vrf_fallback_routes = [] } ` @@ -300,5 +328,6 @@ resource "aci_vrf_fallback_route_group" "test" { annotations = [] tags = [] vrf_fallback_route_group_members = [] + vrf_fallback_routes = [] } ` diff --git a/internal/provider/resource_aci_vrf_fallback_route_test.go b/internal/provider/resource_aci_vrf_fallback_route_test.go new file mode 100644 index 000000000..86abe798e --- /dev/null +++ b/internal/provider/resource_aci_vrf_fallback_route_test.go @@ -0,0 +1,248 @@ +// Code generated by "gen/generator.go"; DO NOT EDIT. +// In order to regenerate this file execute `go generate` from the repository root. +// More details can be found in the [README](https://github.com/CiscoDevNet/terraform-provider-aci/blob/master/README.md). + +package provider + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccResourceFvFBRouteWithFvFBRGroup(t *testing.T) { + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create with minimum config and verify default APIC values + { + Config: testConfigFvFBRouteMinDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "description", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name_alias", ""), + ), + }, + // Update with all config and verify default APIC values + { + Config: testConfigFvFBRouteAllDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotation", "annotation"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "description", "description"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name", "name"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name_alias", "name_alias"), + ), + }, + // Update with minimum config and verify config is unchanged + { + Config: testConfigFvFBRouteMinDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + ), + }, + // Update with empty strings config or default value + { + Config: testConfigFvFBRouteResetDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "description", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name_alias", ""), + ), + }, + // Import testing + { + ResourceName: "aci_vrf_fallback_route.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "description", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name_alias", ""), + ), + }, + // Update with children + { + Config: testConfigFvFBRouteChildrenDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "description", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.1.value", "value_2"), + ), + }, + // Import testing with children + { + ResourceName: "aci_vrf_fallback_route.test", + ImportState: true, + ImportStateVerify: true, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "prefix_address", "2.2.2.3/24"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotation", "orchestrator:terraform"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "description", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "name_alias", ""), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.1.value", "value_2"), + ), + }, + // Update with children removed from config + { + Config: testConfigFvFBRouteChildrenRemoveFromConfigDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.#", "2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.key", "key_0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.value", "value_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.1.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.1.value", "value_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.#", "2"), + ), + }, + // Update with children first child removed + { + Config: testConfigFvFBRouteChildrenRemoveOneDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.#", "1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.key", "key_1"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.0.value", "value_2"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.#", "1"), + ), + }, + // Update with all children removed + { + Config: testConfigFvFBRouteChildrenRemoveAllDependencyWithFvFBRGroup, + ExpectNonEmptyPlan: false, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "annotations.#", "0"), + resource.TestCheckResourceAttr("aci_vrf_fallback_route.test", "tags.#", "0"), + ), + }, + }, + }) +} + +const testConfigFvFBRouteMinDependencyWithFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +resource "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" +} +` + +const testConfigFvFBRouteAllDependencyWithFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +resource "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" + annotation = "annotation" + description = "description" + name = "name" + name_alias = "name_alias" +} +` + +const testConfigFvFBRouteResetDependencyWithFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +resource "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" + annotation = "orchestrator:terraform" + description = "" + name = "" + name_alias = "" +} +` +const testConfigFvFBRouteChildrenDependencyWithFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +resource "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" + annotations = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_0" + value = "value_1" + }, + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigFvFBRouteChildrenRemoveFromConfigDependencyWithFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +resource "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" +} +` + +const testConfigFvFBRouteChildrenRemoveOneDependencyWithFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +resource "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" + annotations = [ + { + key = "key_1" + value = "value_2" + }, + ] + tags = [ + { + key = "key_1" + value = "value_2" + }, + ] +} +` + +const testConfigFvFBRouteChildrenRemoveAllDependencyWithFvFBRGroup = testConfigFvFBRGroupMinDependencyWithFvCtx + ` +resource "aci_vrf_fallback_route" "test" { + parent_dn = aci_vrf_fallback_route_group.test.id + prefix_address = "2.2.2.3/24" + annotations = [] + tags = [] +} +` diff --git a/main.go b/main.go index 6240b8d15..70651ffad 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,9 @@ import ( // Run the resource and datasource generation tool. //go:generate go run gen/generator.go +// Format code and cleanup imports +//go:generate go run golang.org/x/tools/cmd/goimports -w internal/provider/ + // If you do not have terraform installed, you can remove the formatting command, but its suggested to // ensure the documentation is formatted properly. //go:generate terraform fmt -recursive ./examples/