Skip to content

Commit

Permalink
Merge pull request #3300 from Runscope/fix-dynamodb-gsi-bug
Browse files Browse the repository at this point in the history
provider/aws: fix bug with reading GSIs from dynamodb
  • Loading branch information
catsby committed Oct 15, 2015
2 parents aee1405 + 127c1ae commit 2f94e57
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions builtin/providers/aws/resource_aws_dynamodb_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,23 @@ func resourceAwsDynamoDbTableRead(d *schema.ResourceData, meta interface{}) erro
}
}

gsi["projection_type"] = *gsiObject.Projection.ProjectionType
gsi["non_key_attributes"] = gsiObject.Projection.NonKeyAttributes
gsi["projection_type"] = *(gsiObject.Projection.ProjectionType)

nonKeyAttrs := make([]string, 0, len(gsiObject.Projection.NonKeyAttributes))
for _, nonKeyAttr := range gsiObject.Projection.NonKeyAttributes {
nonKeyAttrs = append(nonKeyAttrs, *nonKeyAttr)
}
gsi["non_key_attributes"] = nonKeyAttrs

gsiList = append(gsiList, gsi)
log.Printf("[DEBUG] Added GSI: %s - Read: %d / Write: %d", gsi["name"], gsi["read_capacity"], gsi["write_capacity"])
}

d.Set("global_secondary_index", gsiList)
err = d.Set("global_secondary_index", gsiList)
if err != nil {
return err
}

d.Set("arn", table.TableArn)

return nil
Expand Down

0 comments on commit 2f94e57

Please sign in to comment.