-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
New Resource: aws_neptune_cluster_parameter_group #4860
New Resource: aws_neptune_cluster_parameter_group #4860
Conversation
aws/validators_test.go
Outdated
_, errors := validateNeptuneParamGroupName(tc.Value, "aws_neptune_cluster_parameter_group_name") | ||
|
||
if len(errors) != tc.ErrCount { | ||
t.Fatalf("Expected the Neptune Parameter Group Name to trigger a validation error") |
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.
One of the test cases is generating unit test failures:
--- FAIL: TestValidateNeptuneParamGroupNamePrefix (0.00s)
validators_test.go:2733: Expected the Neptune Parameter Group Name to trigger a validation error
Can you please include tc.Value
in the error messaging here and below, then fix the test case? Thanks!
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 for submitting this @saravanan30erd! I left some feedback beyond just the unit testing piece. It will probably be good to go after. Please let us know if you have any questions or do not have time to implement this.
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSNeptuneClusterParameterGroupExists("aws_neptune_cluster_parameter_group.bar", &v), | ||
testAccCheckAWSNeptuneClusterParameterGroupAttributes(&v, parameterGroupName), | ||
resource.TestCheckResourceAttr( |
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 the arn
attribute value as well:
resource.TestMatchResourceAttr("aws_neptune_cluster_parameter_group.bar", "arn", regexp.MustCompile(fmt.Sprintf("^arn:[^:]+:neptune:[^:]+:\\d{12}:cluster-pg:%s", parameterGroupName)))
} | ||
} | ||
|
||
arn := arn.ARN{ |
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 use the value of the ARN from the Terraform state (coming from the API) rather than manually generating it:
arn := d.Get("arn").(string)
Since we're calling update after create, we'll need to d.Set("arn", ...)
in the create function as well as read.
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.
Yeah, thats what I am looking for.
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, done.
|
||
describeResp, err := conn.DescribeDBClusterParameterGroups(&describeOpts) | ||
if err != nil { | ||
if isAWSErr(err, neptune.ErrCodeDBParameterGroupNotFoundFault, "") { |
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.
The SDK provides a separate constant for cluster parameter groups: ErrCodeDBClusterParameterGroupNotFoundFault
|
||
if len(describeResp.DBClusterParameterGroups) != 1 || | ||
aws.StringValue(describeResp.DBClusterParameterGroups[0].DBClusterParameterGroupName) != d.Id() { | ||
return fmt.Errorf("Unable to find Cluster Parameter Group: %#v", describeResp.DBClusterParameterGroups) |
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.
Just like the regular parameter groups we should presume the API will return the correct result (terraform's plan would look very wrong otherwise) -- checking for zero length to recreate the resource instead of returning an error:
if len(describeResp.DbClusterParameterGroups) == 0 {
log.Printf("[WARN] Neptune Cluster Parameter Group (%s) not found, removing from state", d.Id())
d.SetId("")
return 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.
sure, I understood. But anyway we don't need to check for zero length right? since it should be covered by ErrCodeDBClusterParameterGroupNotFoundFault
.
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've seen cases where some service APIs will respond with no errors and also an empty result set. In any case, its best to include the handling to prevent Terraform from crashing with the Go panic of index not in range
.
log.Printf("[DEBUG] Deleting Neptune Cluster Parameter Group: %s", d.Id()) | ||
_, err := conn.DeleteDBClusterParameterGroup(&input) | ||
if err != nil { | ||
if isAWSErr(err, neptune.ErrCodeDBParameterGroupNotFoundFault, "") { |
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.
The SDK provides a separate constant for cluster parameter groups: ErrCodeDBClusterParameterGroupNotFoundFault
} | ||
|
||
if err != nil { | ||
if isAWSErr(err, neptune.ErrCodeDBParameterGroupNotFoundFault, "") { |
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.
The SDK provides a separate constant for cluster parameter groups: ErrCodeDBClusterParameterGroupNotFoundFault
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.
@bflad Looks like ErrCodeDBClusterParameterGroupNotFoundFault
only available for createdbcluster and modifydbcluster and ErrCodeDBParameterGroupNotFoundFault
is the one used for other functions.
https://docs.aws.amazon.com/sdk-for-go/api/service/neptune/#Neptune.DeleteDBClusterParameterGroup
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.
🙁 this is either an error in the AWS documentation or an oversight. I will reach out to AWS support for clarification.
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.
Sorry this was a bad assumption on my part. This behavior is frustrating:
$ aws neptune describe-db-cluster-parameter-groups --db-cluster-parameter-group-name does-not-exist
An error occurred (DBParameterGroupNotFound) when calling the DescribeDBClusterParameterGroups operation: DBClusterParameterGroup not found: does-not-exist
$ aws neptune delete-db-cluster-parameter-group --db-cluster-parameter-group-name does-not-exist
An error occurred (DBParameterGroupNotFound) when calling the DeleteDBClusterParameterGroup operation: DBClusterParameterGroup not found: does-not-exist
$ aws neptune modify-db-cluster-parameter-group --db-cluster-parameter-group-name does-not-exist --parameters 'ParameterName=test,ParameterValue=""'
An error occurred (DBParameterGroupNotFound) when calling the ModifyDBClusterParameterGroup operation: Parameter group does not exist
I guess we should stick with the non-Cluster
constant and add a comment to each instance about why its not using the Cluster
constant. My apologies.
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.
yes, acceptance tests were failed when I was tryingErrCodeDBClusterParameterGroupNotFoundFault
.
--- | ||
layout: "aws" | ||
page_title: "AWS: aws_neptune_cluster_parameter_group" | ||
sidebar_current: "docs-aws-resource-aws-neptune-cluster-parameter-group" |
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.
Documentation page is missing a sidebar link in website/aws.erb
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.
done, also I found duplicate entry for neptune parameter group in this file and removed it.
@bflad thanks for feedback, I done all the changes 👍 |
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.
This should be pretty good to go, thanks @saravanan30erd! I'll add an import test case post-merge and ensure that parameters are updating correctly via acceptance testing. 🚀
4 tests passed (all tests)
--- PASS: TestAccAWSNeptuneClusterParameterGroup_namePrefix (6.58s)
=== RUN TestAccAWSNeptuneClusterParameterGroup_generatedName
--- PASS: TestAccAWSNeptuneClusterParameterGroup_generatedName (6.65s)
=== RUN TestAccAWSNeptuneClusterParameterGroup_withoutParameter
--- PASS: TestAccAWSNeptuneClusterParameterGroup_withoutParameter (6.75s)
=== RUN TestAccAWSNeptuneClusterParameterGroup_basic
--- PASS: TestAccAWSNeptuneClusterParameterGroup_basic (6.85s)
This has been released in version 1.24.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Reference #4713
Changes proposed in this pull request:
added new resource neptune cluster parameter group