belt 0.4.6 → 0.4.7
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/belt/cli/apex_dns_sync.rb +75 -0
- data/lib/belt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f2da2bf0507f4f380a01130c184e6a2bb54103e21274d0aa589ae1dd1d546a7
|
|
4
|
+
data.tar.gz: 1ad686dae1cf98301b286465beee62b5ae23e3d56541679e93110a9c7fa933ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 298cba520960d5ebe54cbc47623aa068ef22ab7888edd3535b77278ef5d71d5d28bd01e7ac02d984d03f4f9baa09b1ff932c87d665a00f218aba12c88be5ac83
|
|
7
|
+
data.tar.gz: f5fe8ff182396627f1bdd2fd451f664d6bf1848959e7d869a7912709487035df8fd87cdae10ed983aec7181a82a9cd5fca9bb17af6f488bea5bfadcd8cd89c6e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.7
|
|
4
|
+
|
|
5
|
+
### Bug Fix
|
|
6
|
+
|
|
7
|
+
- **`apex_dns_sync` now publishes SES DKIM CNAMEs to the root zone.** Apex
|
|
8
|
+
environments delegate the bare domain to the shared-services root zone, so DNS
|
|
9
|
+
records written only to the prod-account zone never reach the internet.
|
|
10
|
+
`ApexDnsSync` already mirrored apex/www/api A aliases and ACM validation CNAMEs
|
|
11
|
+
into the root zone, but not the 3 SES DKIM CNAMEs — leaving SES domain email at
|
|
12
|
+
the apex stuck in `PENDING` / `HOST_NOT_FOUND` with every send rejected.
|
|
13
|
+
`#run` now reads the domain identity's DKIM tokens from SES (under the prod
|
|
14
|
+
profile) and upserts `<token>._domainkey.<domain>` → `<token>.dkim.amazonses.com`
|
|
15
|
+
into the root zone via the same cross-account write path. No-ops silently when
|
|
16
|
+
the domain has no SES identity, so email-less apps are unaffected.
|
|
17
|
+
|
|
3
18
|
## 0.4.6
|
|
4
19
|
|
|
5
20
|
### Added
|
|
@@ -62,6 +62,12 @@ module Belt
|
|
|
62
62
|
# Sync ACM validation first (cert must validate before CloudFront works)
|
|
63
63
|
sync_acm_validation(root_zone_id, targets[:domain])
|
|
64
64
|
|
|
65
|
+
# Sync SES DKIM CNAMEs so the email domain identity can verify. Like the
|
|
66
|
+
# apex A records, these must live in the ROOT zone (the registrar delegates
|
|
67
|
+
# the apex there) — writing them to the prod account's own zone leaves them
|
|
68
|
+
# invisible and the SES identity stuck at PENDING/HOST_NOT_FOUND.
|
|
69
|
+
sync_dkim_cnames(root_zone_id, targets[:domain])
|
|
70
|
+
|
|
65
71
|
# Sync A alias records
|
|
66
72
|
sync_alias_records(root_zone_id, targets)
|
|
67
73
|
|
|
@@ -303,6 +309,75 @@ module Belt
|
|
|
303
309
|
end
|
|
304
310
|
end
|
|
305
311
|
|
|
312
|
+
# Publish the SES Easy-DKIM CNAMEs for the apex email domain into the root
|
|
313
|
+
# zone. SES issues three tokens per domain identity; each maps to a CNAME
|
|
314
|
+
# "<token>._domainkey.<domain>" -> "<token>.dkim.amazonses.com". Publishing
|
|
315
|
+
# them where the domain is actually delegated (the root zone) is what flips
|
|
316
|
+
# the identity from PENDING/HOST_NOT_FOUND to verified so sends are accepted.
|
|
317
|
+
# No-ops quietly when the domain has no SES identity (email not enabled).
|
|
318
|
+
def sync_dkim_cnames(root_zone_id, domain)
|
|
319
|
+
return unless domain
|
|
320
|
+
|
|
321
|
+
tokens = fetch_dkim_tokens(domain)
|
|
322
|
+
return if tokens.empty?
|
|
323
|
+
|
|
324
|
+
changes = build_dkim_changes(domain, tokens)
|
|
325
|
+
upsert_dkim_cnames(root_zone_id, changes, tokens.size)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
# Read the domain identity's DKIM tokens from SES under the PROD profile
|
|
329
|
+
# (that's the account that owns the identity). Returns [] if there's no
|
|
330
|
+
# identity or SES call fails, so email-less apps skip silently.
|
|
331
|
+
def fetch_dkim_tokens(domain)
|
|
332
|
+
env = aws_env_for(@env_config)
|
|
333
|
+
|
|
334
|
+
output, status = Open3.capture2e(
|
|
335
|
+
env,
|
|
336
|
+
'aws', 'sesv2', 'get-email-identity',
|
|
337
|
+
'--email-identity', domain,
|
|
338
|
+
'--output', 'json'
|
|
339
|
+
)
|
|
340
|
+
return [] unless status.success?
|
|
341
|
+
|
|
342
|
+
data = parse_json(output) || {}
|
|
343
|
+
data.dig('DkimAttributes', 'Tokens') || []
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def build_dkim_changes(domain, tokens)
|
|
347
|
+
tokens.map do |token|
|
|
348
|
+
{
|
|
349
|
+
Action: 'UPSERT',
|
|
350
|
+
ResourceRecordSet: {
|
|
351
|
+
Name: "#{token}._domainkey.#{domain}",
|
|
352
|
+
Type: 'CNAME',
|
|
353
|
+
TTL: 300,
|
|
354
|
+
ResourceRecords: [{ Value: "#{token}.dkim.amazonses.com" }]
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
def upsert_dkim_cnames(root_zone_id, changes, count)
|
|
361
|
+
change_batch = {
|
|
362
|
+
Comment: 'Belt SES DKIM sync',
|
|
363
|
+
Changes: changes
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
dns_env = aws_env_for(@dns_config)
|
|
367
|
+
_, status = Open3.capture2e(
|
|
368
|
+
dns_env,
|
|
369
|
+
'aws', 'route53', 'change-resource-record-sets',
|
|
370
|
+
'--hosted-zone-id', root_zone_id,
|
|
371
|
+
'--change-batch', JSON.generate(change_batch)
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
if status.success?
|
|
375
|
+
puts " ✓ SES DKIM CNAMEs synced (#{count})" unless @quiet
|
|
376
|
+
else
|
|
377
|
+
puts ' ⚠ Failed to sync SES DKIM CNAMEs' unless @quiet
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
306
381
|
def alias_change(action, name, target_domain, target_zone_id)
|
|
307
382
|
{
|
|
308
383
|
Action: action,
|
data/lib/belt/version.rb
CHANGED