Skip to content

Commit

Permalink
Merge pull request #3444 from emilpalsson/slot-site_credential
Browse files Browse the repository at this point in the history
azurerm_app_service_slot: Add site_credential attribute export
  • Loading branch information
tombuildsstuff authored May 15, 2019
2 parents 925050d + 32f54e2 commit 5702870
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
37 changes: 37 additions & 0 deletions azurerm/resource_arm_app_service_slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,25 @@ func resourceArmAppServiceSlot() *schema.Resource {

"tags": tagsSchema(),

"site_credential": {
Type: schema.TypeList,
Computed: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"username": {
Type: schema.TypeString,
Computed: true,
},
"password": {
Type: schema.TypeString,
Computed: true,
Sensitive: true,
},
},
},
},

"default_site_hostname": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -370,6 +389,19 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err
return fmt.Errorf("Error making Read request on AzureRM App Service Slot ConnectionStrings %q/%q: %+v", appServiceName, slot, err)
}

siteCredFuture, err := client.ListPublishingCredentialsSlot(ctx, resGroup, appServiceName, slot)
if err != nil {
return err
}
err = siteCredFuture.WaitForCompletionRef(ctx, client.Client)
if err != nil {
return err
}
siteCredResp, err := siteCredFuture.Result(client)
if err != nil {
return fmt.Errorf("Error making Read request on AzureRM App Service Slot Site Credential %q/%q: %+v", appServiceName, slot, err)
}

d.Set("name", slot)
d.Set("app_service_name", appServiceName)
d.Set("resource_group_name", resGroup)
Expand Down Expand Up @@ -397,6 +429,11 @@ func resourceArmAppServiceSlotRead(d *schema.ResourceData, meta interface{}) err
return err
}

siteCred := flattenAppServiceSiteCredential(siteCredResp.UserProperties)
if err := d.Set("site_credential", siteCred); err != nil {
return err
}

identity := flattenAzureRmAppServiceMachineIdentity(resp.Identity)
if err := d.Set("identity", identity); err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions website/docs/r/app_service_slot.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ The following attributes are exported:

* `default_site_hostname` - The Default Hostname associated with the App Service Slot - such as `mysite.azurewebsites.net`

* `site_credential` - A `site_credential` block as defined below, which contains the site-level credentials used to publish to this App Service.

---

`site_credential` exports the following:

* `username` - The username which can be used to publish to this App Service
* `password` - The password associated with the username, which can be used to publish to this App Service.

## Import

App Service Slots can be imported using the `resource id`, e.g.
Expand Down

0 comments on commit 5702870

Please sign in to comment.