Skip to content

Commit c5f3866

Browse files
authored
Revert "feat: Add provision to use cross-account route53 for acm dns validation"
1 parent 8d911e9 commit c5f3866

File tree

13 files changed

+13
-108
lines changed

13 files changed

+13
-108
lines changed

.github/workflows/terraform-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout repository
1414
uses: actions/checkout@v4
1515
with:
16-
ref: ${{ github.event.pull_request.head.ref }}
16+
ref: ${{ github.ref }}
1717

1818
- name: Render and Push terraform docs for main module
1919
uses: terraform-docs/gh-actions@main

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ repos:
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_validate
7-
exclude: '^[^/]+\.tf$|^modules/acm/.*'
87
- id: terraform_tflint
98
args:
109
- '--args=--only=terraform_deprecated_interpolation'

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Terraform module to deploy production-ready applications and services on an exis
1212
| Name | Version |
1313
|------|---------|
1414
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.0 |
15-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 6.0 |
15+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
1616

1717
## Providers
1818

1919
| Name | Version |
2020
|------|---------|
21-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 6.0 |
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |
2222

2323
## Modules
2424

@@ -51,8 +51,6 @@ Terraform module to deploy production-ready applications and services on an exis
5151
| <a name="input_create_s3_bucket_for_alb_logging"></a> [create\_s3\_bucket\_for\_alb\_logging](#input\_create\_s3\_bucket\_for\_alb\_logging) | (Optional) Creates S3 bucket for storing ALB Access and Connection Logs. | `bool` | `true` | no |
5252
| <a name="input_default_capacity_providers_strategies"></a> [default\_capacity\_providers\_strategies](#input\_default\_capacity\_providers\_strategies) | (Optional) Set of capacity provider strategies to use by default for the cluster. | `any` | `[]` | no |
5353
| <a name="input_load_balancer"></a> [load\_balancer](#input\_load\_balancer) | Configuration for the Application Load Balancer. | <pre>object({<br/> name = optional(string)<br/> internal = optional(bool, false)<br/> subnets_ids = optional(list(string), [])<br/> security_groups_ids = optional(list(string), [])<br/> preserve_host_header = optional(bool)<br/> enable_deletion_protection = optional(bool, false)<br/> access_logs = optional(any, null)<br/> connection_logs = optional(any, null)<br/> target_groups = optional(any, {})<br/> listeners = optional(any, {})<br/> listener_rules = optional(any, {})<br/> tags = optional(map(string), {})<br/> })</pre> | `{}` | no |
54-
| <a name="input_region"></a> [region](#input\_region) | (Optional) AWS region to create resources in. | `string` | `null` | no |
55-
| <a name="input_route53_assume_role_arn"></a> [route53\_assume\_role\_arn](#input\_route53\_assume\_role\_arn) | (Optional) ARN of the role to assume for Route53 operations. | `string` | `null` | no |
5654
| <a name="input_s3_bucket_force_destroy"></a> [s3\_bucket\_force\_destroy](#input\_s3\_bucket\_force\_destroy) | (Optional, Default:false) Boolean that indicates all objects (including any locked objects) should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. | `bool` | `false` | no |
5755
| <a name="input_s3_bucket_name"></a> [s3\_bucket\_name](#input\_s3\_bucket\_name) | (Optional, Forces new resource) Name of the bucket. | `string` | `null` | no |
5856
| <a name="input_s3_bucket_policy_id_prefix"></a> [s3\_bucket\_policy\_id\_prefix](#input\_s3\_bucket\_policy\_id\_prefix) | (Optional) - Prefix of the ID for the policy document. | `string` | `"ecs-deployment-alb-"` | no |

examples/complete/main.tf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ module "ecs_deployment" {
9393
record_zone_id = data.aws_route53_zone.base_domain.zone_id
9494
}
9595
}
96-
region = var.region
97-
# Cross-account role that ACM module will use for Route53 DNS record creation
98-
route53_assume_role_arn = var.route53_assume_role_arn
9996

10097
# Application Load Balancer
10198
load_balancer = {

examples/complete/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,3 @@ variable "domain_name" {
132132
description = "Domain name for ACM"
133133
type = string
134134
}
135-
136-
variable "region" {
137-
description = "AWS region to deploy resources"
138-
type = string
139-
}
140-
141-
variable "route53_assume_role_arn" {
142-
description = "ARN of the cross-account role for Route53 DNS record creation"
143-
type = string
144-
}

main.tf

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -243,33 +243,12 @@ resource "aws_ecs_task_definition" "this" {
243243
################################################################################
244244
# Amazon Certificates Manager Sub-module
245245
################################################################################
246-
provider "aws" {
247-
region = var.region
248-
}
249-
250-
# Cross-account provider for Route53
251-
provider "aws" {
252-
alias = "cross_account_provider"
253-
region = var.region
254-
255-
dynamic "assume_role" {
256-
for_each = var.route53_assume_role_arn != null ? [1] : []
257-
content {
258-
role_arn = var.route53_assume_role_arn
259-
}
260-
}
261-
}
262246

263247
module "acm" {
264248
source = "./modules/acm"
265249

266-
providers = {
267-
aws = aws
268-
aws.cross_account_provider = aws.cross_account_provider
269-
}
270-
route53_assume_role_arn = var.route53_assume_role_arn
271-
272250
for_each = var.create_acm ? var.acm_certificates : {}
251+
273252
# ACM Certificate
274253
certificate_domain_name = each.value.domain_name
275254
certificate_subject_alternative_names = try(each.value.subject_alternative_names, null)
@@ -280,7 +259,8 @@ module "acm" {
280259
# Route53 Record
281260
record_zone_id = try(each.value.record_zone_id, null)
282261
record_allow_overwrite = try(each.value.record_allow_overwrite, null)
283-
tags = try(each.value.tags, {})
262+
263+
tags = try(each.value.tags, {})
284264
}
285265

286266
################################################################################

modules/acm/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ This sub-module creates the Amazon-issued certificate for a given domain with `v
2424
| Name | Version |
2525
|------|---------|
2626
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.0 |
27-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 6.0 |
2827

2928
## Providers
3029

3130
| Name | Version |
3231
|------|---------|
33-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 6.0 |
34-
| <a name="provider_aws.cross_account_provider"></a> [aws.cross\_account\_provider](#provider\_aws.cross\_account\_provider) | ~> 6.0 |
32+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
3533

3634
## Modules
3735

@@ -43,7 +41,6 @@ No modules.
4341
|------|------|
4442
| [aws_acm_certificate.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate) | resource |
4543
| [aws_acm_certificate_validation.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate_validation) | resource |
46-
| [aws_route53_record.cross_account](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
4744
| [aws_route53_record.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
4845

4946
## Inputs
@@ -57,7 +54,6 @@ No modules.
5754
| <a name="input_certificate_validation_option"></a> [certificate\_validation\_option](#input\_certificate\_validation\_option) | (Optional) Configuration block used to specify information about the initial validation of each domain name. | <pre>object({<br/> domain_name = string<br/> validation_domain = string<br/> })</pre> | `null` | no |
5855
| <a name="input_record_allow_overwrite"></a> [record\_allow\_overwrite](#input\_record\_allow\_overwrite) | (Optional) Allow creation of this record in Terraform to overwrite an existing record, if any. | `bool` | `true` | no |
5956
| <a name="input_record_zone_id"></a> [record\_zone\_id](#input\_record\_zone\_id) | (Required) Hosted zone ID for a CloudFront distribution, S3 bucket, ELB, or Route 53 hosted zone. | `string` | n/a | yes |
60-
| <a name="input_route53_assume_role_arn"></a> [route53\_assume\_role\_arn](#input\_route53\_assume\_role\_arn) | (Optional) IAM role ARN to assume for Route53 operations | `string` | `null` | no |
6157
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) Map of tags to assign to the resource. | `map(string)` | `{}` | no |
6258

6359
## Outputs
@@ -67,5 +63,5 @@ No modules.
6763
| <a name="output_acm_certificate_arn"></a> [acm\_certificate\_arn](#output\_acm\_certificate\_arn) | ARN of the ACM certificate. |
6864
| <a name="output_acm_certificate_id"></a> [acm\_certificate\_id](#output\_acm\_certificate\_id) | ARN of the ACM certificate. |
6965
| <a name="output_acm_certificate_validation_id"></a> [acm\_certificate\_validation\_id](#output\_acm\_certificate\_validation\_id) | Identifier of the ACM certificate validation resource. |
70-
| <a name="output_route53_record_id"></a> [route53\_record\_id](#output\_route53\_record\_id) | Identifier of the Route53 Record (supports same & cross-account). |
66+
| <a name="output_route53_record_id"></a> [route53\_record\_id](#output\_route53\_record\_id) | Identifier of the Route53 Record for validation of the ACM certificate. |
7167
<!-- END_TF_DOCS -->

modules/acm/main.tf

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,6 @@ resource "aws_acm_certificate" "this" {
3838
################################################################################
3939

4040
resource "aws_route53_record" "this" {
41-
count = var.route53_assume_role_arn == null ? 1 : 0
42-
43-
zone_id = var.record_zone_id
44-
name = local.acm_certificate_validation_record.name
45-
type = local.acm_certificate_validation_record.type
46-
records = [local.acm_certificate_validation_record.value]
47-
ttl = 60
48-
allow_overwrite = var.record_allow_overwrite
49-
}
50-
51-
resource "aws_route53_record" "cross_account" {
52-
count = var.route53_assume_role_arn != null ? 1 : 0
53-
provider = aws.cross_account_provider
54-
55-
5641
zone_id = var.record_zone_id
5742
name = local.acm_certificate_validation_record.name
5843
type = local.acm_certificate_validation_record.type
@@ -62,11 +47,6 @@ resource "aws_route53_record" "cross_account" {
6247
}
6348

6449
resource "aws_acm_certificate_validation" "this" {
65-
certificate_arn = aws_acm_certificate.this.arn
66-
67-
validation_record_fqdns = [
68-
var.route53_assume_role_arn == null ?
69-
aws_route53_record.this[0].fqdn :
70-
aws_route53_record.cross_account[0].fqdn
71-
]
50+
certificate_arn = aws_acm_certificate.this.arn
51+
validation_record_fqdns = [aws_route53_record.this.fqdn]
7252
}

modules/acm/outputs.tf

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,10 @@ output "acm_certificate_arn" {
1717
################################################################################
1818

1919
output "route53_record_id" {
20-
description = "Identifier of the Route53 Record (supports same & cross-account)."
21-
value = (
22-
var.route53_assume_role_arn == null
23-
? aws_route53_record.this[0].id
24-
: aws_route53_record.cross_account[0].id
25-
)
20+
description = "Identifier of the Route53 Record for validation of the ACM certificate."
21+
value = aws_route53_record.this.id
2622
}
2723

28-
2924
################################################################################
3025
# ACM Certificate Validation
3126
################################################################################

modules/acm/providers.tf

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

0 commit comments

Comments
 (0)