Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ExpressRoute direct MACsec SCI state #23625

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion internal/services/network/express_route_port_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ var expressRoutePortSchema = &pluginsdk.Schema{
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
"macsec_sci_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: false,
},
"id": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -412,13 +417,19 @@ func expandExpressRoutePortLink(idx int, input []interface{}) *network.ExpressRo
adminState = network.ExpressRouteLinkAdminStateEnabled
}

sciState := network.ExpressRouteLinkMacSecSciStateDisabled
if b["macsec_sci_enabled"].(bool) {
sciState = network.ExpressRouteLinkMacSecSciStateEnabled
}

link := network.ExpressRouteLink{
// The link name is fixed
Name: utils.String(fmt.Sprintf("link%d", idx)),
ExpressRouteLinkPropertiesFormat: &network.ExpressRouteLinkPropertiesFormat{
AdminState: adminState,
MacSecConfig: &network.ExpressRouteLinkMacSecConfig{
Cipher: network.ExpressRouteLinkMacSecCipher(b["macsec_cipher"].(string)),
Cipher: network.ExpressRouteLinkMacSecCipher(b["macsec_cipher"].(string)),
SciState: sciState,
},
},
}
Expand Down Expand Up @@ -460,6 +471,7 @@ func flattenExpressRoutePortLink(link network.ExpressRouteLink) []interface{} {
cknSecretId string
cakSecretId string
cipher string
sciState bool
)

if prop := link.ExpressRouteLinkPropertiesFormat; prop != nil {
Expand All @@ -477,6 +489,7 @@ func flattenExpressRoutePortLink(link network.ExpressRouteLink) []interface{} {
}
connectorType = string(prop.ConnectorType)
adminState = prop.AdminState == network.ExpressRouteLinkAdminStateEnabled
sciState = prop.MacSecConfig.SciState == network.ExpressRouteLinkMacSecSciStateEnabled
if cfg := prop.MacSecConfig; cfg != nil {
if cfg.CknSecretIdentifier != nil {
cknSecretId = *cfg.CknSecretIdentifier
Expand All @@ -500,6 +513,7 @@ func flattenExpressRoutePortLink(link network.ExpressRouteLink) []interface{} {
"macsec_ckn_keyvault_secret_id": cknSecretId,
"macsec_cak_keyvault_secret_id": cakSecretId,
"macsec_cipher": cipher,
"macsec_sci_enabled": sciState,
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ resource "azurerm_express_route_port" "test" {
macsec_cipher = "GcmAes256"
macsec_ckn_keyvault_secret_id = azurerm_key_vault_secret.ckn.id
macsec_cak_keyvault_secret_id = azurerm_key_vault_secret.cak.id
macsec_sci_enabled = true
}
link2 {
macsec_cipher = "GcmAes128"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/express_route_port.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ A `link` block supports the following:

* `macsec_cak_keyvault_secret_id` - (Optional) The ID of the Key Vault Secret that contains the Mac security CAK key for this Express Route Port Link.

* `macsec_sci_enabled` - (Optional) Enable Secure Channel Identifier on the Express Route Port Link.
jake-scott marked this conversation as resolved.
Show resolved Hide resolved

~> **NOTE** `macsec_ckn_keyvault_secret_id` and `macsec_cak_keyvault_secret_id` should be used together with `identity`, so that the Express Route Port instance have the right permission to access the Key Vault.

## Attributes Reference
Expand Down