Skip to content

Commit

Permalink
Add hub and spoke topology policy definition resource and data source
Browse files Browse the repository at this point in the history
  • Loading branch information
danischm committed Jul 15, 2023
1 parent d2fe574 commit 4ef881c
Show file tree
Hide file tree
Showing 27 changed files with 1,286 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Add `sdwan_cisco_ospf_feature_template` resource and data source
- Add `sdwan_cisco_vpn_interface_ipsec_feature_template` resource and data source
- Add `sdwan_cisco_secure_internet_gateway_feature_template` resource and data source
- Add `sdwan_hub_and_spoke_topology_policy_definition` resource and data source

## 0.2.0

Expand Down
61 changes: 61 additions & 0 deletions docs/data-sources/hub_and_spoke_topology_policy_definition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sdwan_hub_and_spoke_topology_policy_definition Data Source - terraform-provider-sdwan"
subcategory: "Centralized Policies"
description: |-
This data source can read the Hub and Spoke Topology policy definition.
---

# sdwan_hub_and_spoke_topology_policy_definition (Data Source)

This data source can read the Hub and Spoke Topology policy definition.

## Example Usage

```terraform
data "sdwan_hub_and_spoke_topology_policy_definition" "example" {
id = "f6b2c44c-693c-4763-b010-895aa3d236bd"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `id` (String) The id of the policy definition

### Read-Only

- `description` (String) The description of the policy definition
- `name` (String) The name of the policy definition
- `topologies` (Attributes List) List of topologies (see [below for nested schema](#nestedatt--topologies))
- `type` (String) The policy definition type
- `version` (Number) The version of the policy definition
- `vpn_list_id` (String) VPN list ID
- `vpn_list_version` (Number) VPN list version

<a id="nestedatt--topologies"></a>
### Nested Schema for `topologies`

Read-Only:

- `name` (String) Topology name
- `spokes` (Attributes List) List of spokes (see [below for nested schema](#nestedatt--topologies--spokes))

<a id="nestedatt--topologies--spokes"></a>
### Nested Schema for `topologies.spokes`

Read-Only:

- `hubs` (Attributes List) List of hubs (see [below for nested schema](#nestedatt--topologies--spokes--hubs))
- `site_list_id` (String) Site list ID
- `site_list_version` (Number) Site list version

<a id="nestedatt--topologies--spokes--hubs"></a>
### Nested Schema for `topologies.spokes.hubs`

Read-Only:

- `site_list_id` (String) Site list ID
- `site_list_version` (Number) Site list version
1 change: 1 addition & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description: |-
- Add `sdwan_cisco_ospf_feature_template` resource and data source
- Add `sdwan_cisco_vpn_interface_ipsec_feature_template` resource and data source
- Add `sdwan_cisco_secure_internet_gateway_feature_template` resource and data source
- Add `sdwan_hub_and_spoke_topology_policy_definition` resource and data source

## 0.2.0

Expand Down
92 changes: 92 additions & 0 deletions docs/resources/hub_and_spoke_topology_policy_definition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sdwan_hub_and_spoke_topology_policy_definition Resource - terraform-provider-sdwan"
subcategory: "Centralized Policies"
description: |-
This resource can manage a Hub and Spoke Topology policy definition.
---

# sdwan_hub_and_spoke_topology_policy_definition (Resource)

This resource can manage a Hub and Spoke Topology policy definition.

## Example Usage

```terraform
resource "sdwan_hub_and_spoke_topology_policy_definition" "example" {
name = "Example"
description = "My description"
vpn_list_id = "04fcbb0b-efbf-43d2-a04b-847d3a7b104e"
topologies = [
{
name = "Topology1"
spokes = [
{
site_list_id = "e858e1c4-6aa8-4de7-99df-c3adbf80290d"
hubs = [
{
site_list_id = "e858e1c4-6aa8-4de7-99df-c3adbf80290d"
}
]
}
]
}
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `description` (String) The description of the policy definition
- `name` (String) The name of the policy definition
- `topologies` (Attributes List) List of topologies (see [below for nested schema](#nestedatt--topologies))

### Optional

- `vpn_list_id` (String) VPN list ID
- `vpn_list_version` (Number) VPN list version

### Read-Only

- `id` (String) The id of the policy definition
- `type` (String) The policy defintion type
- `version` (Number) The version of the policy definition

<a id="nestedatt--topologies"></a>
### Nested Schema for `topologies`

Required:

- `name` (String) Topology name

Optional:

- `spokes` (Attributes List) List of spokes (see [below for nested schema](#nestedatt--topologies--spokes))

<a id="nestedatt--topologies--spokes"></a>
### Nested Schema for `topologies.spokes`

Optional:

- `hubs` (Attributes List) List of hubs (see [below for nested schema](#nestedatt--topologies--spokes--hubs))
- `site_list_id` (String) Site list ID
- `site_list_version` (Number) Site list version

<a id="nestedatt--topologies--spokes--hubs"></a>
### Nested Schema for `topologies.spokes.hubs`

Optional:

- `site_list_id` (String) Site list ID
- `site_list_version` (Number) Site list version

## Import

Import is supported using the following syntax:

```shell
terraform import sdwan_hub_and_spoke_topology_policy_definition.example "f6b2c44c-693c-4763-b010-895aa3d236bd"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "sdwan_hub_and_spoke_topology_policy_definition" "example" {
id = "f6b2c44c-693c-4763-b010-895aa3d236bd"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import sdwan_hub_and_spoke_topology_policy_definition.example "f6b2c44c-693c-4763-b010-895aa3d236bd"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "sdwan_hub_and_spoke_topology_policy_definition" "example" {
name = "Example"
description = "My description"
vpn_list_id = "04fcbb0b-efbf-43d2-a04b-847d3a7b104e"
topologies = [
{
name = "Topology1"
spokes = [
{
site_list_id = "e858e1c4-6aa8-4de7-99df-c3adbf80290d"
hubs = [
{
site_list_id = "e858e1c4-6aa8-4de7-99df-c3adbf80290d"
}
]
}
]
}
]
}
1 change: 1 addition & 0 deletions gen/definitions/policy_definitions/acl.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: ACL
type: acl
doc_category: Localized Policies
skip_templates: [model.go, resource.go]
attributes:
- model_name: type
Expand Down
1 change: 1 addition & 0 deletions gen/definitions/policy_definitions/device_acl.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Device ACL
type: deviceAccessPolicy
doc_category: Localized Policies
skip_templates: [model.go, resource.go]
attributes:
- model_name: type
Expand Down
58 changes: 58 additions & 0 deletions gen/definitions/policy_definitions/hub_and_spoke_topology.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: Hub and Spoke Topology
type: hubAndSpoke
root_element: definition
doc_category: Centralized Policies
attributes:
- model_name: vpnList
tf_name: vpn_list_id
type: String
description: VPN list ID
example: 04fcbb0b-efbf-43d2-a04b-847d3a7b104e
- tf_name: vpn_list_version
tf_only: true
type: Int64
description: VPN list version
exclude_test: true
- model_name: subDefinitions
tf_name: topologies
type: List
mandatory: true
description: List of topologies
attributes:
- model_name: name
tf_name: name
type: String
mandatory: true
description: Topology name
example: Topology1
- model_name: spokes
tf_name: spokes
type: List
description: List of spokes
attributes:
- model_name: siteList
tf_name: site_list_id
type: String
description: Site list ID
example: e858e1c4-6aa8-4de7-99df-c3adbf80290d
- tf_name: site_list_version
tf_only: true
type: Int64
description: Site list version
exclude_test: true
- model_name: hubs
tf_name: hubs
type: List
description: List of hubs
attributes:
- model_name: siteList
tf_name: site_list_id
type: String
description: Site list ID
example: e858e1c4-6aa8-4de7-99df-c3adbf80290d
- tf_name: site_list_version
tf_only: true
type: Int64
description: Site list version
exclude_test: true
1 change: 1 addition & 0 deletions gen/definitions/policy_definitions/qos_map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: QoS Map
type: qosMap
root_element: definition
doc_category: Localized Policies
skip_templates: [data_source_test.go, resource_test.go, model.go, resource.go]
attributes:
- model_name: qosSchedulers
Expand Down
1 change: 1 addition & 0 deletions gen/definitions/policy_definitions/rewrite_policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: Rewrite Rule
type: rewriteRule
root_element: definition
doc_category: Localized Policies
skip_templates: [data_source_test.go, resource_test.go, model.go, resource.go]
attributes:
- model_name: rules
Expand Down
1 change: 1 addition & 0 deletions gen/definitions/policy_definitions/route.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
name: Route
type: vedgeRoute
doc_category: Localized Policies
skip_templates: [model.go, resource.go, data_source.go]
attributes:
- model_name: type
Expand Down
6 changes: 4 additions & 2 deletions gen/doc_category.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const (
)

type YamlConfig struct {
Name string `yaml:"name"`
Name string `yaml:"name"`
DocCategory string `yaml:"doc_category"`
}

var docPaths = []string{"./docs/data-sources/", "./docs/resources/"}
Expand Down Expand Up @@ -152,8 +153,9 @@ func main() {
log.Fatalf("Error opening documentation: %v", err)
}

cat := policyDefinitionConfigs[i].DocCategory
s := string(content)
s = strings.ReplaceAll(s, `subcategory: ""`, `subcategory: "Localized Policies"`)
s = strings.ReplaceAll(s, `subcategory: ""`, `subcategory: "`+cat+`"`)

ioutil.WriteFile(filename, []byte(s), 0644)
}
Expand Down
17 changes: 17 additions & 0 deletions gen/templates/policy_definitions/data_source.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions gen/templates/policy_definitions/data_source_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4ef881c

Please sign in to comment.