belt 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66c35b71a47f74ba7805bce24b37eb02fa6ded7246872df30a951a35be22d21f
4
- data.tar.gz: 5ddc3bb756fdf782da5074abb72bd0c7275c6a90f4ba98c81963b92cb9cd6bb9
3
+ metadata.gz: 05d5db875d229ad413bf8af05004a92961776b347db0884ded768f35fcfe245e
4
+ data.tar.gz: d6f1590f52f2a04b9457b82cf0c0cad094b96b8e04e112672df37d1e5ccf173b
5
5
  SHA512:
6
- metadata.gz: 44320ad96e29e29a6bb9b88d2de94822f982dad01e92bc639204c38d2bb7a306463b7b570ac8c35cbf13cc00a223a55442b52171ac64f3357de98a9662a5e3e9
7
- data.tar.gz: 8e176982bec58892623685d2b3bfd02cde1ab22d9fcac2c6eb1bfe58f5ae27f02d28b708cced560b803379b36bcd2bea5463fce749bde4ebd9b169cbfff878ba
6
+ metadata.gz: 5b9c29157f8d7b698c8f68c807564299f881b220473ef4a51194352092f5a8967dfce0495fb12bc24a813b4ab2e077358c3800151ccf8737059888560a62ad97
7
+ data.tar.gz: 6629a4a02a92e571d1e835ba0f12894f8bad945eb89bf79a2bc4696538378f45dfd7b5f5e3fc4090d9e61120c51d032b2fab5d5e2bdc17cfdfe81d25950061db
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.2
4
+
5
+ ### Fixed
6
+
7
+ - **First deploy of a new env with a `domain` no longer fails at plan.** The generated
8
+ module keyed `aws_route53_record.cert_validation` by the ACM validation CNAME name,
9
+ which is unknown until the cert exists, so `belt plan`/`belt deploy` on a brand-new
10
+ standalone env failed with `Invalid for_each argument` and needed a `-target` apply
11
+ of the cert first. The record is now `aws_route53_record.acm_validation`, keyed by
12
+ the env's domain (known at plan). A `removed` block forgets old `cert_validation`
13
+ instances without deleting the live CNAME. The module now needs Terraform >= 1.7.
14
+ Existing apps: see [UPGRADING.md](UPGRADING.md#acm-validation-record-062).
15
+
3
16
  ## 0.6.1
4
17
 
5
18
  ### Fixed
data/lib/belt/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.2'
5
5
 
6
6
  # Ruby version new apps run on in Lambda. Rendered into the conveyor-belt
7
7
  # provider block (`ruby_version`) by `belt new` / `belt generate environment`.
@@ -62,33 +62,45 @@ resource "aws_acm_certificate" "app" {
62
62
  }
63
63
  }
64
64
 
65
- # DNS validation record for the certificate
66
- # Key by resource_record_name (not domain_name) because ACM uses the same
67
- # validation CNAME for both base domain and wildcard — keying by domain_name
68
- # creates duplicate records that Route 53 rejects.
69
- # Use ellipsis (...) to group duplicates, then take the first element since
70
- # they're identical anyway.
71
- resource "aws_route53_record" "cert_validation" {
72
- for_each = local.dns_enabled && !local.is_nested ? {
73
- for dvo in aws_acm_certificate.app[0].domain_validation_options : dvo.resource_record_name => {
74
- name = dvo.resource_record_name
75
- type = dvo.resource_record_type
76
- record = dvo.resource_record_value
77
- }...
78
- } : {}
65
+ # DNS validation record for the certificate.
66
+ # ACM issues one identical validation CNAME for both the base domain and the
67
+ # wildcard, so one record covers the cert. Key it by app_domain (known at plan)
68
+ # rather than by anything from domain_validation_options: those values are
69
+ # unknown until the cert exists, and for_each over them fails the first plan
70
+ # of a new env with "Invalid for_each argument".
71
+ resource "aws_route53_record" "acm_validation" {
72
+ for_each = local.dns_enabled && !local.is_nested ? toset([local.app_domain]) : toset([])
79
73
 
80
74
  zone_id = aws_route53_zone.app[0].zone_id
81
- name = each.value[0].name
82
- type = each.value[0].type
75
+ name = local.acm_validation_options[each.key].resource_record_name
76
+ type = local.acm_validation_options[each.key].resource_record_type
83
77
  ttl = 300
84
- records = [each.value[0].record]
78
+ records = [local.acm_validation_options[each.key].resource_record_value]
85
79
  allow_overwrite = true
86
80
  }
87
81
 
82
+ locals {
83
+ acm_validation_options = local.dns_enabled && !local.is_nested ? {
84
+ for dvo in aws_acm_certificate.app[0].domain_validation_options : dvo.domain_name => dvo
85
+ } : {}
86
+ }
87
+
88
+ # Older Belt modules created this record as cert_validation, keyed by the
89
+ # validation CNAME name. Forget those instances without deleting them:
90
+ # acm_validation upserts the same CNAME (allow_overwrite), and a delete would
91
+ # pull the record ACM needs for renewal. No-op for envs that never had it.
92
+ removed {
93
+ from = aws_route53_record.cert_validation
94
+
95
+ lifecycle {
96
+ destroy = false
97
+ }
98
+ }
99
+
88
100
  resource "aws_acm_certificate_validation" "app" {
89
101
  count = local.dns_enabled && !local.is_nested ? 1 : 0
90
102
  certificate_arn = aws_acm_certificate.app[0].arn
91
- validation_record_fqdns = [for record in aws_route53_record.cert_validation : record.fqdn]
103
+ validation_record_fqdns = [for record in aws_route53_record.acm_validation : record.fqdn]
92
104
  }
93
105
 
94
106
  # =============================================================================
@@ -2,6 +2,9 @@
2
2
  # Environments call this module with different variables.
3
3
 
4
4
  terraform {
5
+ # >= 1.7 for the removed block in dns.tf
6
+ required_version = ">= 1.7"
7
+
5
8
  required_providers {
6
9
  aws = {
7
10
  source = "hashicorp/aws"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla