Skip to content

Commit 8bad533

Browse files
authored
Convert to TF 0.12. Add tests. Add Codefresh test pipeline (#20)
* Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline * Convert to TF 0.12. Add tests. Add Codefresh test pipeline
1 parent f6f10a5 commit 8bad533

22 files changed

+529
-81
lines changed

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2017-2018 Cloud Posse, LLC
189+
Copyright 2017-2019 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
# terraform-aws-acm-request-certificate
77

8-
[![Build Status](https://travis-ci.org/cloudposse/terraform-aws-acm-request-certificate.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-acm-request-certificate) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-acm-request-certificate.svg)](https://github.com/cloudposse/terraform-aws-acm-request-certificate/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
8+
[![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-acm-request-certificate?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d13bc4da6fc75502872e5f8) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-acm-request-certificate.svg)](https://github.com/cloudposse/terraform-aws-acm-request-certificate/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
99

1010

11-
Terraform module to request an ACM certificate for a domain and add a CNAME record to the DNS zone to complete certificate validation
11+
Terraform module to request an ACM certificate for a domain and add a CNAME record to the DNS zone to complete certificate validation
1212

1313

1414
---
@@ -44,13 +44,18 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are
4444

4545
## Usage
4646

47+
48+
**IMPORTANT:** The `master` branch is used in `source` just as an example. In your code, do not pin to `master` because there may be breaking changes between releases.
49+
Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest releases](https://github.com/cloudposse/terraform-aws-acm-request-certificate/releases).
50+
51+
4752
This example will request an SSL certificate for `example.com` domain
4853

4954
```hcl
5055
module "acm_request_certificate" {
5156
source = "git::https://github.com/cloudposse/terraform-aws-acm-request-certificate.git?ref=master"
5257
domain_name = "example.com"
53-
process_domain_validation_options = "true"
58+
process_domain_validation_options = true
5459
ttl = "300"
5560
}
5661
```
@@ -61,7 +66,7 @@ This example will request an SSL certificate for `example.com` domain and all it
6166
module "acm_request_certificate" {
6267
source = "git::https://github.com/cloudposse/terraform-aws-acm-request-certificate.git?ref=master"
6368
domain_name = "example.com"
64-
process_domain_validation_options = "true"
69+
process_domain_validation_options = true
6570
ttl = "300"
6671
subject_alternative_names = ["*.example.com"]
6772
}
@@ -87,11 +92,13 @@ Available targets:
8792
| Name | Description | Type | Default | Required |
8893
|------|-------------|:----:|:-----:|:-----:|
8994
| domain_name | A domain name for which the certificate should be issued | string | - | yes |
90-
| process_domain_validation_options | Flag to enable/disable processing of the record to add to the DNS zone to complete certificate validation | string | `true` | no |
91-
| subject_alternative_names | A list of domains that should be SANs in the issued certificate | list | `<list>` | no |
92-
| tags | Additional tags (e.g. map('BusinessUnit`,`XYZ`) | map | `<map>` | no |
95+
| enabled | Set to false to prevent the module from creating or accessing any resources | bool | `true` | no |
96+
| process_domain_validation_options | Flag to enable/disable processing of the record to add to the DNS zone to complete certificate validation | bool | `true` | no |
97+
| subject_alternative_names | A list of domains that should be SANs in the issued certificate | list(string) | `<list>` | no |
98+
| tags | Additional tags (e.g. map('BusinessUnit`,`XYZ`) | map(string) | `<map>` | no |
9399
| ttl | The TTL of the record to add to the DNS zone to complete certificate validation | string | `300` | no |
94-
| validation_method | Which method to use for validation, DNS or EMAIL | string | `DNS` | no |
100+
| validation_method | Method to use for validation, DNS or EMAIL | string | `DNS` | no |
101+
| wait_for_certificate_issued | Whether to wait for the certificate to be issued by ACM (the certificate status changed from `Pending Validation` to `Issued`) | bool | `false` | no |
95102
| zone_name | The name of the desired Route53 Hosted Zone | string | `` | no |
96103

97104
## Outputs
@@ -100,7 +107,7 @@ Available targets:
100107
|------|-------------|
101108
| arn | The ARN of the certificate |
102109
| domain_validation_options | CNAME records that are added to the DNS zone to complete certificate validation |
103-
| id | The ARN of the certificate |
110+
| id | The ID of the certificate |
104111

105112

106113

@@ -238,11 +245,15 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
238245

239246
### Contributors
240247

241-
| [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] |
242-
|---|---|
248+
| [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]<br/>[Igor Rodionov][goruha_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] |
249+
|---|---|---|---|
243250

244251
[aknysh_homepage]: https://github.com/aknysh
245252
[aknysh_avatar]: https://github.com/aknysh.png?size=150
253+
[osterman_homepage]: https://github.com/osterman
254+
[osterman_avatar]: https://github.com/osterman.png?size=150
255+
[goruha_homepage]: https://github.com/goruha
256+
[goruha_avatar]: https://github.com/goruha.png?size=150
246257
[SweetOps_homepage]: https://github.com/SweetOps
247258
[SweetOps_avatar]: https://github.com/SweetOps.png?size=150
248259

README.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ github_repo: cloudposse/terraform-aws-acm-request-certificate
3434

3535
# Badges to display
3636
badges:
37-
- name: "Build Status"
38-
image: "https://travis-ci.org/cloudposse/terraform-aws-acm-request-certificate.svg?branch=master"
39-
url: "https://travis-ci.org/cloudposse/terraform-aws-acm-request-certificate"
37+
- name: "Codefresh Build Status"
38+
image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-acm-request-certificate?type=cf-1"
39+
url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d13bc4da6fc75502872e5f8"
4040
- name: "Latest Release"
4141
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-acm-request-certificate.svg"
4242
url: "https://github.com/cloudposse/terraform-aws-acm-request-certificate/releases/latest"
@@ -54,7 +54,7 @@ related:
5454

5555
# Short description of this project
5656
description: |-
57-
Terraform module to request an ACM certificate for a domain and add a CNAME record to the DNS zone to complete certificate validation
57+
Terraform module to request an ACM certificate for a domain and add a CNAME record to the DNS zone to complete certificate validation
5858
5959
# How to use this project
6060
usage: |-
@@ -64,7 +64,7 @@ usage: |-
6464
module "acm_request_certificate" {
6565
source = "git::https://github.com/cloudposse/terraform-aws-acm-request-certificate.git?ref=master"
6666
domain_name = "example.com"
67-
process_domain_validation_options = "true"
67+
process_domain_validation_options = true
6868
ttl = "300"
6969
}
7070
```
@@ -75,7 +75,7 @@ usage: |-
7575
module "acm_request_certificate" {
7676
source = "git::https://github.com/cloudposse/terraform-aws-acm-request-certificate.git?ref=master"
7777
domain_name = "example.com"
78-
process_domain_validation_options = "true"
78+
process_domain_validation_options = true
7979
ttl = "300"
8080
subject_alternative_names = ["*.example.com"]
8181
}
@@ -89,5 +89,9 @@ include:
8989
contributors:
9090
- name: "Andriy Knysh"
9191
github: "aknysh"
92+
- name: "Erik Osterman"
93+
github: "osterman"
94+
- name: "Igor Rodionov"
95+
github: "goruha"
9296
- name: "Vladimir"
93-
github: "SweetOps"
97+
github: "SweetOps"

codefresh/test.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
version: '1.0'
2+
3+
stages:
4+
- Prepare
5+
- Test
6+
7+
steps:
8+
wait:
9+
title: Wait
10+
stage: Prepare
11+
image: codefresh/cli:latest
12+
commands:
13+
- codefresh get builds --pipeline=${{CF_REPO_NAME}} --status running --limit 1000 -o json | jq --arg id ${{CF_BUILD_ID}} -ser 'flatten|.[-1].id==$id'
14+
retry:
15+
maxAttempts: 10
16+
delay: 20
17+
exponentialFactor: 1.1
18+
19+
main_clone:
20+
title: "Clone repository"
21+
type: git-clone
22+
stage: Prepare
23+
description: "Initialize"
24+
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
25+
git: CF-default
26+
revision: ${{CF_REVISION}}
27+
28+
clean_init:
29+
title: Prepare build-harness and test-harness
30+
image: ${{TEST_IMAGE}}
31+
stage: Prepare
32+
commands:
33+
- cf_export PATH="/usr/local/terraform/0.12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
34+
- make init
35+
- git -C build-harness checkout master
36+
- make -C test/ clean init TEST_HARNESS_BRANCH=master
37+
- make -C test/src clean init
38+
- find . -type d -name '.terraform' | xargs rm -rf
39+
- find . -type f -name 'terraform.tfstate*' -exec rm -f {} \;
40+
41+
test:
42+
type: "parallel"
43+
title: "Run tests"
44+
description: "Run all tests in parallel"
45+
stage: Test
46+
steps:
47+
test_readme_lint:
48+
title: "Test README.md updated"
49+
stage: "Test"
50+
image: ${{TEST_IMAGE}}
51+
description: Test "readme/lint"
52+
commands:
53+
- make readme/lint
54+
55+
test_module:
56+
title: Test module with bats
57+
image: ${{TEST_IMAGE}}
58+
stage: Test
59+
commands:
60+
- make -C test/ module
61+
62+
test_examples_complete:
63+
title: Test "examples/complete" with bats
64+
image: ${{TEST_IMAGE}}
65+
stage: Test
66+
commands:
67+
- make -C test/ examples/complete
68+
69+
test_examples_complete_terratest:
70+
title: Test "examples/complete" with terratest
71+
image: ${{TEST_IMAGE}}
72+
stage: Test
73+
commands:
74+
- make -C test/src

docs/terraform.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
| Name | Description | Type | Default | Required |
44
|------|-------------|:----:|:-----:|:-----:|
55
| domain_name | A domain name for which the certificate should be issued | string | - | yes |
6-
| process_domain_validation_options | Flag to enable/disable processing of the record to add to the DNS zone to complete certificate validation | string | `true` | no |
7-
| subject_alternative_names | A list of domains that should be SANs in the issued certificate | list | `<list>` | no |
8-
| tags | Additional tags (e.g. map('BusinessUnit`,`XYZ`) | map | `<map>` | no |
6+
| enabled | Set to false to prevent the module from creating or accessing any resources | bool | `true` | no |
7+
| process_domain_validation_options | Flag to enable/disable processing of the record to add to the DNS zone to complete certificate validation | bool | `true` | no |
8+
| subject_alternative_names | A list of domains that should be SANs in the issued certificate | list(string) | `<list>` | no |
9+
| tags | Additional tags (e.g. map('BusinessUnit`,`XYZ`) | map(string) | `<map>` | no |
910
| ttl | The TTL of the record to add to the DNS zone to complete certificate validation | string | `300` | no |
10-
| validation_method | Which method to use for validation, DNS or EMAIL | string | `DNS` | no |
11+
| validation_method | Method to use for validation, DNS or EMAIL | string | `DNS` | no |
12+
| wait_for_certificate_issued | Whether to wait for the certificate to be issued by ACM (the certificate status changed from `Pending Validation` to `Issued`) | bool | `false` | no |
1113
| zone_name | The name of the desired Route53 Hosted Zone | string | `` | no |
1214

1315
## Outputs
@@ -16,5 +18,5 @@
1618
|------|-------------|
1719
| arn | The ARN of the certificate |
1820
| domain_validation_options | CNAME records that are added to the DNS zone to complete certificate validation |
19-
| id | The ARN of the certificate |
21+
| id | The ID of the certificate |
2022

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
region = "us-west-1"
2+
3+
namespace = "eg"
4+
5+
stage = "test"
6+
7+
name = "test-zone"
8+
9+
parent_zone_name = "testing.cloudposse.co"
10+
11+
validation_method = "DNS"
12+
13+
ttl = "300"
14+
15+
process_domain_validation_options = true
16+
17+
wait_for_certificate_issued = false

examples/complete/main.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
provider "aws" {
2+
region = var.region
3+
}
4+
5+
module "zone" {
6+
source = "git::https://github.com/cloudposse/terraform-aws-route53-cluster-zone.git?ref=tags/0.4.0"
7+
namespace = var.namespace
8+
stage = var.stage
9+
name = var.name
10+
parent_zone_name = var.parent_zone_name
11+
zone_name = "$${name}.$${parent_zone_name}"
12+
}
13+
14+
module "acm_request_certificate" {
15+
source = "../../"
16+
domain_name = module.zone.zone_name
17+
validation_method = var.validation_method
18+
ttl = var.ttl
19+
subject_alternative_names = ["*.${module.zone.zone_name}"]
20+
process_domain_validation_options = var.process_domain_validation_options
21+
wait_for_certificate_issued = var.wait_for_certificate_issued
22+
}

examples/complete/outputs.tf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
output "parent_zone_id" {
2+
value = module.zone.parent_zone_id
3+
}
4+
5+
output "parent_zone_name" {
6+
value = module.zone.parent_zone_name
7+
}
8+
9+
output "zone_id" {
10+
value = module.zone.zone_id
11+
}
12+
13+
output "zone_name" {
14+
value = module.zone.zone_name
15+
}
16+
17+
output "zone_fqdn" {
18+
value = module.zone.fqdn
19+
}
20+
21+
output "certificate_id" {
22+
value = module.acm_request_certificate.id
23+
description = "The ID of the certificate"
24+
}
25+
26+
output "certificate_arn" {
27+
value = module.acm_request_certificate.arn
28+
description = "The ID of the certificate"
29+
}
30+
31+
output "certificate_domain_validation_options" {
32+
value = module.acm_request_certificate.domain_validation_options
33+
description = "CNAME records that are added to the DNS zone to complete certificate validation"
34+
}

examples/complete/variables.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
variable "namespace" {
2+
type = string
3+
description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
4+
}
5+
6+
variable "stage" {
7+
type = string
8+
description = "Stage (e.g. `prod`, `dev`, `staging`)"
9+
}
10+
11+
variable "name" {
12+
type = string
13+
description = "The Name of the application or solution (e.g. `bastion` or `portal`)"
14+
}
15+
16+
variable "region" {
17+
type = string
18+
description = "AWS region"
19+
}
20+
21+
variable "parent_zone_name" {
22+
type = string
23+
description = "Parent DNS zone name"
24+
}
25+
26+
variable "validation_method" {
27+
type = string
28+
description = "Method to use for validation, DNS or EMAIL"
29+
}
30+
31+
variable "process_domain_validation_options" {
32+
type = bool
33+
description = "Flag to enable/disable processing of the record to add to the DNS zone to complete certificate validation"
34+
}
35+
36+
variable "ttl" {
37+
type = string
38+
description = "The TTL of the record to add to the DNS zone to complete certificate validation"
39+
}
40+
41+
variable "wait_for_certificate_issued" {
42+
type = bool
43+
description = "Whether to wait for the certificate to be issued by ACM (the certificate status changed from `Pending Validation` to `Issued`)"
44+
}

0 commit comments

Comments
 (0)