Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record: Add warning if TTL has changed #1157

Merged
merged 4 commits into from
May 17, 2024
Merged

Record: Add warning if TTL has changed #1157

merged 4 commits into from
May 17, 2024

Conversation

danaelhe
Copy link
Member

@danaelhe danaelhe commented May 16, 2024

Per @DanRStevens suggestion in #1012 , throws a warning if a record's TTL has changed to comply to rfc2181 which states that multiple records for the same fqdn are expected to have the same TTL.

For example, a plan with the following:

resource "digitalocean_domain" "example_com" {
  name = "example.com"
}

resource "digitalocean_record" "test_txt_2" {
  domain   = digitalocean_domain.example_com.name
  type     = "TXT"
  name     = "@"
  value    = "2"
  ttl      = 1800
}

resource "digitalocean_record" "test_txt_1" {
  domain   = digitalocean_domain.example_com.name
  type     = "TXT"
  name     = "@"
  value    = "1"
  ttl      = 60
}

Will result in digitalocean_record.test_txt_1 ttl to change from 60 to 1800. When this occurs, the following warning will be thrown:

│ Warning: digitalocean_record TTL changed
│
│   with digitalocean_record.test_txt_2,
│   on main.tf line 14, in resource "digitalocean_record" "test_txt_2":
│   14: resource "digitalocean_record" "test_txt_2" {
│
│ TTL for Record ID 1739652564 changed from 1800 to 60. This may be due to multiple records with the same fqdn are required to have the same TTL. For reference, see rfc2181,
│ section 5.2: https://www.rfc-editor.org/rfc/rfc2181#section-5.
╵

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Copy link
Member

@andrewsomething andrewsomething left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM!

I did add a suggestion inline that I think makes the warning a bit more clear by being explicit that change was made by DigitalOcean.

digitalocean/domain/resource_record.go Outdated Show resolved Hide resolved
danaelhe and others added 2 commits May 17, 2024 12:36
Co-authored-by: Andrew Starr-Bochicchio <andrewsomething@users.noreply.github.com>
@danaelhe danaelhe merged commit 4a9379e into main May 17, 2024
3 checks passed
@danaelhe danaelhe deleted the record_add_warning branch May 17, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants