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

r/aws_dax_cluster: Support encryption at rest #5508

Merged
merged 1 commit into from
Aug 17, 2018

Conversation

ewbankkit
Copy link
Contributor

Fixes #5500.
Acceptance tests:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSDAXCluster_basic'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAWSDAXCluster_basic -timeout 120m
=== RUN   TestAccAWSDAXCluster_basic
--- PASS: TestAccAWSDAXCluster_basic (669.50s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	669.513s
$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSDAXCluster_encryption'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -run=TestAccAWSDAXCluster_encryption -timeout 120m
=== RUN   TestAccAWSDAXCluster_encryption
--- PASS: TestAccAWSDAXCluster_encryption (596.19s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	596.203s

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Aug 10, 2018
iam_role_arn = "${aws_iam_role.test.arn}"
node_type = "dax.r3.large"
node_type = "dax.t2.small"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node type changed as encryption at rest is not supported for dax.r3.* node types:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -158,34 +158,3 @@ func resourceAwsDaxParameterGroupDelete(d *schema.ResourceData, meta interface{}

return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these 2 functions to structure.go.

@radeksimko radeksimko added enhancement Requests to existing resources that expand the functionality or scope. service/dax Issues and PRs that pertain to the dax service. labels Aug 13, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @ewbankkit! 🚀 I made some nitpicky cleanup in a commit after yours (we generally recommend against using CustomizeDiff unless really necessary).

--- PASS: TestAccAWSDAXCluster_encryption_disabled (597.08s)
--- PASS: TestAccAWSDAXCluster_importBasic (605.43s)
--- PASS: TestAccAWSDAXCluster_encryption_enabled (679.29s)
--- PASS: TestAccAWSDAXCluster_basic (736.60s)
--- PASS: TestAccAWSDAXCluster_resize (1289.44s)

@@ -137,6 +151,28 @@ func TestAccAWSDAXCluster_resize(t *testing.T) {
testAccCheckAWSDAXClusterExists("aws_dax_cluster.test", &dc),
resource.TestCheckResourceAttr(
"aws_dax_cluster.test", "replication_factor", "1"),
resource.TestCheckResourceAttr(
"aws_dax_cluster.test", "server_side_encryption.0.enabled", "true"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this check was extraneously added 😉

--- FAIL: TestAccAWSDAXCluster_resize (1252.75s)
	testing.go:527: Step 2 error: Check failed: Check 3/3 error: aws_dax_cluster.test: Attribute 'server_side_encryption.0.enabled' expected "true", got "false"

iam_role_arn = "${aws_iam_role.test.arn}"
node_type = "dax.r3.large"
node_type = "dax.t2.small"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"server_side_encryption": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to remove the following by changing the schema definition:

  • Computed: true
  • CustomizeDiff
  • isDaxClusterOptionDisabled

Check this out:

"server_side_encryption": {
	Type:     schema.TypeList,
	Optional: true,
	MaxItems: 1,
	DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
		if old == "1" && new == "0" {
			return true
		}
		return false
	},
	Elem: &schema.Resource{
		Schema: map[string]*schema.Schema{
			"enabled": {
				Type:     schema.TypeBool,
				Optional: true,
				Default:  false,
			},
		},
	},
},

At some point I need to make that DiffSuppressFunc into its own function 😅 , its basically just there to ignore the container attribute being unset in the Terraform configuration (all child attribute differences still apply).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I reused the logic from aws_dynamodb_table so we may want to refactor there also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Especially as it looks like with AWS SDK v1.15.16 aws_dynamodb_table SSE can be updated without recreating the table.

@bflad bflad added this to the v1.33.0 milestone Aug 17, 2018
@bflad bflad merged commit 8155612 into hashicorp:master Aug 17, 2018
bflad added a commit that referenced this pull request Aug 17, 2018
@ewbankkit ewbankkit deleted the issue-5500 branch August 17, 2018 11:54
@bflad
Copy link
Contributor

bflad commented Aug 22, 2018

This has been released in version 1.33.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 3, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/dax Issues and PRs that pertain to the dax service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Encryption at rest for DAX
3 participants