make parameter group optional
This commit is contained in:
parent
a552db0c8c
commit
aad0808cc5
|
@ -43,6 +43,7 @@ func resourceAwsElasticacheCluster() *schema.Resource {
|
||||||
"parameter_group_name": &schema.Schema{
|
"parameter_group_name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"port": &schema.Schema{
|
"port": &schema.Schema{
|
||||||
|
@ -120,7 +121,6 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{
|
||||||
subnetGroupName := d.Get("subnet_group_name").(string)
|
subnetGroupName := d.Get("subnet_group_name").(string)
|
||||||
securityNameSet := d.Get("security_group_names").(*schema.Set)
|
securityNameSet := d.Get("security_group_names").(*schema.Set)
|
||||||
securityIdSet := d.Get("security_group_ids").(*schema.Set)
|
securityIdSet := d.Get("security_group_ids").(*schema.Set)
|
||||||
paramGroupName := d.Get("parameter_group_name").(string) // default.memcached1.4
|
|
||||||
|
|
||||||
securityNames := expandStringList(securityNameSet.List())
|
securityNames := expandStringList(securityNameSet.List())
|
||||||
securityIds := expandStringList(securityIdSet.List())
|
securityIds := expandStringList(securityIdSet.List())
|
||||||
|
@ -135,7 +135,11 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{
|
||||||
CacheSubnetGroupName: aws.String(subnetGroupName),
|
CacheSubnetGroupName: aws.String(subnetGroupName),
|
||||||
CacheSecurityGroupNames: securityNames,
|
CacheSecurityGroupNames: securityNames,
|
||||||
SecurityGroupIDs: securityIds,
|
SecurityGroupIDs: securityIds,
|
||||||
CacheParameterGroupName: aws.String(paramGroupName),
|
}
|
||||||
|
|
||||||
|
// parameter groups are optional and can be defaulted by AWS
|
||||||
|
if v, ok := d.GetOk("parameter_group_name"); ok {
|
||||||
|
req.CacheParameterGroupName = aws.String(v.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := conn.CreateCacheCluster(req)
|
_, err := conn.CreateCacheCluster(req)
|
||||||
|
@ -161,14 +165,14 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{
|
||||||
|
|
||||||
d.SetId(clusterId)
|
d.SetId(clusterId)
|
||||||
|
|
||||||
return resourceAwsElasticacheClusterRead(d, meta)
|
return resourceAwsElasticacheClusterRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{}) error {
|
func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
conn := meta.(*AWSClient).elasticacheconn
|
conn := meta.(*AWSClient).elasticacheconn
|
||||||
req := &elasticache.DescribeCacheClustersInput{
|
req := &elasticache.DescribeCacheClustersInput{
|
||||||
CacheClusterID: aws.String(d.Id()),
|
CacheClusterID: aws.String(d.Id()),
|
||||||
ShowCacheNodeInfo: aws.Boolean(true),
|
ShowCacheNodeInfo: aws.Boolean(true),
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := conn.DescribeCacheClusters(req)
|
res, err := conn.DescribeCacheClusters(req)
|
||||||
|
@ -211,9 +215,9 @@ func setCacheNodeData(d *schema.ResourceData, c *elasticache.CacheCluster) error
|
||||||
return fmt.Errorf("Unexpected nil pointer in: %#v", node)
|
return fmt.Errorf("Unexpected nil pointer in: %#v", node)
|
||||||
}
|
}
|
||||||
cacheNodeData = append(cacheNodeData, map[string]interface{}{
|
cacheNodeData = append(cacheNodeData, map[string]interface{}{
|
||||||
"id": *node.CacheNodeID,
|
"id": *node.CacheNodeID,
|
||||||
"address": *node.Endpoint.Address,
|
"address": *node.Endpoint.Address,
|
||||||
"port": int(*node.Endpoint.Port),
|
"port": int(*node.Endpoint.Port),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue