Skip to content

Commit de12af3

Browse files
committed
Initial commit
1 parent 180b15b commit de12af3

32 files changed

+1299
-113
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
## 2.0.0-beta2 (Unreleased)
22

3+
- (Fix) Improved HA Pair and Clustering implementations
34
- (Fix) Update minimum FMC version for `file_type` and `file_category` data sources
45
- (Fix) Align fields in ipv4/ipv6/vrf_ipv4/vrf_ipv6 static_route resources
56
- (Enhancement) Add `type` field to multiple resources
7+
- (Enhancement) Add `fmc_device_ha_pair_physical_interface_mac_address` resource and data source
68

79
## 2.0.0-beta1
810

docs/data-sources/device_cluster.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ data "fmc_device_cluster" "example" {
3838
- `control_node_interface_type` (String) Cluster control link interface Type.
3939
- `control_node_priority` (Number) Priority of cluster controle node.
4040
- `control_node_vni_prefix` (String) Cluster Control VXLAN Network Identifier (VNI) Network
41-
- `data_devices` (Attributes List) List of data nodes where hardware needs to match the control node hardware. (see [below for nested schema](#nestedatt--data_devices))
41+
- `data_devices` (Attributes Set) List of data nodes where hardware needs to match the control node hardware. (see [below for nested schema](#nestedatt--data_devices))
4242
- `type` (String) Type of the resource; This is always `DeviceCluster`.
4343

4444
<a id="nestedatt--data_devices"></a>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "fmc_device_ha_pair_physical_interface_mac_address Data Source - terraform-provider-fmc"
4+
subcategory: "Devices"
5+
description: |-
6+
This data source reads the Device HA Pair Physical Interface MAC Address.
7+
---
8+
9+
# fmc_device_ha_pair_physical_interface_mac_address (Data Source)
10+
11+
This data source reads the Device HA Pair Physical Interface MAC Address.
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "fmc_device_ha_pair_physical_interface_mac_address" "example" {
17+
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
18+
device_id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
19+
}
20+
```
21+
22+
<!-- schema generated by tfplugindocs -->
23+
## Schema
24+
25+
### Required
26+
27+
- `device_id` (String) Id of the parent HA Pair device.
28+
29+
### Optional
30+
31+
- `domain` (String) Name of the FMC domain
32+
- `id` (String) Id of the object
33+
- `interface_name` (String) Interface physical name.
34+
35+
### Read-Only
36+
37+
- `active_mac_address` (String) MAC address of the active interface.
38+
- `interface_id` (String) Id of the interface.
39+
- `standby_mac_address` (String) MAC address of the standby interface.
40+
- `type` (String) Type of the resource; This is always `FailoverInterfaceMacAddressConfig`.

docs/guides/changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ description: |-
99

1010
## 2.0.0-beta2 (Unreleased)
1111

12+
- (Fix) Improved HA Pair and Clustering implementations
1213
- (Fix) Update minimum FMC version for `file_type` and `file_category` data sources
1314
- (Fix) Align fields in ipv4/ipv6/vrf_ipv4/vrf_ipv6 static_route resources
1415
- (Enhancement) Add `type` field to multiple resources
16+
- (Enhancement) Add `fmc_device_ha_pair_physical_interface_mac_address` resource and data source
1517

1618
## 2.0.0-beta1
1719

docs/resources/device_cluster.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
page_title: "fmc_device_cluster Resource - terraform-provider-fmc"
44
subcategory: "Devices"
55
description: |-
6-
This device manages FTD Device Cluster configuration. This is resource may be re-designed in future releases.
6+
This device manages FTD Device Cluster configuration.
7+
Configuration of the Cluster is taken from the control node. Nevertheless, please make sure that the Terraform configuration of all control and data nodes is consistent.
78
---
89

910
# fmc_device_cluster (Resource)
1011

11-
This device manages FTD Device Cluster configuration. This is resource may be re-designed in future releases.
12+
This device manages FTD Device Cluster configuration.
13+
Configuration of the Cluster is taken from the control node. Nevertheless, please make sure that the Terraform configuration of all control and data nodes is consistent.
1214

1315
## Example Usage
1416

@@ -48,12 +50,12 @@ resource "fmc_device_cluster" "example" {
4850
- `control_node_interface_type` (String) Cluster control link interface Type.
4951
- `control_node_priority` (Number) Priority of cluster controle node.
5052
- Range: `1`-`255`
53+
- `control_node_vni_prefix` (String) Cluster Control VXLAN Network Identifier (VNI) Network
5154
- `name` (String) Name of the FTD Cluster.
5255

5356
### Optional
5457

55-
- `control_node_vni_prefix` (String) Cluster Control VXLAN Network Identifier (VNI) Network
56-
- `data_devices` (Attributes List) List of data nodes where hardware needs to match the control node hardware. (see [below for nested schema](#nestedatt--data_devices))
58+
- `data_devices` (Attributes Set) List of data nodes where hardware needs to match the control node hardware. (see [below for nested schema](#nestedatt--data_devices))
5759
- `domain` (String) Name of the FMC domain
5860

5961
### Read-Only

docs/resources/device_ha_pair.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
page_title: "fmc_device_ha_pair Resource - terraform-provider-fmc"
44
subcategory: "Devices"
55
description: |-
6-
This device manages FTD HA Pair configuration. This is resource may be re-designed in future releases.
6+
This device manages FTD HA Pair configuration.
7+
Configuration of the HA Pair is taken from the primary device. Nevertheless, please make sure that the Terraform configuration of primary and secondary devices is consistent.
78
---
89

910
# fmc_device_ha_pair (Resource)
1011

11-
This device manages FTD HA Pair configuration. This is resource may be re-designed in future releases.
12+
This device manages FTD HA Pair configuration.
13+
Configuration of the HA Pair is taken from the primary device. Nevertheless, please make sure that the Terraform configuration of primary and secondary devices is consistent.
1214

1315
## Example Usage
1416

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "fmc_device_ha_pair_physical_interface_mac_address Resource - terraform-provider-fmc"
4+
subcategory: "Devices"
5+
description: |-
6+
This resource manages a Device HA Pair Physical Interface MAC Address.
7+
---
8+
9+
# fmc_device_ha_pair_physical_interface_mac_address (Resource)
10+
11+
This resource manages a Device HA Pair Physical Interface MAC Address.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "fmc_device_ha_pair_physical_interface_mac_address" "example" {
17+
device_id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
18+
interface_name = "GigabitEthernet0/0"
19+
interface_id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
20+
active_mac_address = "c460.15e4.0edd"
21+
standby_mac_address = "c460.15e4.0ed0"
22+
}
23+
```
24+
25+
<!-- schema generated by tfplugindocs -->
26+
## Schema
27+
28+
### Required
29+
30+
- `active_mac_address` (String) MAC address of the active interface.
31+
- `device_id` (String) Id of the parent HA Pair device.
32+
- `interface_id` (String) Id of the interface.
33+
- `interface_name` (String) Interface physical name.
34+
- `standby_mac_address` (String) MAC address of the standby interface.
35+
36+
### Optional
37+
38+
- `domain` (String) Name of the FMC domain
39+
40+
### Read-Only
41+
42+
- `id` (String) Id of the object
43+
- `type` (String) Type of the resource; This is always `FailoverInterfaceMacAddressConfig`.
44+
45+
## Import
46+
47+
Import is supported using the following syntax:
48+
49+
```shell
50+
terraform import fmc_device_ha_pair_physical_interface_mac_address.example "<device_id>,<id>"
51+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
data "fmc_device_ha_pair_physical_interface_mac_address" "example" {
2+
id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
3+
device_id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import fmc_device_ha_pair_physical_interface_mac_address.example "<device_id>,<id>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "fmc_device_ha_pair_physical_interface_mac_address" "example" {
2+
device_id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
3+
interface_name = "GigabitEthernet0/0"
4+
interface_id = "76d24097-41c4-4558-a4d0-a8c07ac08470"
5+
active_mac_address = "c460.15e4.0edd"
6+
standby_mac_address = "c460.15e4.0ed0"
7+
}

gen/definitions/device_cluster.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Device Cluster
33
rest_endpoint: /api/fmc_config/v1/domain/{DOMAIN_UUID}/deviceclusters/ftddevicecluster
44
doc_category: Devices
5-
res_description: This device manages FTD Device Cluster configuration. This is resource may be re-designed in future releases.
5+
res_description: This device manages FTD Device Cluster configuration.\nConfiguration of the Cluster is taken from the control node. Nevertheless, please make sure that the Terraform configuration of all control and data nodes is consistent.
66
test_tags: [TF_VAR_device_id, TF_VAR_device_interface_name]
77
attributes:
88
- model_name: name
@@ -36,6 +36,7 @@ attributes:
3636
type: String
3737
description: Cluster Control VXLAN Network Identifier (VNI) Network
3838
example: 10.10.3.0/27
39+
mandatory: true
3940
- model_name: cclNetwork
4041
tf_name: control_node_ccl_prefix
4142
data_path: [commonBootstrap]
@@ -84,7 +85,7 @@ attributes:
8485
example: 1
8586
description: Priority of cluster controle node.
8687
- model_name: dataDevices
87-
type: List
88+
type: Set
8889
description: List of data nodes where hardware needs to match the control node hardware.
8990
attributes:
9091
- model_name: id
@@ -94,6 +95,7 @@ attributes:
9495
mandatory: true
9596
description: Cluster Data Node device ID.
9697
example: 76d24097-41c4-4558-a4d0-a8c07ac08470
98+
id: true
9799
- model_name: cclIp
98100
tf_name: data_node_ccl_ipv4_address
99101
data_path: [clusterNodeBootstrap]

gen/definitions/device_ha_pair.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Device HA Pair
33
rest_endpoint: /api/fmc_config/v1/domain/{DOMAIN_UUID}/devicehapairs/ftddevicehapairs
44
doc_category: Devices
55
test_tags: [TF_VAR_device_id, TF_VAR_device_2_id]
6-
res_description: This device manages FTD HA Pair configuration. This is resource may be re-designed in future releases.
6+
res_description: This device manages FTD HA Pair configuration.\nConfiguration of the HA Pair is taken from the primary device. Nevertheless, please make sure that the Terraform configuration of primary and secondary devices is consistent.
77
attributes:
88
- model_name: name
99
type: String

gen/definitions/device_ha_pair_monitoring.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ attributes:
1111
description: Id of the parent HA device (fmc_device.example.id).
1212
example: 76d24097-41c4-4558-a4d0-a8c07ac08470
1313
test_value: var.device_ha_id
14+
requires_replace: true
1415
- model_name: type
1516
type: String
1617
computed: true
@@ -23,6 +24,7 @@ attributes:
2324
type: String
2425
example: "outside"
2526
data_source_query: true
27+
requires_replace: true
2628
- model_name: monitorForFailures
2729
tf_name: monitor_interface
2830
description: Monitor this interface for failures.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: Device HA Pair Physical Interface MAC Address
3+
rest_endpoint: /api/fmc_config/v1/domain/{DOMAIN_UUID}/devicehapairs/ftddevicehapairs/%v/failoverinterfacemacaddressconfigs
4+
doc_category: Devices
5+
test_tags: [TF_VAR_device_ha_id, TF_VAR_interface_name]
6+
skip_minimum_test: true
7+
attributes:
8+
- tf_name: device_id
9+
type: String
10+
reference: true
11+
description: Id of the parent HA Pair device.
12+
example: 76d24097-41c4-4558-a4d0-a8c07ac08470
13+
test_value: var.device_ha_id
14+
requires_replace: true
15+
- model_name: type
16+
type: String
17+
computed: true
18+
description: Type of the resource; This is always `FailoverInterfaceMacAddressConfig`.
19+
# General
20+
- model_name: name
21+
data_path: ["physicalInterface"]
22+
tf_name: interface_name
23+
mandatory: true
24+
description: Interface physical name.
25+
type: String
26+
example: "GigabitEthernet0/0"
27+
data_source_query: true
28+
requires_replace: true
29+
test_value: data.fmc_device_physical_interface.test.name
30+
- model_name: id
31+
data_path: ["physicalInterface"]
32+
tf_name: interface_id
33+
mandatory: true
34+
description: Id of the interface.
35+
type: String
36+
example: "76d24097-41c4-4558-a4d0-a8c07ac08470"
37+
requires_replace: true
38+
test_value: data.fmc_device_physical_interface.test.id
39+
- model_name: type
40+
data_path: ["physicalInterface"]
41+
type: String
42+
value: "PhysicalInterface"
43+
- model_name: failoverActiveMac
44+
tf_name: active_mac_address
45+
mandatory: true
46+
type: String
47+
description: MAC address of the active interface.
48+
example: c460.15e4.0edd
49+
- model_name: failoverStandbyMac
50+
tf_name: standby_mac_address
51+
mandatory: true
52+
type: String
53+
description: MAC address of the standby interface.
54+
example: c460.15e4.0ed0
55+
56+
test_prerequisites: |-
57+
data "fmc_device_physical_interface" "test" {
58+
device_id = var.device_id
59+
name = var.interface_name
60+
}
61+
62+
variable "device_ha_id" { default = null } // tests will set $TF_VAR_device_ha_id
63+
variable "interface_name" {default = null} // tests will set $TF_VAR_interface_name

internal/provider/data_source_fmc_device.go

+18-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,24 @@ func (d *DeviceDataSource) Read(ctx context.Context, req datasource.ReadRequest,
212212
return
213213
}
214214

215-
res = config.fromBodyPolicy(ctx, res, policies)
215+
// Get HA Pairs
216+
haPairs, err := d.client.Get("/api/fmc_config/v1/domain/{DOMAIN_UUID}/devicehapairs/ftddevicehapairs?expanded=true", reqMods...)
217+
if err != nil {
218+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve HA Pairs (GET), got error: %s, %s", err, haPairs.String()))
219+
return
220+
}
221+
222+
// Get Clusters
223+
clusters, err := d.client.Get("/api/fmc_config/v1/domain/{DOMAIN_UUID}/deviceclusters/ftddevicecluster?expanded=true", reqMods...)
224+
if err != nil {
225+
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve Clusters (GET), got error: %s, %s", err, haPairs.String()))
226+
return
227+
}
228+
229+
// Check if device is member of either HAPair or Cluster
230+
haMembershipStatus := config.checkHaMembership(ctx, haPairs, clusters)
231+
232+
res = config.fromBodyPolicy(ctx, res, policies, haMembershipStatus)
216233
config.fromBody(ctx, res)
217234

218235
tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString()))

internal/provider/data_source_fmc_device_cluster.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (d *DeviceClusterDataSource) Schema(ctx context.Context, req datasource.Sch
116116
MarkdownDescription: "Priority of cluster controle node.",
117117
Computed: true,
118118
},
119-
"data_devices": schema.ListNestedAttribute{
119+
"data_devices": schema.SetNestedAttribute{
120120
MarkdownDescription: "List of data nodes where hardware needs to match the control node hardware.",
121121
Computed: true,
122122
NestedObject: schema.NestedAttributeObject{

0 commit comments

Comments
 (0)