feat(vpn): add BGP filter resources and gateway/connection SDK updates - #1720
feat(vpn): add BGP filter resources and gateway/connection SDK updates#1720steffenkoenig wants to merge 5 commits into
Conversation
Reflects upcoming stackit-sdk-go vpn changes (stackitcloud/stackit-sdk-go#9324, pinned by commit since the SDK PR isn't tagged/released yet): - New stackit_vpn_bgp_filter and stackit_vpn_bgp_filter_rule resources and data sources, supporting the new gateway-scoped BGP route filtering API. - stackit_vpn_gateway gains an optional network_config block (predefined_network_prefix, routing_table_id). - stackit_vpn_connection's tunnel bgp block gains inbound_filter_id, linking a tunnel's BGP session to a stackit_vpn_bgp_filter, with tri-state set/clear/leave-untouched handling on update. - integrity_algorithms now accepts sha2_512 instead of sha1 (SDK enum change, no code change needed since values are derived dynamically). go.mod is pinned to the SDK PR's commit as a pseudo-version with a TODO(vpn-sdk-pin) marker to re-pin once the SDK PR merges and is tagged.
The vpn changes (BGP filter, network_config, inbound_filter_id) landed on stackit-sdk-go main and are now tagged as services/vpn/v0.15.0. Re-pin from the temporary commit pseudo-version to this release; no code changes needed since the tag points at the same content already implemented against.
The released stackit-sdk-go v0.15.0 kept `sha1` in PhaseIntegrityAlgorithmsInner alongside the new `sha2_512`, unlike the draft PR commit this was originally implemented against (which dropped `sha1`). No Go code change is needed since the provider already derives its integrity_algorithms validator values dynamically from the SDK enum, but the previously generated docs were stale and needed a refresh.
sha1 remains supported by the API but is deprecated. Add a schema description note and a plan-time diagnostic warning (on create/update) when a stackit_vpn_connection tunnel's phase1/phase2 integrity_algorithms includes sha1, pointing users toward sha2_256/sha2_384/sha2_512 instead.
|
Hi @steffenkoenig, |
|
This PR was marked as stale after 7 days of inactivity and will be closed after another 7 days of further inactivity. If this PR should be kept open, just add a comment, remove the stale label or push new commits to it. |
|
It would be really great to have this functionality in one of the next releases <3 |
| Description: schemaDescriptions["network_config"], | ||
| Optional: true, | ||
| Attributes: map[string]schema.Attribute{ | ||
| "predefined_network_prefix": schema.ListAttribute{ |
There was a problem hiding this comment.
It seems that predefined_network_prefix must be a string, not an array. The VPN Gateway API blocks any payload with predefinedNetworkPrefix set as an array with error 500. See stackitcloud/stackit-api-specifications#69
We will have to wait for a new release of the Go SDK to fix this.
There was a problem hiding this comment.
Thanks for catching this. One detail is worth pinning down before a new SDK release is planned around it.
This comment reports HTTP 500, while stackitcloud/stackit-api-specifications#69 reports HTTP 400 for the array payload and includes a response body with "status": "BAD_REQUEST".
The two point at different fixes:
400means the server rejects the array at validation. The contract is then a single string, and only the spec needs correcting.500means the array is not handled at all. That is a server-side defect on top of the spec fix, and correcting the spec alone would not close it.
I asked the same question in the issue. For context I also added this there: predefinedNetworkPrefix carries no type at all in the spec, only items plus a scalar example. It is the only such property in the file, which is why both the Go and the Python generator produce a list.
There was a problem hiding this comment.
One note on how far this blocker actually reaches, since it does not affect all of network_config.
It only hits predefined_network_prefix. A block that sets just routing_table_id never puts an array on the wire:
toNetworkConfigPayloadguards the prefix withtfutils.IsUndefined, which isIsUnknown() || IsNull(). An omittedpredefined_network_prefixis null, soNetworkConfig.PredefinedNetworkPrefixstays nil.- The SDK's
NetworkConfig.ToMapwritespredefinedNetworkPrefixonly whenIsNilreturns false, and it returns true for a nil slice. The key is therefore absent from the request body.
So this configuration is untouched by the spec bug:
network_config = {
routing_table_id = stackit_routing_table.example.routing_table_id
}That covers serialization only. Whether the API accepts a custom routing table is untested in this PR: TestAccVpnGatewayResourceMax asserts TestCheckResourceAttrSet on network_config.routing_table_id, which the default table assigned by the API already satisfies, and gateway-max.tf sets only the prefix. A case that passes an existing routing table id would close that gap.
Worth mentioning because it means the routing table part of this PR could be usable ahead of the spec fix.
| OverrideAdvertisedRoutes types.List `tfsdk:"override_advertised_routes"` | ||
| } | ||
|
|
||
| type NetworkConfigModel struct { |
There was a problem hiding this comment.
I just tested this branch in our local setup and it throws an error:
│ Error: Value Conversion Error
│
│ with module.stackit.module.mack_one.module.connect.module.hub.module.dev.module.hub_dev_vpn.stackit_vpn_gateway.this,
│ on modules/stackit-vpn-gateway/main.tf line 15, in resource "stackit_vpn_gateway" "this":
│ 15: network_config = var.network_config
│
│ An unexpected error was encountered trying to build a value. This is always an error in the provider. Please report the following to the provider developer:
│
│ Received unknown value, however the target type cannot handle unknown values. Use the corresponding `types` package type or a custom type that handles unknown values.
│
│ Path: network_config
│ Target Type: *gateway.NetworkConfigModel
│ Suggested Type: basetypes.ObjectValue
We're creating the VPN Gateway in a reusable module with network_config set as a variable.
The resource in our Terraform module:
resource "stackit_vpn_gateway" "this" {
project_id = var.project_id
display_name = "${data.stackit_resourcemanager_project.this.name}-vpn-gw"
plan_id = var.plan_id
routing_type = var.routing_type
availability_zones = {
tunnel1 = var.availability_zones.tunnel1
tunnel2 = var.availability_zones.tunnel2
}
network_config = var.network_config
}
and the corresponding variable:
variable "network_config" {
description = "Network configuration for the VPN gateway. Leave null to have the network prefix assigned automatically."
type = object({
predefined_network_prefix = optional(list(string))
routing_table_id = optional(string)
})
default = null
}
I think using basetypes is safer here for optional values, see also Europa-Park-DD@572dc0c#diff-238f9f2b61941094893b6851aab64dac70d5582b03fbd2c22ba6f0d34dc6fd0fR22-R64 on how we set this up.
Description
Reflects vpn changes:
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)