Skip to content
This repository was archived by the owner on Jan 31, 2021. It is now read-only.

Commit 8a3f617

Browse files
authored
Added ACM (#3)
* Added ACM
1 parent e5623f5 commit 8a3f617

File tree

4 files changed

+51
-5
lines changed

4 files changed

+51
-5
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ Available targets:
8383
lint Lint terraform code
8484
8585
```
86-
8786
## Inputs
8887

8988
| Name | Description | Type | Default | Required |
9089
|------|-------------|:----:|:-----:|:-----:|
90+
| acm_enabled | Set to false to prevent the acm module from creating any resources | string | `true` | no |
91+
| acm_primary_domain | A domain name for which the certificate should be issued | string | - | yes |
92+
| acm_san_domains | A list of domains that should be SANs in the issued certificate | list | `<list>` | no |
9193
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
9294
| chamber_format | Format to store parameters in SSM, for consumption with chamber | string | `/%s/%s` | no |
9395
| chamber_service | `chamber` service name. See [chamber usage](https://github.com/segmentio/chamber#usage) for more details | string | `` | no |
@@ -133,6 +135,8 @@ Available targets:
133135

134136
| Name | Description |
135137
|------|-------------|
138+
| acm_arn | The ARN of the certificate |
139+
| acm_domain_validation_options | CNAME records that are added to the DNS zone to complete certificate validation |
136140
| aurora_postgres_cluster_name | Aurora Postgres Cluster Identifier |
137141
| aurora_postgres_database_name | Aurora Postgres Database name |
138142
| aurora_postgres_master_hostname | Aurora Postgres DB Master hostname |

acm.tf

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
variable "acm_enabled" {
2+
description = "Set to false to prevent the acm module from creating any resources"
3+
default = "true"
4+
}
5+
6+
variable "acm_primary_domain" {
7+
description = "A domain name for which the certificate should be issued"
8+
}
9+
10+
variable "acm_san_domains" {
11+
type = "list"
12+
default = []
13+
description = "A list of domains that should be SANs in the issued certificate"
14+
}
15+
16+
resource "aws_acm_certificate" "default" {
17+
count = "${var.acm_enabled ? 1 : 0}"
18+
domain_name = "${var.acm_primary_domain}"
19+
validation_method = "DNS"
20+
subject_alternative_names = ["${var.acm_san_domains}"]
21+
tags = "${var.tags}"
22+
23+
lifecycle {
24+
create_before_destroy = true
25+
}
26+
}
27+
28+
output "acm_arn" {
29+
value = "${join("", aws_acm_certificate.default.*.arn)}"
30+
description = "The ARN of the certificate"
31+
}
32+
33+
output "acm_domain_validation_options" {
34+
value = "${flatten(aws_acm_certificate.default.*.domain_validation_options)}"
35+
description = "CNAME records that are added to the DNS zone to complete certificate validation"
36+
}

docs/terraform.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
21
## Inputs
32

43
| Name | Description | Type | Default | Required |
54
|------|-------------|:----:|:-----:|:-----:|
5+
| acm_enabled | Set to false to prevent the acm module from creating any resources | string | `true` | no |
6+
| acm_primary_domain | A domain name for which the certificate should be issued | string | - | yes |
7+
| acm_san_domains | A list of domains that should be SANs in the issued certificate | list | `<list>` | no |
68
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
79
| chamber_format | Format to store parameters in SSM, for consumption with chamber | string | `/%s/%s` | no |
810
| chamber_service | `chamber` service name. See [chamber usage](https://github.com/segmentio/chamber#usage) for more details | string | `` | no |
@@ -48,6 +50,8 @@
4850

4951
| Name | Description |
5052
|------|-------------|
53+
| acm_arn | The ARN of the certificate |
54+
| acm_domain_validation_options | CNAME records that are added to the DNS zone to complete certificate validation |
5155
| aurora_postgres_cluster_name | Aurora Postgres Cluster Identifier |
5256
| aurora_postgres_database_name | Aurora Postgres Database name |
5357
| aurora_postgres_master_hostname | Aurora Postgres DB Master hostname |

examples/complete/main.tf

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module "vpc" {
88
stage = "${var.stage}"
99
name = "${var.name}"
1010
attributes = "${var.attributes}"
11-
tags = "${local.tags}"
1211
cidr_block = "${var.vpc_cidr_block}"
1312
}
1413

@@ -19,7 +18,6 @@ module "subnets" {
1918
stage = "${var.stage}"
2019
name = "${var.name}"
2120
attributes = "${var.attributes}"
22-
tags = "${local.tags}"
2321
region = "${var.region}"
2422
vpc_id = "${module.vpc.vpc_id}"
2523
igw_id = "${module.vpc.igw_id}"
@@ -28,7 +26,7 @@ module "subnets" {
2826
}
2927

3028
module "codefresh_backing_services" {
31-
source = "git::https://github.com/cloudposse/terraform-aws-codefresh-backing-services.git?ref=0.1.0"
29+
source = "../../"
3230
enabled = "true"
3331
name = "${var.name}"
3432
namespace = "${var.namespace}"
@@ -38,6 +36,10 @@ module "codefresh_backing_services" {
3836
subnet_ids = ["${module.subnets.private_subnet_ids}"]
3937
security_groups = ["${module.vpc.vpc_default_security_group_id}"]
4038

39+
acm_enabled = "true"
40+
acm_primary_domain = "example.com"
41+
acm_san_domains = ["*.example.com"]
42+
4143
chamber_format = "/%s/%s"
4244
chamber_service = "codefresh-backing-services"
4345
kms_key_id = "${format("alias/%s-%s-chamber", var.namespace, var.stage)}"

0 commit comments

Comments
 (0)