Skip to content

Commit

Permalink
azurerm_express_route_port - support for the billing_type property (
Browse files Browse the repository at this point in the history
#20361)

Co-authored-by: xuzhang3 <Zhangxu894765>
  • Loading branch information
xuzhang3 committed Feb 10, 2023
1 parent 4d2318b commit 346725e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
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

0 comments on commit 346725e

Please sign in to comment.