Skip to content

Commit cea6850

Browse files
committed
Merge branch 'elasticache-cluster-import' of https://github.com/AMeng/terraform into AMeng-elasticache-cluster-import
2 parents a8a1f6d + 01cfeb8 commit cea6850

4 files changed

Lines changed: 46 additions & 1 deletion

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package aws
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform/helper/resource"
8+
)
9+
10+
func TestAccAWSElasticacheCluster_importBasic(t *testing.T) {
11+
oldvar := os.Getenv("AWS_DEFAULT_REGION")
12+
os.Setenv("AWS_DEFAULT_REGION", "us-east-1")
13+
defer os.Setenv("AWS_DEFAULT_REGION", oldvar)
14+
15+
resourceName := "aws_elasticache_cluster.bar"
16+
17+
resource.Test(t, resource.TestCase{
18+
PreCheck: func() { testAccPreCheck(t) },
19+
Providers: testAccProviders,
20+
CheckDestroy: testAccCheckAWSElasticacheClusterDestroy,
21+
Steps: []resource.TestStep{
22+
resource.TestStep{
23+
Config: testAccAWSElasticacheClusterConfig,
24+
},
25+
26+
resource.TestStep{
27+
ResourceName: resourceName,
28+
ImportState: true,
29+
ImportStateVerify: true,
30+
},
31+
},
32+
})
33+
}

builtin/providers/aws/resource_aws_elasticache_cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ func resourceAwsElasticacheCluster() *schema.Resource {
210210
Read: resourceAwsElasticacheClusterRead,
211211
Update: resourceAwsElasticacheClusterUpdate,
212212
Delete: resourceAwsElasticacheClusterDelete,
213+
Importer: &schema.ResourceImporter{
214+
State: schema.ImportStatePassthrough,
215+
},
213216

214217
Schema: resourceSchema,
215218
}

website/source/docs/import/importability.html.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ To make a resource importable, please see the
4848
* aws_eip
4949
* aws_elastic_beanstalk_application
5050
* aws_elastic_beanstalk_environment
51+
* aws_elasticache_cluster
5152
* aws_elasticache_parameter_group
5253
* aws_elasticache_subnet_group
5354
* aws_elb
@@ -149,4 +150,3 @@ To make a resource importable, please see the
149150
* triton_key
150151
* triton_machine
151152
* triton_vlan
152-

website/source/docs/providers/aws/r/elasticache_cluster.html.markdown

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,12 @@ The following attributes are exported:
122122

123123
[1]: https://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_ModifyCacheCluster.html
124124
[2]: https://docs.aws.amazon.com/fr_fr/AmazonElastiCache/latest/UserGuide/Clusters.Modify.html
125+
126+
127+
## Import
128+
129+
ElastiCache Clusters can be imported using the `cluster_id`, e.g.
130+
131+
```
132+
$ terraform import aws_elasticache_cluster.my_cluster my_cluster
133+
```

0 commit comments

Comments
 (0)