Skip to content

Commit

Permalink
azurerm_automation_account - support for the `private_endpoint_conn…
Browse files Browse the repository at this point in the history
…ection` property (#17934)

Co-authored-by: xuwu1 <[email protected]>
  • Loading branch information
wuxu92 and wuxu92 authored Aug 16, 2022
1 parent f859529 commit 3cb003a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/services/automation/automation_account_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ func dataSourceAutomationAccount() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Computed: true,
},
"private_endpoint_connection": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Computed: true,
},
"id": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -76,5 +92,21 @@ func dataSourceAutomationAccountRead(d *pluginsdk.ResourceData, meta interface{}
d.Set("secondary_key", iresp.Keys.Secondary)
}
d.Set("endpoint", iresp.Endpoint)
if resp.Model != nil && resp.Model.Properties != nil {
d.Set("private_endpoint_connection", flattenPrivateEndpointConnections(resp.Model.Properties.PrivateEndpointConnections))
}
return nil
}

func flattenPrivateEndpointConnections(conns *[]automationaccount.PrivateEndpointConnection) (res []interface{}) {
if conns == nil || len(*conns) == 0 {
return
}
for _, con := range *conns {
res = append(res, map[string]interface{}{
"id": con.Id,
"name": con.Name,
})
}
return res
}
20 changes: 20 additions & 0 deletions internal/services/automation/automation_account_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ func resourceAutomationAccount() *pluginsdk.Resource {
Optional: true,
Default: true,
},
"private_endpoint_connection": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Computed: true,
},
"id": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -231,6 +247,10 @@ func resourceAutomationAccountRead(d *pluginsdk.ResourceData, meta interface{})
return fmt.Errorf("setting `identity`: %+v", err)
}

if resp.Model != nil && resp.Model.Properties != nil {
d.Set("private_endpoint_connection", flattenPrivateEndpointConnections(resp.Model.Properties.PrivateEndpointConnections))
}

if resp.Model.Tags != nil {
return flattenAndSetTags(d, *resp.Model.Tags)
}
Expand Down

0 comments on commit 3cb003a

Please sign in to comment.