mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-03 01:01:06 +00:00
allow cross-project imports for sql user (#2632)
<!-- This change is generated by MagicModules. --> /cc @danawillow
This commit is contained in:
parent
89b95575ea
commit
5fea92fadf
@ -227,15 +227,17 @@ func resourceSqlUserDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
func resourceSqlUserImporter(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||
parts := strings.Split(d.Id(), "/")
|
||||
|
||||
if len(parts) == 2 {
|
||||
d.Set("instance", parts[0])
|
||||
d.Set("name", parts[1])
|
||||
} else if len(parts) == 3 {
|
||||
d.Set("instance", parts[0])
|
||||
d.Set("host", parts[1])
|
||||
if len(parts) == 3 {
|
||||
d.Set("project", parts[0])
|
||||
d.Set("instance", parts[1])
|
||||
d.Set("name", parts[2])
|
||||
} else if len(parts) == 4 {
|
||||
d.Set("project", parts[0])
|
||||
d.Set("instance", parts[1])
|
||||
d.Set("host", parts[2])
|
||||
d.Set("name", parts[3])
|
||||
} else {
|
||||
return nil, fmt.Errorf("Invalid specifier. Expecting {instance}/{name} for postgres instance and {instance}/{host}/{name} for MySQL instance")
|
||||
return nil, fmt.Errorf("Invalid specifier. Expecting {project}/{instance}/{name} for postgres instance and {project}/{instance}/{host}/{name} for MySQL instance")
|
||||
}
|
||||
|
||||
return []*schema.ResourceData{d}, nil
|
||||
|
@ -62,14 +62,14 @@ Only the arguments listed above are exposed as attributes.
|
||||
|
||||
## Import
|
||||
|
||||
SQL users for MySQL databases can be imported using the `instance`, `host` and `name`, e.g.
|
||||
SQL users for MySQL databases can be imported using the `project`, `instance`, `host` and `name`, e.g.
|
||||
|
||||
```
|
||||
$ terraform import google_sql_user.users master-instance/my-domain.com/me
|
||||
$ terraform import google_sql_user.users my-project/master-instance/my-domain.com/me
|
||||
```
|
||||
|
||||
SQL users for PostgreSQL databases can be imported using the `instance` and `name`, e.g.
|
||||
SQL users for PostgreSQL databases can be imported using the `project`, `instance` and `name`, e.g.
|
||||
|
||||
```
|
||||
$ terraform import google_sql_user.users master-instance/me
|
||||
$ terraform import google_sql_user.users my-project/master-instance/me
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user