-
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
New Resource: aws_dax_cluster #2884
Conversation
Unit test results:
|
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.
@gazoakley this is off to a good start! Thank so much for all the legwork here. I've left some initial comments below so please let me know if you have any questions. Also, if you don't have time to finish up the work here, feel free to let us know as well.
Passes locally for me so far:
make testacc TEST=./aws TESTARGS='-run=TestAccAwsDaxCluster'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAwsDaxCluster -timeout 120m
=== RUN TestAccAwsDaxCluster_basic
--- PASS: TestAccAwsDaxCluster_basic (1411.68s)
=== RUN TestAccAwsDaxCluster_resize
--- PASS: TestAccAwsDaxCluster_resize (1244.04s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 2655.771s
StateFunc: func(val interface{}) string { | ||
return strings.ToLower(val.(string)) | ||
}, | ||
// DAX follows the same naming convention as ElastiCache 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.
Thank you for the comment here!
aws/resource_aws_dax_cluster.go
Outdated
Pending: pending, | ||
Target: []string{"available"}, | ||
Refresh: daxClusterStateRefreshFunc(conn, d.Id(), "available", pending), | ||
Timeout: 40 * time.Minute, |
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.
Nitpick: I think we'll want to switch these to the schema timeout handlers instead of hardcoding it since they are so long:
# under &schema.Resource
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(45 * time.Minute),
Delete: schema.DefaultTimeout(45 * time.Minute),
Update: schema.DefaultTimeout(90 * time.Minute),
},
# example usage
d.Timeout(schema.TimeoutCreate)
# for adding the standard documentation you can search for ## Timeouts in the markdown files
aws/resource_aws_dax_cluster.go
Outdated
ClusterNames: []*string{aws.String(clusterID)}, | ||
}) | ||
if err != nil { | ||
apierr := err.(awserr.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.
Nitpick: Can use our helper function and the SDK constant here to simplify this:
if isAwsErr(err, dax.ErrCodeClusterNotFoundFault, "") {
aws/resource_aws_dax_cluster.go
Outdated
} | ||
|
||
if c.Status == nil { | ||
log.Printf("[DEBUG] DAX Cluster %s has no status attribute set - assume status is deleting", clusterID) |
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.
Should we be assuming here? It seems more likely we should be returning an 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.
I need to go back and check, but I think when I wrote this the status field wasn't set during deletion. If that's the case I'll drop a comment in.
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.
Yep. Goes through stages of:
- "deleting" status:
{"Clusters":[{"ActiveNodes":0,"ClusterArn":"arn:aws:dax:us-west-2:799416384551:cache/tf-x2r91tkwdp","ClusterDiscoveryEndpoint":{"Address":"tf-x2r91tkwdp.ydlnd2.clustercfg.dax.usw2.cache.amazonaws.com","Port":8111},"ClusterName":"tf-x2r91tkwdp","IamRoleArn":"arn:aws:iam::799416384551:role/terraform-20180213123722223800000001","NodeType":"dax.r3.large","ParameterGroup":{"NodeIdsToReboot":[],"ParameterApplyStatus":"in-sync","ParameterGroupName":"default.dax1.0"},"PreferredMaintenanceWindow":"fri:09:00-fri:10:00","SecurityGroups":[{"SecurityGroupIdentifier":"sg-3e289a46","Status":"active"}],"Status":"deleting","SubnetGroup":"default","TotalNodes":1}]}
- No status:
{"Clusters":[{"ClusterArn":"arn:aws:dax:us-west-2:799416384551:cache/tf-x2r91tkwdp","ClusterName":"tf-x2r91tkwdp"}]}
- ClusterNotFoundFault:
{"__type":"ClusterNotFoundFault","message":"Cluster tf-x2r91tkwdp not found."}
I'll drop in a comment stating we don't get a status towards the end of the deletion process.
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.
Ha nice - every AWS API is special 😅 thanks for all your work here!
aws/resource_aws_dax_cluster.go
Outdated
return err | ||
} | ||
|
||
if len(res.Clusters) == 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.
Nickpick: switch this to the opposite condition and return immediately (to save all the later indentation):
if len(res.Clusters) == 0 {
log.Printf("[WARN] DAX cluster (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
aws/resource_aws_dax_cluster_test.go
Outdated
}) | ||
if err != nil { | ||
// Verify the error is what we want | ||
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "ClusterNotFoundFault" { |
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.
isAwsErr(err, dax.ErrCodeClusterNotFoundFault, "")
can help here too 😉
Provides an DAX Cluster resource. | ||
--- | ||
|
||
# aws\_dax\_cluster |
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.
Nitpick: Backslashes are extraneous here 😄
```hcl | ||
resource "aws_dax_cluster" "bar" { | ||
cluster_id = "cluster-example" | ||
iam_role_arn = "arn:aws:iams:us-east-1:012345678999" |
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.
Especially since this is an invalid ARN, you can point at a fake data source like ${data.aws_iam_role.example.arn}
|
||
## Attributes Reference | ||
|
||
The following attributes are exported: |
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.
Please add additional
before attributes (we get sometimes have confusion issues with our newer Terraform implementors)
DAX Clusters can be imported using the `cluster_id`, e.g. | ||
|
||
``` | ||
$ terraform import aws_dax_cluster.my_cluster my_cluster |
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.
Please add an acceptance test step to (at least) the _basic
test that checks importability:
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
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.
I've created a separate test in import_aws_dax_cluster_test.go
55b03aa
to
927fa14
Compare
927fa14
to
08e04f2
Compare
08e04f2
to
6ef4d1f
Compare
6ef4d1f
to
207d92c
Compare
Thanks for your updates, we really appreciate your effort here. Please let me know when this good to check again or if you don't have time for anything. 👍 |
@bflad Also added an |
I can get to this later today. Thanks! |
Acceptance tests passing:
|
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.
@gazoakley this is fantastic -- awesome job and thanks for the hard work! 🚀
make testacc TEST=./aws TESTARGS='-run=TestAccAWSDAXCluster'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDAXCluster -timeout 120m
=== RUN TestAccAWSDAXCluster_importBasic
--- PASS: TestAccAWSDAXCluster_importBasic (701.49s)
=== RUN TestAccAWSDAXCluster_basic
--- PASS: TestAccAWSDAXCluster_basic (1039.20s)
=== RUN TestAccAWSDAXCluster_resize
--- PASS: TestAccAWSDAXCluster_resize (1300.12s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 3040.870s
This has been released in version 1.10.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! |
This adds support for managing AWS DynamoDB Accelerator (DAX). It adds a new aws_dax_cluster resource. Addresses #936