Skip to content

Commit 06ed67b

Browse files
committed
Fixing certificates quirks
1 parent f672f0d commit 06ed67b

File tree

6 files changed

+38
-5
lines changed

6 files changed

+38
-5
lines changed

action.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ inputs:
244244
aws_r53_create_sub_cert:
245245
description: 'Generates and manage the sub-domain certificate for the application'
246246
required: false
247+
aws_r53_export_cert:
248+
description: 'Enables export flag of the certificate.'
249+
required: false
247250
aws_r53_additional_tags:
248251
description: 'A JSON object of additional tags that will be included on created resources. Example: `{"key1": "value1", "key2": "value2"}`'
249252
required: false
@@ -1334,6 +1337,7 @@ runs:
13341337
AWS_R53_CERT_ARN: ${{ inputs.aws_r53_cert_arn }}
13351338
AWS_R53_CREATE_ROOT_CERT: ${{ inputs.aws_r53_create_root_cert }}
13361339
AWS_R53_CREATE_SUB_CERT: ${{ inputs.aws_r53_create_sub_cert }}
1340+
AWS_R53_EXPORT_CERT: ${{ inputs.aws_r53_export_cert }}
13371341
AWS_R53_ADDITIONAL_TAGS: ${{ inputs.aws_r53_additional_tags }}
13381342

13391343
# AWS ELB

operations/_scripts/generate/generate_vars_terraform.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ if [[ $(alpha_only "$AWS_R53_ENABLE_CERT") == true ]]; then
116116
aws_r53_cert_arn=$(generate_var aws_r53_cert_arn $AWS_R53_CERT_ARN)
117117
aws_r53_create_root_cert=$(generate_var aws_r53_create_root_cert $AWS_R53_CREATE_ROOT_CERT)
118118
aws_r53_create_sub_cert=$(generate_var aws_r53_create_sub_cert $AWS_R53_CREATE_SUB_CERT)
119+
aws_r53_export_cert=$(generate_var aws_r53_export_cert $AWS_R53_EXPORT_CERT)
119120
fi
120121

121122
#-- AWS ELB --#
@@ -512,6 +513,7 @@ $aws_r53_enable_cert
512513
$aws_r53_cert_arn
513514
$aws_r53_create_root_cert
514515
$aws_r53_create_sub_cert
516+
$aws_r53_export_cert
515517
$aws_r53_additional_tags
516518
517519
#-- ELB --#

operations/deployment/terraform/aws/aws_variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ variable "aws_r53_create_sub_cert" {
260260
default = false
261261
}
262262

263+
variable "aws_r53_export_cert" {
264+
type = bool
265+
description = "Enables export flag of the certificate."
266+
default = false
267+
}
268+
263269
variable "aws_r53_additional_tags" {
264270
type = string
265271
description = "A list of strings that will be added to created resources"

operations/deployment/terraform/aws/bitovi_main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module "aws_certificates" {
6767
aws_r53_cert_arn = var.aws_r53_cert_arn
6868
aws_r53_create_root_cert = var.aws_r53_create_root_cert
6969
aws_r53_create_sub_cert = var.aws_r53_create_sub_cert
70+
aws_r53_export_cert = var.aws_r53_export_cert
7071
# R53
7172
aws_r53_domain_name = var.aws_r53_domain_name
7273
aws_r53_sub_domain_name = var.aws_r53_sub_domain_name

operations/deployment/terraform/modules/aws/certificates/aws_certificates.tf

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ data "aws_route53_zone" "selected" {
66

77
data "aws_acm_certificate" "issued" {
88
#count = local.is_enabled_and_valid ? (!var.aws_r53_create_root_cert ? (!var.aws_r53_create_sub_cert ? (var.fqdn_provided ? 1 : 0) : 0) : 0) :0
9-
for_each = local.is_enabled_and_valid ? {
10-
"domain" : var.aws_r53_domain_name,
11-
"wildcard" : "*.${var.aws_r53_domain_name}"
12-
"sub" : "${var.aws_r53_sub_domain_name}.${var.aws_r53_domain_name}"
9+
for_each = (!var.aws_r53_create_root_cert && !var.aws_r53_create_sub_cert && local.is_enabled_and_valid) ? {
10+
"domain" = var.aws_r53_domain_name,
11+
"wildcard" = "*.${var.aws_r53_domain_name}",
12+
"sub" = "${var.aws_r53_sub_domain_name}.${var.aws_r53_domain_name}"
1313
} : {}
14-
domain = var.aws_r53_domain_name
14+
domain = each.value
15+
#domain = var.aws_r53_domain_name
1516
}
1617

1718
# This block will create and validate the root domain and www cert
@@ -20,6 +21,15 @@ resource "aws_acm_certificate" "root_domain" {
2021
domain_name = var.aws_r53_domain_name
2122
subject_alternative_names = ["*.${var.aws_r53_domain_name}", "${var.aws_r53_domain_name}"]
2223
validation_method = "DNS"
24+
dynamic "options" {
25+
for_each = var.aws_r53_export_cert ? [1] : []
26+
content {
27+
export = "ENABLED"
28+
}
29+
}
30+
lifecycle {
31+
create_before_destroy = true
32+
}
2333
}
2434

2535
resource "aws_route53_record" "root_domain" {
@@ -44,6 +54,15 @@ resource "aws_acm_certificate" "sub_domain" {
4454
count = local.is_enabled_and_valid ? (var.aws_r53_create_sub_cert ? (var.aws_r53_domain_name != "" ? (var.aws_r53_sub_domain_name != "" ? (var.aws_r53_create_root_cert ? 0 : 1) : 0) : 0) : 0) : 0
4555
domain_name = "${var.aws_r53_sub_domain_name}.${var.aws_r53_domain_name}"
4656
validation_method = "DNS"
57+
dynamic "options" {
58+
for_each = var.aws_r53_export_cert ? [1] : []
59+
content {
60+
export = "ENABLED"
61+
}
62+
}
63+
lifecycle {
64+
create_before_destroy = true
65+
}
4766
}
4867

4968
resource "aws_route53_record" "sub_domain" {

operations/deployment/terraform/modules/aws/certificates/aws_certificates_vars.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
variable "aws_r53_create_root_cert" {}
22
variable "aws_r53_create_sub_cert" {}
33
variable "aws_r53_cert_arn" {}
4+
variable "aws_r53_export_cert" {}
45
# R53
56
variable "aws_r53_domain_name" {}
67
variable "aws_r53_sub_domain_name" {}

0 commit comments

Comments
 (0)