Skip to content

Commit 875fe16

Browse files
committed
refactor(modules/acm): remove unnecessary try logic, set default value of key_algorithm to "RSA_2048", and add nullable flags to variables
Update documentation.
1 parent 685fd10 commit 875fe16

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

modules/acm/.header.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This sub-module creates the Amazon-issued certificate for a given domain with `v
77
### ACM Certificate
88

99
- The `validation_method` is set to `DNS` as the recommended method, and can be overridden to use `EMAIL` method if required.
10+
- The `validation_method` is not marked as nullable, and is a required attribute for Amazon-issued ACM certificates.
11+
- The `key_algorithm` is set to `RSA_2048` as the default algorithm, and can be overridden to specify a different algorithm if required.
1012

1113
### Route53 Record
1214

modules/acm/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ locals {
1313

1414
resource "aws_acm_certificate" "this" {
1515
domain_name = var.certificate_domain_name
16-
subject_alternative_names = try(var.certificate_subject_alternative_names, null)
17-
validation_method = try(var.certificate_validation_method, null)
18-
key_algorithm = try(var.certificate_key_algorithm, null)
16+
subject_alternative_names = var.certificate_subject_alternative_names
17+
validation_method = var.certificate_validation_method
18+
key_algorithm = var.certificate_key_algorithm
1919

2020
dynamic "validation_option" {
2121
for_each = try(var.certificate_validation_option, null) != null ? [1] : []

modules/acm/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,27 @@
55
variable "certificate_domain_name" {
66
description = "(Required) Domain name for which the certificate should be issued."
77
type = string
8+
nullable = false
89
}
910

1011
variable "certificate_subject_alternative_names" {
1112
description = "(Optional) Set of domains that should be SANs in the issued certificate."
1213
type = list(string)
14+
nullable = false
1315
default = []
1416
}
1517

1618
variable "certificate_validation_method" {
1719
description = "(Optional) Which method to use for validation. DNS or EMAIL are valid."
1820
type = string
21+
nullable = false
1922
default = "DNS"
2023
}
2124

2225
variable "certificate_key_algorithm" {
2326
description = "(Optional) Specifies the algorithm of the public and private key pair that your Amazon issued certificate uses to encrypt data."
2427
type = string
25-
default = null
28+
default = "RSA_2048"
2629
}
2730

2831
variable "certificate_validation_option" {
@@ -37,6 +40,7 @@ variable "certificate_validation_option" {
3740
variable "tags" {
3841
description = "(Optional) Map of tags to assign to the resource."
3942
type = map(string)
43+
nullable = false
4044
default = {}
4145
}
4246

@@ -47,10 +51,12 @@ variable "tags" {
4751
variable "record_zone_id" {
4852
description = "(Required) Hosted zone ID for a CloudFront distribution, S3 bucket, ELB, or Route 53 hosted zone."
4953
type = string
54+
nullable = false
5055
}
5156

5257
variable "record_allow_overwrite" {
5358
description = "(Optional) Allow creation of this record in Terraform to overwrite an existing record, if any."
5459
type = bool
60+
nullable = false
5561
default = true
5662
}

0 commit comments

Comments
 (0)