-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Feature/add snapshot schedules resource for redshift #8064
Feature/add snapshot schedules resource for redshift #8064
Conversation
0d115c7
to
b45d731
Compare
b45d731
to
aad1fd9
Compare
Rerun test after rebase master.
|
…t_schedule_association resources
f496012
to
dc84159
Compare
…pshot_schedule_association resources
dc84159
to
a886ea1
Compare
Re-run acctest
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @kterada0509 👋 Thanks so much for this contribution. Overall, looking really good just some minor things to fix up before we can merge this in. Please let us know if you have any questions or do not have time to implement the items.
} | ||
|
||
var associatedCluster *redshift.ClusterAssociatedToSchedule | ||
foundAssociatedCluster := false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This boolean variable is extraneous since we can check associatedCluster == nil
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fix it.
|
||
func resourceAwsRedshiftSnapshotScheduleAssociationParseId(id string) (clusterIdentifier, scheduleIdentifier string, err error) { | ||
parts := strings.SplitN(id, "/", 2) | ||
if len(parts) != 2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check for empty strings on either side of the /
as well 👍
if len(parts) != 2 { | |
if len(parts) != 2 || parts[0] == "" || parts[1] == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fix it.
|
||
func waitForRedshiftSnapshotScheduleAssociationActive(conn *redshift.Redshift, timeout time.Duration, clusterIdentifier, scheduleIdentifier string) error { | ||
// sleep 30 seconds to give it time, until association information included to describe response | ||
time.Sleep(30 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource.StateChangeConf
accepts a delay in its configuration so this can be moved there 😄
stateConf := &resource.StateChangeConf{
// ...
Delay: 30 * time.Second,
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fix it.
ClusterIdentifier: aws.String(clusterIdentifier), | ||
}) | ||
|
||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically prefer to invert this logic so it reads a little easier:
if err != nil {
return err
}
if resp != nil && len(resp.SnapshotSchedules) > 0 {
return fmt.Errorf(/*...*/)
}
// no return nil since we want to check all the resources of this type
website/aws.erb
Outdated
@@ -2360,6 +2360,12 @@ | |||
<li> | |||
<a href="/docs/providers/aws/r/redshift_snapshot_copy_grant.html">aws_redshift_snapshot_copy_grant</a> | |||
</li> | |||
<li> | |||
<a href="/docs/providers/aws/r/redshift_snapshot_schedule_association.html">redshift_snapshot_schedule_association</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing aws_
prefix 😎
<a href="/docs/providers/aws/r/redshift_snapshot_schedule_association.html">redshift_snapshot_schedule_association</a> | |
<a href="/docs/providers/aws/r/redshift_snapshot_schedule_association.html">aws_redshift_snapshot_schedule_association</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed!
website/aws.erb
Outdated
<a href="/docs/providers/aws/r/redshift_snapshot_schedule_association.html">redshift_snapshot_schedule_association</a> | ||
</li> | ||
<li> | ||
<a href="/docs/providers/aws/r/redshift_snapshot_schedule.html">redshift_snapshot_schedule</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎
<a href="/docs/providers/aws/r/redshift_snapshot_schedule.html">redshift_snapshot_schedule</a> | |
<a href="/docs/providers/aws/r/redshift_snapshot_schedule.html">aws_redshift_snapshot_schedule</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅
* `identifier_prefix` - (Optional, Forces new resource) Creates a unique | ||
identifier beginning with the specified prefix. Conflicts with `identifier`. | ||
* `description` - (Optional) The description of the snapshot schedule. | ||
* `definitions` - (Optional) The definition of the snapshot schedule. The definition is made up of schedule expressions, for example "cron(30 12 *)" or "rate(12 hours)". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we might want to wrap these two examples in backticks since Markdown is interpreting the * for italics
* `definitions` - (Optional) The definition of the snapshot schedule. The definition is made up of schedule expressions, for example "cron(30 12 *)" or "rate(12 hours)". | |
* `definitions` - (Optional) The definition of the snapshot schedule. The definition is made up of schedule expressions, for example `cron(30 12 *)` or `rate(12 hours)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed it.
identifier beginning with the specified prefix. Conflicts with `identifier`. | ||
* `description` - (Optional) The description of the snapshot schedule. | ||
* `definitions` - (Optional) The definition of the snapshot schedule. The definition is made up of schedule expressions, for example "cron(30 12 *)" or "rate(12 hours)". | ||
* `force_destroy` - (Optional) Whether to destroy all associated settings with clusters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo 😎
* `force_destroy` - (Optional) Whether to destroy all associated settings with clusters. | |
* `force_destroy` - (Optional) Whether to destroy all associated clusters with this snapshot schedule on deletion. Must be enabled and applied before attempting deletion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅
} | ||
|
||
resource "aws_redshift_snapshot_schedule_association" "default" { | ||
cluster_identifier = "${aws_redshift_cluster.default.id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: formatting
cluster_identifier = "${aws_redshift_cluster.default.id}" | |
cluster_identifier = "${aws_redshift_cluster.default.id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed it.
Re-run acctest.
|
@bflad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the updates, looks good, thanks @kterada0509 🚀
--- PASS: TestAccAWSRedshiftSnapshotSchedule_withDescription (10.08s)
--- PASS: TestAccAWSRedshiftSnapshotSchedule_withIdentifierPrefix (10.12s)
--- PASS: TestAccAWSRedshiftSnapshotSchedule_withMultipleDefinition (13.44s)
--- PASS: TestAccAWSRedshiftSnapshotSchedule_basic (15.01s)
--- PASS: TestAccAWSRedshiftSnapshotSchedule_withTags (15.10s)
--- PASS: TestAccAWSRedshiftSnapshotSchedule_withForceDestroy (663.90s)
--- PASS: TestAccAWSRedshiftSnapshotScheduleAssociation_basic (680.42s)
This has been released in version 2.23.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Fixes #7228
Changes proposed in this pull request:
aws_redshift_snapshot_schedule
resourceaws_redshift_snapshot_schedule_association
resourceOutput from acceptance testing:
aws_redshift_snapshot_schedule
aws_redshift_snapshot_schedule_association