Skip to content

Commit

Permalink
fixes #6057
Browse files Browse the repository at this point in the history
* Fix issue with frontdoor custom https configuration not being updated

* Clean up to fix lint warnings

* Fix merge issues

* Add synthetic resource id to custom_https_configuration

* Clean up custom_https_configuration + methods signaures

* Fix validation. Fix read custom_https_configuration

* Apply suggestions from code review

Co-authored-by: Tim Jacomb <tim.jacomb@hmcts.net>

* Add docs. Move common code to helper. Move custom_https_configuration code to resource_arm_frontdoor_custom_https_configuration_resource file.

* Move docs to separate file

* Add clarifications + fixes to docs.

* Fix file name

* Fix endpoint delete conflict

* Add acceptance tests

* Apply suggestions from code review

Co-authored-by: WS <20408400+WodansSon@users.noreply.github.com>

* Fix merge issues + add frontend_id to custom_https_configuration resource

* Fix timeout (revert to: a08a2d8#diff-f40eb1b0d4646b0fed0eab1d3837c42d)

* Replace front_door and frontend_endpoint names with frontend_endpoint_id

Co-authored-by: Tim Jacomb <tim.jacomb@hmcts.net>
Co-authored-by: WS <20408400+WodansSon@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 22, 2020
1 parent 2f65814 commit e6a276c
Show file tree
Hide file tree
Showing 9 changed files with 835 additions and 215 deletions.
94 changes: 94 additions & 0 deletions azurerm/helpers/azure/frontdoor_custom_https_configuration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package azure

import (
"fmt"

"github.com/Azure/azure-sdk-for-go/services/frontdoor/mgmt/2020-01-01/frontdoor"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

func SchemaFrontdoorCustomHttpsConfiguration() map[string]*schema.Schema {
return map[string]*schema.Schema{
"certificate_source": {
Type: schema.TypeString,
Optional: true,
Default: string(frontdoor.CertificateSourceFrontDoor),
ValidateFunc: validation.StringInSlice([]string{
string(frontdoor.CertificateSourceAzureKeyVault),
string(frontdoor.CertificateSourceFrontDoor),
}, false),
},
"minimum_tls_version": {
Type: schema.TypeString,
Computed: true,
},
"provisioning_state": {
Type: schema.TypeString,
Computed: true,
},
"provisioning_substate": {
Type: schema.TypeString,
Computed: true,
},
// NOTE: None of these attributes are valid if
// certificate_source is set to FrontDoor
"azure_key_vault_certificate_secret_name": {
Type: schema.TypeString,
Optional: true,
},
"azure_key_vault_certificate_secret_version": {
Type: schema.TypeString,
Optional: true,
},
"azure_key_vault_certificate_vault_id": {
Type: schema.TypeString,
Optional: true,
},
}
}

func FlattenArmFrontDoorCustomHttpsConfiguration(input *frontdoor.FrontendEndpoint, output map[string]interface{}, resourceGroup string) error {
if input == nil {
return fmt.Errorf("cannot read Front Door Frontend Endpoint (Resource Group %q): endpoint is empty", resourceGroup)
}

customHttpsConfiguration := make([]interface{}, 0)
chc := make(map[string]interface{})

if properties := input.FrontendEndpointProperties; properties != nil {
if properties.CustomHTTPSConfiguration != nil {
customHTTPSConfiguration := properties.CustomHTTPSConfiguration
if customHTTPSConfiguration.CertificateSource == frontdoor.CertificateSourceAzureKeyVault {
if kvcsp := customHTTPSConfiguration.KeyVaultCertificateSourceParameters; kvcsp != nil {
chc["certificate_source"] = string(frontdoor.CertificateSourceAzureKeyVault)
chc["azure_key_vault_certificate_vault_id"] = *kvcsp.Vault.ID
chc["azure_key_vault_certificate_secret_name"] = *kvcsp.SecretName
chc["azure_key_vault_certificate_secret_version"] = *kvcsp.SecretVersion
}
} else {
chc["certificate_source"] = string(frontdoor.CertificateSourceFrontDoor)
}

chc["minimum_tls_version"] = string(customHTTPSConfiguration.MinimumTLSVersion)

if provisioningState := properties.CustomHTTPSProvisioningState; provisioningState != "" {
chc["provisioning_state"] = provisioningState
if provisioningState == frontdoor.CustomHTTPSProvisioningStateEnabled || provisioningState == frontdoor.CustomHTTPSProvisioningStateEnabling {
output["custom_https_provisioning_enabled"] = true

if provisioningSubstate := properties.CustomHTTPSProvisioningSubstate; provisioningSubstate != "" {
chc["provisioning_substate"] = provisioningSubstate
}
} else {
output["custom_https_provisioning_enabled"] = false
}

customHttpsConfiguration = append(customHttpsConfiguration, chc)
output["custom_https_configuration"] = customHttpsConfiguration
}
}
}

return nil
}
Loading

0 comments on commit e6a276c

Please sign in to comment.