@@ -94,6 +94,26 @@ func TestAccExpressRoutePort_userAssignedIdentity(t *testing.T) {
9494 Config : r .userAssignedIdentity (data ),
9595 Check : acceptance .ComposeTestCheckFunc (
9696 check .That (data .ResourceName ).ExistsInAzure (r ),
97+ check .That (data .ResourceName ).Key ("identity.0.type" ).HasValue ("UserAssigned" ),
98+ check .That (data .ResourceName ).Key ("identity.0.identity_ids.#" ).HasValue ("1" ),
99+ ),
100+ },
101+ {
102+ Config : r .userAssignedIdentityWithTags (data , "tag1" ),
103+ Check : acceptance .ComposeTestCheckFunc (
104+ check .That (data .ResourceName ).ExistsInAzure (r ),
105+ check .That (data .ResourceName ).Key ("identity.0.type" ).HasValue ("UserAssigned" ),
106+ check .That (data .ResourceName ).Key ("identity.0.identity_ids.#" ).HasValue ("1" ),
107+ check .That (data .ResourceName ).Key ("tags.environment" ).HasValue ("tag1" ),
108+ ),
109+ },
110+ {
111+ Config : r .userAssignedIdentityWithTags (data , "tag2" ),
112+ Check : acceptance .ComposeTestCheckFunc (
113+ check .That (data .ResourceName ).ExistsInAzure (r ),
114+ check .That (data .ResourceName ).Key ("identity.0.type" ).HasValue ("UserAssigned" ),
115+ check .That (data .ResourceName ).Key ("identity.0.identity_ids.#" ).HasValue ("1" ),
116+ check .That (data .ResourceName ).Key ("tags.environment" ).HasValue ("tag2" ),
97117 ),
98118 },
99119 data .ImportStep (),
@@ -115,6 +135,31 @@ func TestAccExpressRoutePort_linkCipher(t *testing.T) {
115135 })
116136}
117137
138+ func TestAccExpressRoutePort_identityRemoval (t * testing.T ) {
139+ data := acceptance .BuildTestData (t , "azurerm_express_route_port" , "test" )
140+ r := ExpressRoutePortResource {}
141+
142+ data .ResourceTest (t , r , []acceptance.TestStep {
143+ {
144+ Config : r .linkCipher (data ),
145+ Check : acceptance .ComposeTestCheckFunc (
146+ check .That (data .ResourceName ).ExistsInAzure (r ),
147+ check .That (data .ResourceName ).Key ("identity.0.type" ).HasValue ("UserAssigned" ),
148+ check .That (data .ResourceName ).Key ("identity.0.identity_ids.#" ).HasValue ("1" ),
149+ check .That (data .ResourceName ).Key ("link1.0.macsec_cipher" ).HasValue ("GcmAesXpn256" ),
150+ ),
151+ },
152+ {
153+ Config : r .basic (data ),
154+ Check : acceptance .ComposeTestCheckFunc (
155+ check .That (data .ResourceName ).ExistsInAzure (r ),
156+ check .That (data .ResourceName ).Key ("identity.#" ).HasValue ("0" ),
157+ ),
158+ },
159+ data .ImportStep (),
160+ })
161+ }
162+
118163func (r ExpressRoutePortResource ) Exists (ctx context.Context , clients * clients.Client , state * pluginsdk.InstanceState ) (* bool , error ) {
119164 client := clients .Network .ExpressRoutePorts
120165
@@ -137,18 +182,18 @@ func (r ExpressRoutePortResource) basic(data acceptance.TestData) string {
137182%s
138183
139184resource "azurerm_express_route_port" "test" {
140- name = "acctestERP-%d"
185+ name = "acctestERP-%[2] d"
141186 resource_group_name = azurerm_resource_group.test.name
142187 location = azurerm_resource_group.test.location
143- peering_location = "Equinix-London-LDS "
188+ peering_location = "Airtel-Chennai2-CLS "
144189 bandwidth_in_gbps = 10
145190 encapsulation = "Dot1Q"
146191 billing_type = "MeteredData"
147192 tags = {
148193 ENV = "Test"
149194 }
150195}
151- ` , template , data .RandomInteger )
196+ ` , template , data .RandomIntOfLength ( 8 ) )
152197}
153198
154199func (r ExpressRoutePortResource ) adminState (data acceptance.TestData ) string {
@@ -201,7 +246,7 @@ resource "azurerm_express_route_port" "test" {
201246 name = "acctestERP-%[2]d"
202247 resource_group_name = azurerm_resource_group.test.name
203248 location = azurerm_resource_group.test.location
204- peering_location = "Area51-ERDirect "
249+ peering_location = "Airtel-Chennai2-CLS "
205250 bandwidth_in_gbps = 10
206251 encapsulation = "Dot1Q"
207252 identity {
@@ -276,7 +321,7 @@ resource "azurerm_express_route_port" "test" {
276321 identity_ids = [azurerm_user_assigned_identity.test.id]
277322 }
278323 link1 {
279- macsec_cipher = "GcmAes256 "
324+ macsec_cipher = "GcmAesXpn256 "
280325 macsec_ckn_keyvault_secret_id = azurerm_key_vault_secret.ckn.id
281326 macsec_cak_keyvault_secret_id = azurerm_key_vault_secret.cak.id
282327 macsec_sci_enabled = true
@@ -290,6 +335,45 @@ resource "azurerm_express_route_port" "test" {
290335` , template , data .RandomIntOfLength (8 ))
291336}
292337
338+ func (r ExpressRoutePortResource ) userAssignedIdentityWithTags (data acceptance.TestData , tagValue string ) string {
339+ template := r .template (data )
340+ return fmt .Sprintf (`
341+ %s
342+
343+ resource "azurerm_user_assigned_identity" "test" {
344+ location = azurerm_resource_group.test.location
345+ name = "acctestUAI-%[2]d"
346+ resource_group_name = azurerm_resource_group.test.name
347+ }
348+
349+ resource "azurerm_express_route_port" "test" {
350+ name = "acctestERP-%[2]d"
351+ resource_group_name = azurerm_resource_group.test.name
352+ location = azurerm_resource_group.test.location
353+ peering_location = "Airtel-Chennai2-CLS"
354+ bandwidth_in_gbps = 10
355+ encapsulation = "Dot1Q"
356+
357+ identity {
358+ type = "UserAssigned"
359+ identity_ids = [azurerm_user_assigned_identity.test.id]
360+ }
361+
362+ link1 {
363+ admin_enabled = false
364+ }
365+
366+ link2 {
367+ admin_enabled = false
368+ }
369+
370+ tags = {
371+ environment = "%[3]s"
372+ }
373+ }
374+ ` , template , data .RandomIntOfLength (8 ), tagValue )
375+ }
376+
293377func (r ExpressRoutePortResource ) template (data acceptance.TestData ) string {
294378 return fmt .Sprintf (`
295379provider "azurerm" {
0 commit comments