Skip to content

Commit

Permalink
azurerm_app_service_managed_certificate - create certificate in ser…
Browse files Browse the repository at this point in the history
…vice plan resource group (#9701)
  • Loading branch information
AdamCoulterOz authored Dec 10, 2020
1 parent 8459251 commit cf86a65
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,16 @@ func resourceArmAppServiceManagedCertificateCreateUpdate(d *schema.ResourceData,
}

name := customHostnameBindingId.Name
appServicePlanID := ""
appServicePlanIDRaw := ""
if appService.SiteProperties == nil || appService.SiteProperties.ServerFarmID == nil {
return fmt.Errorf("could not get App Service Plan ID for Custom Hostname Binding %q (resource group %q)", customHostnameBindingId.Name, customHostnameBindingId.ResourceGroup)
}
appServicePlanID = *appService.SiteProperties.ServerFarmID
appServicePlanIDRaw = *appService.SiteProperties.ServerFarmID

appServicePlanID, err := parse.AppServicePlanID(appServicePlanIDRaw)
if err != nil {
return err
}

appServiceLocation := ""
if appService.Location != nil {
Expand All @@ -124,7 +129,7 @@ func resourceArmAppServiceManagedCertificateCreateUpdate(d *schema.ResourceData,

t := d.Get("tags").(map[string]interface{})

id := parse.NewManagedCertificateID(subscriptionId, customHostnameBindingId.ResourceGroup, name)
id := parse.NewManagedCertificateID(subscriptionId, appServicePlanID.ResourceGroup, name)

if d.IsNewResource() {
existing, err := client.Get(ctx, id.ResourceGroup, id.CertificateName)
Expand All @@ -142,7 +147,7 @@ func resourceArmAppServiceManagedCertificateCreateUpdate(d *schema.ResourceData,
certificate := web.Certificate{
CertificateProperties: &web.CertificateProperties{
CanonicalName: utils.String(customHostnameBindingId.Name),
ServerFarmID: utils.String(appServicePlanID),
ServerFarmID: utils.String(appServicePlanIDRaw),
Password: new(string),
},
Location: utils.String(appServiceLocation),
Expand Down

0 comments on commit cf86a65

Please sign in to comment.