Skip to content

Commit 7054fdf

Browse files
author
Paddy
committed
providers/google: make projects importable.
This change doesn't make much sense now, as projects are read-only anyways, so there's not a lot that importing really does for you--you can already reference pre-existing projects just by defining them in your config. But as we discussed hashicorp#10425, this change made more and more sense. In a world where projects can be created, we can no longer reference pre-existing projects just by defining them in config. We get that ability back by making projects importable.
1 parent 973a46c commit 7054fdf

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package google
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/hashicorp/terraform/helper/resource"
8+
)
9+
10+
func TestAccGoogleProject_importBasic(t *testing.T) {
11+
resourceName := "google_project.acceptance"
12+
conf := fmt.Sprintf(testAccGoogleProject_basic, projectId)
13+
14+
resource.Test(t, resource.TestCase{
15+
PreCheck: func() { testAccPreCheck(t) },
16+
Providers: testAccProviders,
17+
Steps: []resource.TestStep{
18+
resource.TestStep{
19+
Config: conf,
20+
},
21+
22+
resource.TestStep{
23+
ResourceName: resourceName,
24+
ImportState: true,
25+
ImportStateVerify: true,
26+
},
27+
},
28+
})
29+
}

builtin/providers/google/resource_google_project.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ func resourceGoogleProject() *schema.Resource {
2929
Read: resourceGoogleProjectRead,
3030
Update: resourceGoogleProjectUpdate,
3131
Delete: resourceGoogleProjectDelete,
32+
Importer: &schema.ResourceImporter{
33+
State: schema.ImportStatePassthrough,
34+
},
3235

3336
Schema: map[string]*schema.Schema{
3437
"id": &schema.Schema{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ To make a resource importable, please see the
135135
* google_compute_instance_group_manager
136136
* google_compute_instance_template
137137
* google_compute_target_pool
138+
* google_project
138139

139140
### OpenStack
140141

0 commit comments

Comments
 (0)