Skip to content

Commit

Permalink
elasticache replication group: import paths and added primary endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Aug 6, 2015
1 parent ce94a02 commit 669c4ad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
39 changes: 23 additions & 16 deletions builtin/providers/aws/resource_aws_elasticache_replication_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"log"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/service/elasticache"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticache"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)
Expand Down Expand Up @@ -77,6 +77,10 @@ func resourceAwsElasticacheReplicationGroup() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"primary_endpoint": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand All @@ -93,20 +97,22 @@ func resourceAwsElasticacheReplicationGroupCreate(d *schema.ResourceData, meta i
engineVersion := d.Get("engine_version").(string)
securityNameSet := d.Get("security_group_names").(*schema.Set)
securityIdSet := d.Get("security_group_ids").(*schema.Set)
subnetGroupName := d.Get("subnet_group_name").(string)

securityNames := expandStringList(securityNameSet.List())
securityIds := expandStringList(securityIdSet.List())

req := &elasticache.CreateReplicationGroupInput{
ReplicationGroupID: aws.String(replicationGroupId),
ReplicationGroupDescription: aws.String(description),
CacheNodeType: aws.String(cacheNodeType),
AutomaticFailoverEnabled: aws.Boolean(automaticFailover),
NumCacheClusters: aws.Long(int64(numCacheClusters)),
Engine: aws.String(engine),
EngineVersion: aws.String(engineVersion),
CacheSecurityGroupNames: securityNames,
SecurityGroupIDs: securityIds,
ReplicationGroupID: aws.String(replicationGroupId),
ReplicationGroupDescription: aws.String(description),
CacheNodeType: aws.String(cacheNodeType),
AutomaticFailoverEnabled: aws.Bool(automaticFailover),
NumCacheClusters: aws.Int64(int64(numCacheClusters)),
Engine: aws.String(engine),
CacheSubnetGroupName: aws.String(subnetGroupName),
EngineVersion: aws.String(engineVersion),
CacheSecurityGroupNames: securityNames,
SecurityGroupIDs: securityIds,
}

if v, ok := d.GetOk("parameter_group_name"); ok {
Expand All @@ -123,7 +129,7 @@ func resourceAwsElasticacheReplicationGroupCreate(d *schema.ResourceData, meta i
Pending: pending,
Target: "available",
Refresh: ReplicationGroupStateRefreshFunc(conn, d.Id(), "available", pending),
Timeout: 15 * time.Minute,
Timeout: 60 * time.Minute,
Delay: 20 * time.Second,
MinTimeout: 5 * time.Second,
}
Expand Down Expand Up @@ -164,21 +170,22 @@ func resourceAwsElasticacheReplicationGroupRead(d *schema.ResourceData, meta int
d.Set("automatic_failover", c.AutomaticFailover)
d.Set("num_cache_clusters", len(c.MemberClusters))
}
d.Set("primary_endpoint", res.ReplicationGroups[0].NodeGroups[0].PrimaryEndpoint.Address)

return nil
}

func resourceAwsElasticacheReplicationGroupUpdate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).elasticacheconn

req := &elasticache.ModifyReplicationGroupInput {
ApplyImmediately: aws.Boolean(true),
req := &elasticache.ModifyReplicationGroupInput{
ApplyImmediately: aws.Bool(true),
ReplicationGroupID: aws.String(d.Id()),
}

if d.HasChange("automatic_failover") {
automaticFailover := d.Get("automatic_failover").(bool)
req.AutomaticFailoverEnabled = aws.Boolean(automaticFailover)
req.AutomaticFailoverEnabled = aws.Bool(automaticFailover)
}

if d.HasChange("description") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"log"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/service/elasticache"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elasticache"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand Down

0 comments on commit 669c4ad

Please sign in to comment.