github.com/pmcatominey/terraform@v0.7.0-rc2.0.20160708105029-1401a52a5cc5/website/source/docs/providers/aws/r/iam_server_certificate.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_iam_server_certificate" 4 sidebar_current: "docs-aws-resource-iam-server-certificate" 5 description: |- 6 Provides an IAM Server Certificate 7 --- 8 9 # aws\_iam\_server\_certificate 10 11 Provides an IAM Server Certificate resource to upload Server Certificates. 12 Certs uploaded to IAM can easily work with other AWS services such as: 13 14 - AWS Elastic Beanstalk 15 - Elastic Load Balancing 16 - CloudFront 17 - AWS OpsWorks 18 19 For information about server certificates in IAM, see [Managing Server 20 Certificates][2] in AWS Documentation. 21 22 ## Example Usage 23 24 **Using certs on file:** 25 26 ``` 27 resource "aws_iam_server_certificate" "test_cert" { 28 name = "some_test_cert" 29 certificate_body = "${file("self-ca-cert.pem")}" 30 private_key = "${file("test-key.pem")}" 31 } 32 ``` 33 34 **Example with cert in-line:** 35 36 ``` 37 resource "aws_iam_server_certificate" "test_cert_alt" { 38 name = "alt_test_cert" 39 certificate_body = <<EOF 40 -----BEGIN CERTIFICATE----- 41 [......] # cert contents 42 -----END CERTIFICATE----- 43 EOF 44 45 private_key = <<EOF 46 -----BEGIN RSA PRIVATE KEY----- 47 [......] # cert contents 48 -----END CERTIFICATE----- 49 EOF 50 } 51 ``` 52 53 **Use in combination with an AWS ELB resource:** 54 55 Some properties of an IAM Server Certificates cannot be updated while they are 56 in use. In order for Terraform to effectively manage a Certificate in this situation, it is 57 recommended you utilize the `name_prefix` attribute and enable the 58 `create_before_destroy` [lifecycle block][lifecycle]. This will allow Terraform 59 to create a new, updated `aws_iam_server_certificate` resource and replace it in 60 dependant resources before attempting to destroy the old version. 61 62 63 ``` 64 resource "aws_iam_server_certificate" "test_cert" { 65 name_prefix = "example-cert" 66 certificate_body = "${file("self-ca-cert.pem")}" 67 private_key = "${file("test-key.pem")}" 68 69 lifecycle { 70 create_before_destroy = true 71 } 72 } 73 74 resource "aws_elb" "ourapp" { 75 name = "terraform-asg-deployment-example" 76 availability_zones = ["us-west-2a"] 77 cross_zone_load_balancing = true 78 79 listener { 80 instance_port = 8000 81 instance_protocol = "http" 82 lb_port = 443 83 lb_protocol = "https" 84 ssl_certificate_id = "${aws_iam_server_certificate.test_cert.arn}" 85 } 86 } 87 ``` 88 89 ## Argument Reference 90 91 The following arguments are supported: 92 93 * `name` - (Optional) The name of the Server Certificate. Do not include the 94 path in this value. If omitted, Terraform will assign a random, unique name. 95 * `name_prefix` - (Optional) Creates a unique name beginning with the specified 96 prefix. Conflicts with `name`. 97 * `certificate_body` – (Required) The contents of the public key certificate in 98 PEM-encoded format. 99 * `certificate_chain` – (Optional) The contents of the certificate chain. 100 This is typically a concatenation of the PEM-encoded public key certificates 101 of the chain. 102 * `private_key` – (Required) The contents of the private key in PEM-encoded format. 103 * `path` - (Optional) The IAM path for the server certificate. If it is not 104 included, it defaults to a slash (/). If this certificate is for use with 105 AWS CloudFront, the path must be in format `/cloudfront/your_path_here`. 106 See [IAM Identifiers][1] for more details on IAM Paths. 107 108 ~> **NOTE:** AWS performs behind-the-scenes modifications to some certificate files if they do not adhere to a specific format. These modifications will result in terraform forever believing that it needs to update the resources since the local and AWS file contents will not match after theses modifications occur. In order to prevent this from happening you must ensure that all your PEM-encoded files use UNIX line-breaks and that `certificate_body` contains only one certificate. All other certificates should go in `certificate_chain`. It is common for some Certificate Authorities to issue certificate files that have DOS line-breaks and that are actually multiple certificates concatenated together in order to form a full certificate chain. 109 110 ## Attributes Reference 111 112 * `id` - The unique Server Certificate name 113 * `name` - The name of the Server Certificate 114 * `arn` - The Amazon Resource Name (ARN) specifying the server certificate. 115 116 117 [1]: https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html 118 [2]: https://docs.aws.amazon.com/IAM/latest/UserGuide/ManagingServerCerts.html 119 [lifecycle]: /docs/configuration/resources.html