From a7b31ac40d938720c4a90125c942cfc4352735fc Mon Sep 17 00:00:00 2001 From: Jason Berlinsky Date: Sun, 21 Jun 2015 01:40:09 -0400 Subject: [PATCH 1/2] Normalize certificate chains as well as certificate bodies when creating AWS IAM SSL certificates --- builtin/providers/aws/resource_aws_iam_server_certificate.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_iam_server_certificate.go b/builtin/providers/aws/resource_aws_iam_server_certificate.go index 5b5fde9c3..9d5d28b4a 100644 --- a/builtin/providers/aws/resource_aws_iam_server_certificate.go +++ b/builtin/providers/aws/resource_aws_iam_server_certificate.go @@ -30,6 +30,7 @@ func resourceAwsIAMServerCertificate() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, + StateFunc: normalizeCert, }, "path": &schema.Schema{ @@ -106,7 +107,7 @@ func resourceAwsIAMServerCertificateRead(d *schema.ResourceData, meta interface{ // these values should always be present, and have a default if not set in // configuration, and so safe to reference with nil checks d.Set("certificate_body", normalizeCert(resp.ServerCertificate.CertificateBody)) - d.Set("certificate_chain", resp.ServerCertificate.CertificateChain) + d.Set("certificate_chain", normalizeCert(resp.ServerCertificate.CertificateChain)) d.Set("path", resp.ServerCertificate.ServerCertificateMetadata.Path) d.Set("arn", resp.ServerCertificate.ServerCertificateMetadata.ARN) From 06e2336467860b522a12b79fdc92406f8cd8b38c Mon Sep 17 00:00:00 2001 From: Jason Berlinsky Date: Sun, 21 Jun 2015 01:40:29 -0400 Subject: [PATCH 2/2] Replace AWS IAM test SSL certificate with self-signed cert, including CA chain --- ...esource_aws_iam_server_certificate_test.go | 151 +++++++++--------- 1 file changed, 74 insertions(+), 77 deletions(-) diff --git a/builtin/providers/aws/resource_aws_iam_server_certificate_test.go b/builtin/providers/aws/resource_aws_iam_server_certificate_test.go index aff97f998..3165416fc 100644 --- a/builtin/providers/aws/resource_aws_iam_server_certificate_test.go +++ b/builtin/providers/aws/resource_aws_iam_server_certificate_test.go @@ -99,32 +99,23 @@ func testAccCheckIAMServerCertificateDestroy(s *terraform.State) error { var certBody = fmt.Sprintf(` -----BEGIN CERTIFICATE----- -MIIExDCCA6ygAwIBAgIJALX7Jt7ddT3eMA0GCSqGSIb3DQEBBQUAMIGcMQswCQYD -VQQGEwJVUzERMA8GA1UECBMITWlzc291cmkxETAPBgNVBAcTCENvbHVtYmlhMRIw -EAYDVQQKEwlIYXNoaUNvcnAxEjAQBgNVBAsTCVRlcnJhZm9ybTEbMBkGA1UEAxMS -d3d3Lm5vdGV4YW1wbGUuY29tMSIwIAYJKoZIhvcNAQkBFhNjbGludEBoYXNoaWNv -cnAuY29tMB4XDTE1MDUyNjE0MzA1MloXDTE4MDUyNTE0MzA1MlowgZwxCzAJBgNV -BAYTAlVTMREwDwYDVQQIEwhNaXNzb3VyaTERMA8GA1UEBxMIQ29sdW1iaWExEjAQ -BgNVBAoTCUhhc2hpQ29ycDESMBAGA1UECxMJVGVycmFmb3JtMRswGQYDVQQDExJ3 -d3cubm90ZXhhbXBsZS5jb20xIjAgBgkqhkiG9w0BCQEWE2NsaW50QGhhc2hpY29y -cC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCownyOIKXBbYxh -PynVAw30eaJj2OmilFJagwGeFHMT0rErCodY8lAQsPz6gj83NC9D4MzDt1H+GmoR -MSDphJEUxxTxvaNWTTN5sZ9WvE+sbw5YkkTXc4DmVsVMoa3urQO20f0tcHXyULj0 -sXbtG+q/QhKxqeFjYON46Z6l7x32d/cj4mIcXwLpIf+W2wpvXCKAc8851skJ+O9W -UW0/h/ivwwkKfzGfiObL16IUaq+fxwnkYt3fUI2Z4rSKAULMEcquzfKr3JR6wkeI -J66ZSb6fMNlCPGPcINDhzwSgGRpqRqeuRl4Z9m2fZaaYVltHqjwDH1tKr+3qXFnv -nZmq7pzJAgMBAAGjggEFMIIBATAdBgNVHQ4EFgQUO8bEvPq+V/rtnlhTxQDusR7o -n6QwgdEGA1UdIwSByTCBxoA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DQEJARYYamFzb25AYmFyZWZvb3Rjb2Rl +cnMuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD2AVGKRIx+EFM0kkg7 +6GoJv9uy0biEDHB4phQBqnDIf8J8/gq9eVvQrR5jJC9Uz4zp5wG/oLZlGuF92/jD +bI/yS+DOAjrh30vN79Au74jGN2Cw8fIak40iDUwjZaczK2Gkna54XIO9pqMcbQ6Q +mLUkQXsqlJ7Q4X2kL3b9iMsXcQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQCDGNvU +eioQMVPNlmmxW3+Rwo0Kl+/HtUOmqUDKUDvJnelxulBr7O8w75N/Z7h7+aBJCUkt +tz+DwATZswXtsal6TuzHHpAhpFql82jQZVE8OYkrX84XKRQpm8ZnbyZObMdXTJWk +ArC/rGVIWsvhlbgGM8zu7a3zbeuAESZ8Bn4ZbJxnoaRK8p36/alvzAwkgzSf3oUX +HtU4LrdunevBs6/CbKCWrxYcvNCy8EcmHitqCfQL5nxCCXpgf/Mw1vmIPTwbPSJq +oUkh5yjGRKzhh7QbG1TlFX6zUp4vb+UJn5+g4edHrqivRSjIqYrC45ygVMOABn21 +hpMXOlZL+YXfR4Kp -----END CERTIFICATE-----`) var testAccIAMServerCertConfig = fmt.Sprintf(` @@ -132,62 +123,68 @@ resource "aws_iam_server_certificate" "test_cert" { name = "terraform-test-cert-%d" certificate_body = <