mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Add availability_zone parameter.
Signed-off-by: wata727 <watassbass@gmail.com>
This commit is contained in:
parent
6d1d46c47c
commit
df56ef44f7
@ -120,6 +120,10 @@ func resourceAwsElasticacheCluster() *schema.Resource {
|
|||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
},
|
},
|
||||||
|
"availability_zone": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -162,6 +166,13 @@ func resourceAwsElasticacheCluster() *schema.Resource {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"availability_zone": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
|
||||||
"tags": tagsSchema(),
|
"tags": tagsSchema(),
|
||||||
|
|
||||||
// apply_immediately is used to determine when the update modifications
|
// apply_immediately is used to determine when the update modifications
|
||||||
@ -234,6 +245,10 @@ func resourceAwsElasticacheClusterCreate(d *schema.ResourceData, meta interface{
|
|||||||
log.Printf("[DEBUG] Restoring Redis cluster from S3 snapshot: %#v", s)
|
log.Printf("[DEBUG] Restoring Redis cluster from S3 snapshot: %#v", s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v, ok := d.GetOk("availability_zone"); ok {
|
||||||
|
req.PreferredAvailabilityZone = aws.String(v.(string))
|
||||||
|
}
|
||||||
|
|
||||||
resp, err := conn.CreateCacheCluster(req)
|
resp, err := conn.CreateCacheCluster(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error creating Elasticache: %s", err)
|
return fmt.Errorf("Error creating Elasticache: %s", err)
|
||||||
@ -306,6 +321,7 @@ func resourceAwsElasticacheClusterRead(d *schema.ResourceData, meta interface{})
|
|||||||
d.Set("notification_topic_arn", c.NotificationConfiguration.TopicArn)
|
d.Set("notification_topic_arn", c.NotificationConfiguration.TopicArn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
d.Set("availability_zone", c.PreferredAvailabilityZone)
|
||||||
|
|
||||||
if err := setCacheNodeData(d, c); err != nil {
|
if err := setCacheNodeData(d, c); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -454,13 +470,14 @@ func setCacheNodeData(d *schema.ResourceData, c *elasticache.CacheCluster) error
|
|||||||
cacheNodeData := make([]map[string]interface{}, 0, len(sortedCacheNodes))
|
cacheNodeData := make([]map[string]interface{}, 0, len(sortedCacheNodes))
|
||||||
|
|
||||||
for _, node := range sortedCacheNodes {
|
for _, node := range sortedCacheNodes {
|
||||||
if node.CacheNodeId == nil || node.Endpoint == nil || node.Endpoint.Address == nil || node.Endpoint.Port == nil {
|
if node.CacheNodeId == nil || node.Endpoint == nil || node.Endpoint.Address == nil || node.Endpoint.Port == nil || node.CustomerAvailabilityZone == nil {
|
||||||
return fmt.Errorf("Unexpected nil pointer in: %s", node)
|
return fmt.Errorf("Unexpected nil pointer in: %s", 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),
|
||||||
|
"availability_zone": *node.CustomerAvailabilityZone,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,8 @@ func TestAccAWSElasticacheCluster_vpc(t *testing.T) {
|
|||||||
testAccCheckAWSElasticacheSubnetGroupExists("aws_elasticache_subnet_group.bar", &csg),
|
testAccCheckAWSElasticacheSubnetGroupExists("aws_elasticache_subnet_group.bar", &csg),
|
||||||
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
|
testAccCheckAWSElasticacheClusterExists("aws_elasticache_cluster.bar", &ec),
|
||||||
testAccCheckAWSElasticacheClusterAttributes(&ec),
|
testAccCheckAWSElasticacheClusterAttributes(&ec),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"aws_elasticache_cluster.bar", "availability_zone", "us-west-2a"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -414,6 +416,7 @@ resource "aws_elasticache_cluster" "bar" {
|
|||||||
security_group_ids = ["${aws_security_group.bar.id}"]
|
security_group_ids = ["${aws_security_group.bar.id}"]
|
||||||
parameter_group_name = "default.redis2.8"
|
parameter_group_name = "default.redis2.8"
|
||||||
notification_topic_arn = "${aws_sns_topic.topic_example.arn}"
|
notification_topic_arn = "${aws_sns_topic.topic_example.arn}"
|
||||||
|
availability_zone = "us-west-2a"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_sns_topic" "topic_example" {
|
resource "aws_sns_topic" "topic_example" {
|
||||||
|
@ -98,6 +98,8 @@ Can only be used for the Redis engine.
|
|||||||
SNS topic to send ElastiCache notifications to. Example:
|
SNS topic to send ElastiCache notifications to. Example:
|
||||||
`arn:aws:sns:us-east-1:012345678999:my_sns_topic`
|
`arn:aws:sns:us-east-1:012345678999:my_sns_topic`
|
||||||
|
|
||||||
|
* `availability_zone` - (Optional) The AZ for the cache cluster.
|
||||||
|
|
||||||
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
||||||
|
|
||||||
~> **NOTE:** Snapshotting functionality is not compatible with t2 instance types.
|
~> **NOTE:** Snapshotting functionality is not compatible with t2 instance types.
|
||||||
@ -106,7 +108,7 @@ SNS topic to send ElastiCache notifications to. Example:
|
|||||||
|
|
||||||
The following attributes are exported:
|
The following attributes are exported:
|
||||||
|
|
||||||
* `cache_nodes` - List of node objects including `id`, `address` and `port`.
|
* `cache_nodes` - List of node objects including `id`, `address`, `port` and `availability_zone`.
|
||||||
Referenceable e.g. as `${aws_elasticache_cluster.bar.cache_nodes.0.address}`
|
Referenceable e.g. as `${aws_elasticache_cluster.bar.cache_nodes.0.address}`
|
||||||
|
|
||||||
* `configuration_endpoint` - (Memcached only) The configuration endpoint to allow host discovery
|
* `configuration_endpoint` - (Memcached only) The configuration endpoint to allow host discovery
|
||||||
|
Loading…
Reference in New Issue
Block a user