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

azurerm_express_route_port - support for the billing_type property #20361

Merged
merged 2 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/services/network/express_route_port_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ func resourceArmExpressRoutePort() *pluginsdk.Resource {

"identity": commonschema.UserAssignedIdentityOptional(),

"billing_type": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
string(network.ExpressRoutePortsBillingTypeMeteredData),
string(network.ExpressRoutePortsBillingTypeUnlimitedData),
}, false),
},

"link1": expressRoutePortSchema,

"link2": expressRoutePortSchema,
Expand Down Expand Up @@ -213,6 +223,10 @@ func resourceArmExpressRoutePortCreateUpdate(d *pluginsdk.ResourceData, meta int
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
}

if v, ok := d.GetOk("billing_type"); ok {
param.ExpressRoutePortPropertiesFormat.BillingType = network.ExpressRoutePortsBillingType(v.(string))
}

// The link properties can't be specified in first creation. It will result into either error (e.g. setting `adminState`) or being ignored (e.g. setting MACSec)
// Hence, if this is a new creation we will do a create-then-update here.
if d.IsNewResource() {
Expand Down Expand Up @@ -277,6 +291,7 @@ func resourceArmExpressRoutePortRead(d *pluginsdk.ResourceData, meta interface{}
d.Set("peering_location", prop.PeeringLocation)
d.Set("bandwidth_in_gbps", prop.BandwidthInGbps)
d.Set("encapsulation", prop.Encapsulation)
d.Set("billing_type", prop.BillingType)
link1, link2, err := flattenExpressRoutePortLinks(resp.Links)
if err != nil {
return fmt.Errorf("flattening links: %v", err)
Expand Down
2 changes: 2 additions & 0 deletions internal/services/network/express_route_port_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestAccAzureRMExpressRoutePort_basic(t *testing.T) {
check.That(data.ResourceName).Key("link2.0.rack_id").Exists(),
check.That(data.ResourceName).Key("link2.0.connector_type").Exists(),
check.That(data.ResourceName).Key("ethertype").Exists(),
check.That(data.ResourceName).Key("billing_type").Exists(),
check.That(data.ResourceName).Key("guid").Exists(),
check.That(data.ResourceName).Key("mtu").Exists(),
),
Expand Down Expand Up @@ -141,6 +142,7 @@ resource "azurerm_express_route_port" "test" {
peering_location = "Airtel-Chennai2-CLS"
bandwidth_in_gbps = 10
encapsulation = "Dot1Q"
billing_type = "MeteredData"
tags = {
ENV = "Test"
}
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 @@ -70,6 +70,8 @@ A `link` block supports the following:

* `macsec_cipher` - (Optional) The MACSec cipher used for this Express Route Port Link. Possible values are `GcmAes128` and `GcmAes256`. Defaults to `GcmAes128`.

* `billing_type` - (Optional) The billing type of the Express Route Port. Possible values are `MeteredData` and `UnlimitedData`.

* `macsec_ckn_keyvault_secret_id` - (Optional) The ID of the Key Vault Secret that contains the MACSec CKN key for this Express Route Port Link.

* `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.
Expand Down