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_dynamodb_table: Ensure ttl is properly read #2452

Merged
merged 2 commits into from
Dec 12, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
r/aws_dynamodb_table: #2452 review updates
* Add timeToLiveOutput.TimeToLiveDescription nil check
* Simplify logic to d.Set ttl
  • Loading branch information
bflad committed Dec 11, 2017
commit 394b67e867ecc92345e00907f82b6a8b6b2551b0
12 changes: 6 additions & 6 deletions aws/resource_aws_dynamodb_table.go
Original file line number Diff line number Diff line change
@@ -817,13 +817,13 @@ func flattenAwsDynamoDbTableResource(d *schema.ResourceData, meta interface{}, t
return err
}

if timeToLiveOutput.TimeToLiveDescription.AttributeName != nil {
timeToLiveList := []interface{}{}
timeToLiveSet := map[string]interface{}{
"attribute_name": *timeToLiveOutput.TimeToLiveDescription.AttributeName,
"enabled": (*timeToLiveOutput.TimeToLiveDescription.TimeToLiveStatus == dynamodb.TimeToLiveStatusEnabled),
if timeToLiveOutput.TimeToLiveDescription != nil && timeToLiveOutput.TimeToLiveDescription.AttributeName != nil {
timeToLiveList := []interface{}{
Copy link
Member

Choose a reason for hiding this comment

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

This is certainly more compact, but it's still a slice, not an array. The three dots I mentioned in my example were turning it into an array.

https://blog.golang.org/go-slices-usage-and-internals

It's certainly not a big deal though.

map[string]interface{}{
"attribute_name": *timeToLiveOutput.TimeToLiveDescription.AttributeName,
"enabled": (*timeToLiveOutput.TimeToLiveDescription.TimeToLiveStatus == dynamodb.TimeToLiveStatusEnabled),
},
}
timeToLiveList = append(timeToLiveList, timeToLiveSet)
err := d.Set("ttl", timeToLiveList)
if err != nil {
return err