Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export connection_name on sql instance resource #406

Merged
merged 1 commit into from
Sep 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions google/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ func resourceSqlDatabaseInstance() *schema.Resource {
},
},

"connection_name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},

"database_version": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -659,6 +664,7 @@ func resourceSqlDatabaseInstanceRead(d *schema.ResourceData, meta interface{}) e
d.Set("name", instance.Name)
d.Set("region", instance.Region)
d.Set("database_version", instance.DatabaseVersion)
d.Set("connection_name", instance.ConnectionName)

if err := d.Set("settings", flattenSettings(instance.Settings)); err != nil {
log.Printf("[WARN] Failed to set SQL Database Instance Settings")
Expand Down
6 changes: 6 additions & 0 deletions google/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,12 @@ func testAccCheckGoogleSqlDatabaseInstanceEquals(n string,
}
}

server = instance.ConnectionName
local = attributes["connection_name"]
if server != local {
return fmt.Errorf("Error connection_name mismatch. (%s, %s)", server, local)
}

return nil
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/sql_database_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The following arguments are supported:

- - -

* `connection_name` - (Optional) The connection name of the instance to be used in connection strings.

* `database_version` - (Optional, Default: `MYSQL_5_6`) The MySQL version to
use. Can be `MYSQL_5_6`, `MYSQL_5_7` or `POSTGRES_9_6` for second-generation
instances, or `MYSQL_5_5` or `MYSQL_5_6` for first-generation instances.
Expand Down