|
1 | 1 | # ACM Certificate Creation
|
2 |
| -This repo is used to create a certificate using DNS validation. It requires: |
3 |
| -- That there be a hosted zone which the IAM principal creating the resource has access to |
| 2 | +``` |
| 3 | +This repo is used to create a certificate using Route53 DNS validation. It requires a hosted zone to which the IAM |
| 4 | +principal creating the resource has access. |
| 5 | +``` |
4 | 6 |
|
5 | 7 | ### Example Usage:
|
6 | 8 | ```
|
7 |
| -module "resource_certificate" { |
8 |
| - source = "StratusGrid/acm-certificate-creation/aws" |
9 |
| - version = "1.0.0" |
10 |
| - # source = "github.com/StratusGrid/terraform-aws-acm-certificate-creation" |
11 |
| - acm_domain_name = "host.my.domain.com" |
12 |
| - hosted_zone_name = "my.domain.com" |
13 |
| - input_tags = merge(local.common_tags, {}) |
| 9 | +# Variables definition |
| 10 | +
|
| 11 | +variable "acm_certificate_name" { |
| 12 | + description = "Certificate name prefix which will be trailed by the hosted-zone name" |
| 13 | + type = list(string) |
| 14 | +} |
| 15 | +
|
| 16 | +variable "hosted_zone_name" { |
| 17 | + description = "Route53 hosted zone name" |
| 18 | + type = string |
| 19 | +} |
| 20 | +
|
| 21 | +acm_certificate_name = ["engineering", "sales"] |
| 22 | +hosted_zone_name = "example.com" |
| 23 | +``` |
| 24 | +``` |
| 25 | +data "aws_route53_zone" "hosted_zone_id" { |
| 26 | + name = var.hosted_zone_name |
| 27 | + private_zone = false |
14 | 28 | }
|
15 | 29 | ```
|
| 30 | +``` |
| 31 | +# Module call |
| 32 | +
|
| 33 | +module "new_record_and_certificate" { |
| 34 | + source = "github.com/StratusGrid/terraform-aws-acm-certificate-creation" |
| 35 | + |
| 36 | + for_each = toset(var.acm_certificate_name) |
| 37 | + acm_domain_name = "${each.key}.${var.hosted_zone_name}" |
| 38 | + zone_id = data.aws_route53_zone.hosted_zone_id.zone_id |
| 39 | + |
| 40 | + input_tags = { |
| 41 | + "Name" = "${each.key}.${var.hosted_zone_name}" |
| 42 | + } |
| 43 | +} |
| 44 | +``` |
0 commit comments