From 07f89e2728cbb9b5ea6bd5c918d7514562925f7c Mon Sep 17 00:00:00 2001 From: Jeff Theriault Date: Sat, 27 May 2017 23:47:55 -0600 Subject: [PATCH] Export RDS instance and cluster resource id (#14882) --- builtin/providers/aws/resource_aws_db_instance.go | 6 ++++++ builtin/providers/aws/resource_aws_db_instance_test.go | 2 ++ builtin/providers/aws/resource_aws_rds_cluster.go | 6 ++++++ builtin/providers/aws/resource_aws_rds_cluster_test.go | 2 ++ .../source/docs/providers/aws/r/db_instance.html.markdown | 1 + .../source/docs/providers/aws/r/rds_cluster.html.markdown | 1 + 6 files changed, 18 insertions(+) diff --git a/builtin/providers/aws/resource_aws_db_instance.go b/builtin/providers/aws/resource_aws_db_instance.go index 8d4790289..05621fb5d 100644 --- a/builtin/providers/aws/resource_aws_db_instance.go +++ b/builtin/providers/aws/resource_aws_db_instance.go @@ -340,6 +340,11 @@ func resourceAwsDbInstance() *schema.Resource { Optional: true, }, + "resource_id": { + Type: schema.TypeString, + Computed: true, + }, + "tags": tagsSchema(), }, } @@ -701,6 +706,7 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error { d.Set("name", v.DBName) d.Set("identifier", v.DBInstanceIdentifier) + d.Set("resource_id", v.DbiResourceId) d.Set("username", v.MasterUsername) d.Set("engine", v.Engine) d.Set("engine_version", v.EngineVersion) diff --git a/builtin/providers/aws/resource_aws_db_instance_test.go b/builtin/providers/aws/resource_aws_db_instance_test.go index dbd6ff660..22ee5df10 100644 --- a/builtin/providers/aws/resource_aws_db_instance_test.go +++ b/builtin/providers/aws/resource_aws_db_instance_test.go @@ -47,6 +47,8 @@ func TestAccAWSDBInstance_basic(t *testing.T) { resource.TestCheckResourceAttr( "aws_db_instance.bar", "parameter_group_name", "default.mysql5.6"), resource.TestCheckResourceAttrSet("aws_db_instance.bar", "hosted_zone_id"), + resource.TestCheckResourceAttrSet( + "aws_db_instance.bar", "resource_id"), ), }, }, diff --git a/builtin/providers/aws/resource_aws_rds_cluster.go b/builtin/providers/aws/resource_aws_rds_cluster.go index eb01b9969..8fc72ce5b 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster.go +++ b/builtin/providers/aws/resource_aws_rds_cluster.go @@ -227,6 +227,11 @@ func resourceAwsRDSCluster() *schema.Resource { Optional: true, }, + "cluster_resource_id": { + Type: schema.TypeString, + Computed: true, + }, + "tags": tagsSchema(), }, } @@ -523,6 +528,7 @@ func resourceAwsRDSClusterRead(d *schema.ResourceData, meta interface{}) error { } d.Set("cluster_identifier", dbc.DBClusterIdentifier) + d.Set("cluster_resource_id", dbc.DbClusterResourceId) d.Set("db_subnet_group_name", dbc.DBSubnetGroup) d.Set("db_cluster_parameter_group_name", dbc.DBClusterParameterGroup) d.Set("endpoint", dbc.Endpoint) diff --git a/builtin/providers/aws/resource_aws_rds_cluster_test.go b/builtin/providers/aws/resource_aws_rds_cluster_test.go index 6adedd0e7..5023bd84a 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster_test.go +++ b/builtin/providers/aws/resource_aws_rds_cluster_test.go @@ -34,6 +34,8 @@ func TestAccAWSRDSCluster_basic(t *testing.T) { "aws_rds_cluster.default", "db_cluster_parameter_group_name", "default.aurora5.6"), resource.TestCheckResourceAttrSet( "aws_rds_cluster.default", "reader_endpoint"), + resource.TestCheckResourceAttrSet( + "aws_rds_cluster.default", "cluster_resource_id"), ), }, }, diff --git a/website/source/docs/providers/aws/r/db_instance.html.markdown b/website/source/docs/providers/aws/r/db_instance.html.markdown index 880dbe854..2fdb3ecc6 100644 --- a/website/source/docs/providers/aws/r/db_instance.html.markdown +++ b/website/source/docs/providers/aws/r/db_instance.html.markdown @@ -126,6 +126,7 @@ standalone database. The following attributes are exported: * `id` - The RDS instance ID. +* `resource_id` - The RDS Resource ID of this instance. * `address` - The address of the RDS instance. * `arn` - The ARN of the RDS instance. * `allocated_storage` - The amount of allocated storage diff --git a/website/source/docs/providers/aws/r/rds_cluster.html.markdown b/website/source/docs/providers/aws/r/rds_cluster.html.markdown index a3f1f599f..32aeb64cd 100644 --- a/website/source/docs/providers/aws/r/rds_cluster.html.markdown +++ b/website/source/docs/providers/aws/r/rds_cluster.html.markdown @@ -91,6 +91,7 @@ The following attributes are exported: * `id` - The RDS Cluster Identifier * `cluster_identifier` - The RDS Cluster Identifier +* `cluster_resource_id` - The RDS Cluster Resource ID * `cluster_members` – List of RDS Instances that are a part of this cluster * `allocated_storage` - The amount of allocated storage * `availability_zones` - The availability zone of the instance