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

fix: Fix an off-by-one error with validation records #47

Closed
wants to merge 3 commits into from
Closed

fix: Fix an off-by-one error with validation records #47

wants to merge 3 commits into from

Conversation

blaskov
Copy link

@blaskov blaskov commented Mar 20, 2020

Description

Prevent duplicated validation record causing failures when validation_allow_overwrite_records is set to false.

Motivation and Context

PR #32 introduces an obscure off-by-one error that leads to a duplicated validation record because of a wrap-around in distinct_domain_names.

I assume this hasn't been spotted until now mainly because the duplicated record gets silently overwritten when validation_allow_overwrite_records is set to true (as it is by
default).

I tried to identify corner cases when this + 1 is required, but couldn't find any. Please let me know if you are aware why it may be needed.

Breaking Changes

I don't think this is breaking backwards compatibility.

How Has This Been Tested?

Used latest master with disabled validation_allow_overwrite_records in examples/complete-dns-validation and verified that Terraform fails to apply.

Then did the change in this PR and managed to apply successfully.

blaskov added 2 commits March 19, 2020 17:16
PR #32 introduces an obscure off-by-one error that leads to a duplicated
validation record because of a wrap-around in `distinct_domain_names`.

I assume this hasn't been spotted until now mainly because the
duplicated record gets silently overwritten when
`validation_allow_overwrite_records` is set to `true` (as it is by
default).

I tried to identify a corner case when this `+ 1` is required, but
couldn't find any so far. Please let me know if you are aware why it may
be needed.
@blaskov
Copy link
Author

blaskov commented Mar 25, 2020

I'm not really sure what to do for this "Semantic Pull Request" check... help?

@antonbabenko
Copy link
Member

@blaskov You can safely ignore this for now. I will update PR template and explain how to deal with it in the near future. Meanwhile, you can prefix your PR title with feat: for new functionality or fix: if you are adding a bug-fix. More info here - https://www.conventionalcommits.org/en/v1.0.0/

@antonbabenko
Copy link
Member

The main reason why some PRs are not merged yet is the lack of time for proper research and investigation but we are getting there with more people involved in different terraform-aws-modules.

@blaskov blaskov changed the title Fix an off-by-one error with validation records fix: Fix an off-by-one error with validation records Mar 25, 2020
@blaskov
Copy link
Author

blaskov commented Mar 25, 2020

@antonbabenko Ok, I've added fix: to the title and that seems to have fixed the angry check problem 😄 Thanks!

As for the review - no worries, we've enabled validation_allow_overwrite_records as a workaround for time being, so this is not really urgent.

@e-moshaya
Copy link

This PR is definitely valid as it creates duplicate route53 validation records

@yehorb
Copy link

yehorb commented Jan 5, 2021

When (if) this PR gets applied, be careful when running terraform apply after updating.

Records created due to "wrapping" are stored as 2 different resources in the Terraform State, but they actually point to the same resource in AWS. So if in your plan you see something like this:

...
# aws_route53_record.validation[1] will be destroyed
...

be aware, that this will destroy the Record associated with aws_route53_record.validation[0]. In my case I was greeted with an Error: No matching records found, but potentially it can lead to an inconsistent state (resource aws_route53_record.validation[0] is present in Terraform state, but is missing from AWS).

This can be resolved with one more terraform apply, but still be careful.

It is better off to run terraform state rm aws_route53_record.validation[1] (or whatever the index of duplicated aws_route53_record in your case) and only then run apply.

Learned this the hard way just now by using the forked repo as the module source. Was not a big deal for me, but who knows.

@ricoli
Copy link

ricoli commented Feb 8, 2021

it's been almost a year since this PR was opened - any chance to get it merged? Also, it's now out of date, needs a rebase

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants