Skip to content

Commit

Permalink
Merge pull request #1221 from commarla/master
Browse files Browse the repository at this point in the history
support more than 20 parameters in elasticacheGroupParameterGroup
  • Loading branch information
grubernaut authored Jul 24, 2017
2 parents 3ad9bae + 11b109f commit c89d37d
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions aws/resource_aws_elasticache_parameter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,29 @@ func resourceAwsElasticacheParameterGroupUpdate(d *schema.ResourceData, meta int
}

if len(parameters) > 0 {
modifyOpts := elasticache.ModifyCacheParameterGroupInput{
CacheParameterGroupName: aws.String(d.Get("name").(string)),
ParameterNameValues: parameters,
}

log.Printf("[DEBUG] Modify Cache Parameter Group: %#v", modifyOpts)
_, err = conn.ModifyCacheParameterGroup(&modifyOpts)
if err != nil {
return fmt.Errorf("Error modifying Cache Parameter Group: %s", err)
// We can only modify 20 parameters at a time, so walk them until
// we've got them all.
maxParams := 20
for parameters != nil {
paramsToModify := make([]*elasticache.ParameterNameValue, 0)
if len(parameters) <= maxParams {
paramsToModify, parameters = parameters[:], nil
} else {
paramsToModify, parameters = parameters[:maxParams], parameters[maxParams:]
}
modifyOpts := elasticache.ModifyCacheParameterGroupInput{
CacheParameterGroupName: aws.String(d.Get("name").(string)),
ParameterNameValues: paramsToModify,
}

log.Printf("[DEBUG] Modify Cache Parameter Group: %#v", modifyOpts)
_, err = conn.ModifyCacheParameterGroup(&modifyOpts)
if err != nil {
return fmt.Errorf("Error modifying Cache Parameter Group: %s", err)
}
}
d.SetPartial("parameter")
}
d.SetPartial("parameter")
}

d.Partial(false)
Expand Down

0 comments on commit c89d37d

Please sign in to comment.