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

allow AWS_DB_INSTANCE final_snapshot_identifier to accept empty string as omitted. #3848

Closed
cthomaspdx opened this issue Nov 10, 2015 · 8 comments · Fixed by #3853
Closed

Comments

@cthomaspdx
Copy link

Omitting final_snapshot_identifier will result in one not being created. Passing an empty string currently results in
Errors: * aws_db_instance.admin-interface: only alphanumeric characters and hyphens allowed in "final_snapshot_identifier"

It would be great if passing final_snapshot_identifier a empty string resulted in not creating a final snapshot.

I would like to not have to create a snapshot in my staging environments, as of now I can't find a work around.

@cthomaspdx
Copy link
Author

terraform -v
Terraform v0.6.6

On Nov 10, 2015, at 1:41 PM, Paul Stack notifications@github.com wrote:

@cthomaspdx https://github.com/cthomaspdx This should already be the case:

finalSnapshot := d.Get("final_snapshot_identifier").(string)
if finalSnapshot == "" {
opts.SkipFinalSnapshot = aws.Bool(true)
} else {
opts.FinalDBSnapshotIdentifier = aws.String(finalSnapshot)
}

this is currently in master. What version of TF are you using?


Reply to this email directly or view it on GitHub #3848 (comment).

@stack72
Copy link
Contributor

stack72 commented Nov 10, 2015

@cthomaspdx Ok, I removed that last comment. It seems that the schema validates the final_snapshot_identifier as follows:

"final_snapshot_identifier": &schema.Schema{
                Type:     schema.TypeString,
                Optional: true,
                ValidateFunc: func(v interface{}, k string) (ws []string, es []error) {
                    value := v.(string)
                    if !regexp.MustCompile(`^[0-9A-Za-z-]+$`).MatchString(value) {
                        es = append(es, fmt.Errorf(
                            "only alphanumeric characters and hyphens allowed in %q", k))
                    }
                    if regexp.MustCompile(`--`).MatchString(value) {
                        es = append(es, fmt.Errorf("%q cannot contain two consecutive hyphens", k))
                    }
                    if regexp.MustCompile(`-$`).MatchString(value) {
                        es = append(es, fmt.Errorf("%q cannot end in a hyphen", k))
                    }
                    return
                },
            },

I am not sure if it is acceptable to bypass this validation as per the http://docs.aws.amazon.com/cli/latest/reference/rds/delete-db-instance.html. I guess that skip_final_snapshot could be added if @phinze / @catsby / @jen20 would agree

This would effectively be able to resign that functionality

@jen20
Copy link
Contributor

jen20 commented Nov 10, 2015

@cthomaspdx Thanks for bringing this up. Am I correct in assuming that the reason you'd rather use an empty string than something like skip_final_snapshot=true is because you're using this as part of a module which is reused across environments?

I'm not sure offhand whether there is precedent for how to approach this, but we should probably look for other resources with similar behaviour to determine this.

@cthomaspdx
Copy link
Author

Hey guys! Great response time! I found this article https://groups.google.com/forum/m/#!msg/terraform-tool/xA3QPNX84Bg/SEeBCEt5MQAJ where they override a variable "snapshot" {default = ""}. But I am not partial to a resolution either should fix my dilemma. I am using it as part of a module.

@cthomaspdx
Copy link
Author

Now that I have thought about it more. I think it may be best to add skip_final_snapshot as my final_snapshot_identifier uses a nice little interpolated stringfinal_snapshot_identifier = "${var.name}-${var.env}-final" which I can't seem to set inside of the module block or as a variable. Variables can't interpolate and module block doesn't seem have access to the other variables set with in it. I may be wrong about this as it is my first week using terraform. Also, is there any reason that both solutions can't play well?

@stack72
Copy link
Contributor

stack72 commented Nov 10, 2015

I personally think that skip_final_snapshot works best as it means you can disable snapshots without having to change the identifier strings :)

@stack72
Copy link
Contributor

stack72 commented Nov 10, 2015

Opened PR #3853 to see if this works

@ghost
Copy link

ghost commented Apr 29, 2020

I'm going to lock this issue 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 similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants