Skip to content

Commit

Permalink
Convert old import formats (using non-/) to use /.
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-henderson committed Nov 12, 2019
1 parent 7ed0a38 commit 6d5f6f6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func resourceFolderOrgPolicyImporter(d *schema.ResourceData, meta interface{}) (
config := meta.(*Config)

if err := parseImportId([]string{
"folders/(?P<folder>[^/]+):constraints/(?P<constraint>[^/]+)",
"(?P<folder>[^/]+):(?P<constraint>[^/]+)"},
"folders/(?P<folder>[^/]+)/constraints/(?P<constraint>[^/]+)",
"(?P<folder>[^/]+)/(?P<constraint>[^/]+)"},
d, config); err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ func resourceGoogleOrganizationPolicyDelete(d *schema.ResourceData, meta interfa
}

func resourceGoogleOrganizationPolicyImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
parts := strings.Split(d.Id(), ":")
parts := strings.SplitN(d.Id(), "/", 2)
if len(parts) != 2 {
return nil, fmt.Errorf("Invalid id format. Expecting {org_id}:{constraint}, got '%s' instead.", d.Id())
return nil, fmt.Errorf("Invalid id format. Expecting {org_id}/{constraint}, got '%s' instead.", d.Id())
}

d.Set("org_id", parts[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,5 @@ exported:
BigQuery tables can be imported using the `project`, `dataset_id`, and `table_id`, e.g.

```
$ terraform import google_bigquery_table.default gcp-project:foo.bar
$ terraform import google_bigquery_table.default gcp-project/foo/bar
```
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ exported:
Folder organization policies can be imported using any of the follow formats:

```
$ terraform import google_folder_organization_policy.policy folders/folder-1234:constraints/serviceuser.services
$ terraform import google_folder_organization_policy.policy folder-1234:serviceuser.services
$ terraform import google_folder_organization_policy.policy folders/folder-1234/constraints/serviceuser.services
$ terraform import google_folder_organization_policy.policy folder-1234/serviceuser.services
```
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,7 @@ exported:
Organization Policies can be imported using the `org_id` and the `constraint`, e.g.

```
$ terraform import google_organization_policy.services_policy 123456789:constraints/serviceuser.services
$ terraform import google_organization_policy.services_policy 123456789/constraints/serviceuser.services
```

It is all right if the constraint contains a slash, as in the example above.

0 comments on commit 6d5f6f6

Please sign in to comment.