Skip to content

Commit f14393a

Browse files
committed
Add multiple usage examples
1 parent 1652cf6 commit f14393a

File tree

10 files changed

+250
-1
lines changed

10 files changed

+250
-1
lines changed

README.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,102 @@
11
# Terraform AWS Certificate Manager (ACM) with Multi Zone Module
22

33
Terraform module to create an ACM resource that contains domains from multiple Route53 hosted zone.
4-
ACM validation is using Route53 domain.
4+
ACM validation is using Route53 only.
55
This module supports terraform version 0.12 only.
66

7+
## Usage
8+
9+
The `domains` variable consist of list of map (object). Each object must consist **zone** and **domain** keys.
10+
11+
- The **zone** key must contains hosted zone name that must be hosted on Route53 in the same AWS account with the requested certificate.
12+
- The **domain** key contains domain name that will be used in the certificate in the domain name or subject alternative names section.
13+
14+
```terraform
15+
module "acm" {
16+
source = "../"
17+
18+
domains = [
19+
{
20+
zone = "example.com"
21+
domain = "example.com"
22+
},
23+
{
24+
zone = "example.com"
25+
domain = "*.example.com"
26+
},
27+
{
28+
zone = "example.org"
29+
domain = "example.org"
30+
},
31+
{
32+
zone = "example.org"
33+
domain = "*.example.org"
34+
}
35+
]
36+
37+
tags = {
38+
Name = "Test ACM multiple zone"
39+
}
40+
}
41+
```
42+
43+
## Examples
44+
45+
- [Basic usage example](./examples/basic/)
46+
- [Use existing domain validations records](./examples/without-domain-validation)
47+
48+
## Conditional domain validation creation
49+
50+
Let's say we want to create a new ACM certificate and there is exiting ACM certificate with overlapping domain name.
51+
Most likely domain validation has been setup on Route53 and it makes the existing domain validation will be overwritten.
52+
Overwritting existing domain validation records might not be a desired behaviour.
53+
To change this behaviour, exclude setting domain validation records on Route53 by configuring the `validation_set_records` variable to **false**.
54+
55+
```terraform
56+
module "acm" {
57+
source = "../"
58+
59+
domains = [
60+
{
61+
zone = "example.com"
62+
domain = "example.com"
63+
},
64+
{
65+
zone = "example.com"
66+
domain = "*.example.com"
67+
},
68+
{
69+
zone = "example.org"
70+
domain = "example.org"
71+
},
72+
{
73+
zone = "example.org"
74+
domain = "*.example.org"
75+
}
76+
]
77+
78+
validation_set_records = false
79+
80+
tags = {
81+
Name = "Test ACM multiple zone"
82+
}
83+
}
84+
```
85+
86+
## Inputs
87+
88+
| Name | Description | Type | Default | Required |
89+
|------|-------------|------|---------|:--------:|
90+
| domains | List of map of string containing domain name for the certificate and its corresponding hosted zone name | `list(map(string))` | n/a | yes |
91+
| tags | Key and value pair that will be added as tag | `map(string)` | `{}` | no |
92+
| validate\_certificate | Whether to validate certificate | `bool` | `true` | no |
93+
| validation\_allow\_overwrite\_records | Whether to allow overwrite of Route53 records | `bool` | `true` | no |
94+
| validation\_set\_records | Whether to configure Route53 records for validation | `bool` | `true` | no |
95+
96+
## Outputs
97+
98+
| Name | Description |
99+
|------|-------------|
100+
| certificate\_arn | The ARN of the certificate |
101+
| certificate\_domain\_validation\_options | A list of attributes to feed into other resources to complete certificate validation |
102+
| certificate\_domains | List of domain names covered by the certificate |

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test

examples/basic/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Terraform AWS ACM Multiple Hosted Zone Example
2+
3+
This provides example on how to use terraform-aws-acm-multiple-hosted-zone module.
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```terraform
10+
terraform init
11+
terraform plan -out=tfplan.out
12+
terraform apply tfplan.out
13+
```
14+
15+
Note that this example may create resources that cost money.
16+
Run `terraform destroy` when you don't need the resources anymore.
17+
18+
## Requirements
19+
20+
| Name | Version |
21+
|------|---------|
22+
| aws | ~> 2.61 |
23+
24+
## Providers
25+
26+
No provider.
27+
28+
## Inputs
29+
30+
No input.
31+
32+
## Outputs
33+
34+
| Name | Description |
35+
|------|-------------|
36+
| certificate\_arn | n/a |
37+
| certificate\_domains | n/a |
38+

examples/basic/main.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module "acm" {
2+
source = "../../"
3+
4+
domains = [
5+
{
6+
zone = "example.com"
7+
domain = "example.com"
8+
},
9+
{
10+
zone = "example.com"
11+
domain = "*.example.com"
12+
},
13+
{
14+
zone = "example.org"
15+
domain = "example.org"
16+
},
17+
{
18+
zone = "example.org"
19+
domain = "*.example.org"
20+
}
21+
]
22+
23+
tags = {
24+
Name = "Test ACM request with multiple hosted zones"
25+
}
26+
}

examples/basic/outputs.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "certificate_arn" {
2+
value = module.acm.certificate_arn
3+
}
4+
5+
output "certificate_domains" {
6+
value = module.acm.certificate_domains
7+
}

examples/basic/providers.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "aws" {
2+
version = "~> 2.61"
3+
region = "us-west-2"
4+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Terraform AWS ACM Multiple Hosted Zone Example
2+
3+
This provides example on how to use terraform-aws-acm-multiple-hosted-zone module without creating or overwriting existing domain validation records on Route53.
4+
5+
## Usage
6+
7+
To run this example you need to execute:
8+
9+
```terraform
10+
terraform init
11+
terraform plan -out=tfplan.out
12+
terraform apply tfplan.out
13+
```
14+
15+
Note that this example may create resources that cost money.
16+
Run `terraform destroy` when you don't need the resources anymore.
17+
18+
## Requirements
19+
20+
| Name | Version |
21+
|------|---------|
22+
| aws | ~> 2.61 |
23+
24+
## Providers
25+
26+
No provider.
27+
28+
## Inputs
29+
30+
No input.
31+
32+
## Outputs
33+
34+
| Name | Description |
35+
|------|-------------|
36+
| certificate\_arn | n/a |
37+
| certificate\_domains | n/a |
38+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module "acm" {
2+
source = "../../"
3+
4+
domains = [
5+
{
6+
zone = "example.com"
7+
domain = "example.com"
8+
},
9+
{
10+
zone = "example.com"
11+
domain = "*.example.com"
12+
},
13+
{
14+
zone = "example.org"
15+
domain = "example.org"
16+
},
17+
{
18+
zone = "example.org"
19+
domain = "*.example.org"
20+
}
21+
]
22+
23+
validation_set_records = false
24+
25+
tags = {
26+
Name = "Test ACM request with multiple hosted zones"
27+
}
28+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "certificate_arn" {
2+
value = module.acm.certificate_arn
3+
}
4+
5+
output "certificate_domains" {
6+
value = module.acm.certificate_domains
7+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "aws" {
2+
version = "~> 2.61"
3+
region = "us-west-2"
4+
}

0 commit comments

Comments
 (0)