Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_api_management: make certificate_password optional #11139

Merged
merged 2 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func resourceApiManagementService() *schema.Resource {

"certificate_password": {
Type: schema.TypeString,
Required: true,
Optional: true,
Sensitive: true,
},

Expand Down Expand Up @@ -1111,13 +1111,15 @@ func expandAzureRmApiManagementCertificates(d *schema.ResourceData) *[]apimanage
config := v.(map[string]interface{})

certBase64 := config["encoded_certificate"].(string)
certificatePassword := config["certificate_password"].(string)
storeName := apimanagement.StoreName(config["store_name"].(string))

cert := apimanagement.CertificateConfiguration{
EncodedCertificate: utils.String(certBase64),
CertificatePassword: utils.String(certificatePassword),
StoreName: storeName,
EncodedCertificate: utils.String(certBase64),
StoreName: storeName,
}

if certPassword := config["certificate_password"]; certPassword != nil {
cert.CertificatePassword = utils.String(certPassword.(string))
}

results = append(results, cert)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,16 @@ resource "azurerm_api_management" "test" {
store_name = "Root"
}
certificate {
encoded_certificate = filebase64("testdata/api_management_api_test.cer")
store_name = "Root"
}
certificate {
encoded_certificate = filebase64("testdata/api_management_api_test.cer")
store_name = "CertificateAuthority"
}
protocols {
enable_http2 = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICsjCCAZoCCQCMdt7DvygPtDANBgkqhkiG9w0BAQsFADAbMRkwFwYDVQQDDBBh
cGkudGVycmFmb3JtLmlvMB4XDTE4MDcwNTEwMzMzMFoXDTI4MDcwMjEwMzMzMFow
GzEZMBcGA1UEAwwQYXBpLnRlcnJhZm9ybS5pbzCCASIwDQYJKoZIhvcNAQEBBQAD
ggEPADCCAQoCggEBAKQW332Ol28CsidAheD1aL9Ul8JWnKLdaVxKZ3ssl5CXjPDO
mM7IXk0SgbQnUC8lIlPFZiDGbQ1sB6OTMun6ZZ4ipLp80dtl0roCLtCnDQOBGzCN
ArCYAoXRurjkXEY7tpD0wwtU72+37h3HQ4g0VS6VItJCqJ9QADV+HO2ZWuZTez70
MhoL6OLfZP7HGYdJDKgfEVNF5XlbVzNAGkDIJFdhjNxyGGu5Nfsm1pfQhAyunkk7
JVamjUg5IojRdo63IS9wwzMOdeGSAbBcsJfYeCfVg2kupR8q0TmZ+x93RmmOlbSi
66kEYxRzZ9YCQeHJmn1YfJ92BpCUiy9A6Z1iaKUCAwEAATANBgkqhkiG9w0BAQsF
AAOCAQEAJ7JhlecP7J48wI2QHTMbAMkkWBv/iWq1/QIF4ugH3Zb5PorOv+NfhQ0L
lWiw/SzN8Ae95vUixAGYHMSa28oumM5K1OsqKEkVIo1AoBH8nBz+VcTpRD/mHXot
AHPAZt9j5LqeHX+enR6RbINAf3jn+YU3MdVe0MsADdFASVDfjmQP2R7o9aJb/QqO
g3bZBWsiBDEISfyaH2+pgUM7wtwEoFWmEMlgjLK1MRBs1cDZXqnHaCd/rs+NmWV9
naEu7x5fyQOk4HozkpweR+Jx1sBlTRsa49/qSHt/6ULKfO01/cTs4iF71ykXPbh3
Kj9cI2uo9aYtXkxkhKrGyUpA7FJqWw==
-----END CERTIFICATE-----
5 changes: 2 additions & 3 deletions website/docs/r/api_management.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ A `additional_location` block supports the following:

A `certificate` block supports the following:

* `encoded_certificate` - (Required) The Base64 Encoded PFX Certificate.

* `certificate_password` - (Required) The password for the certificate.
* `encoded_certificate` - (Required) The Base64 Encoded PFX or Base64 Encoded X.509 Certificate.

* `store_name` - (Required) The name of the Certificate Store where this certificate should be stored. Possible values are `CertificateAuthority` and `Root`.

* `certificate_password` - (Optional) The password for the certificate.

---

Expand Down