Skip to content

Commit

Permalink
Adjust for Dana's comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
paddycarver committed Oct 2, 2018
1 parent 3ab8e95 commit 691ae99
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
28 changes: 17 additions & 11 deletions google/resource_app_engine_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"

"github.com/hashicorp/terraform/helper/customdiff"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
appengine "google.golang.org/api/appengine/v1"
Expand All @@ -20,10 +21,15 @@ func resourceAppEngineApplication() *schema.Resource {
State: schema.ImportStatePassthrough,
},

CustomizeDiff: customdiff.All(
appEngineApplicationLocationIDCustomizeDiff,
),

Schema: map[string]*schema.Schema{
"project": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validateProjectID(),
},
Expand Down Expand Up @@ -127,6 +133,14 @@ func appEngineApplicationFeatureSettingsResource() *schema.Resource {
}
}

func appEngineApplicationLocationIDCustomizeDiff(d *schema.ResourceDiff, meta interface{}) error {
old, new := d.GetChange("location_id")
if old != "" && old != new {
return fmt.Errorf("Cannot change location_id once the resource is created.")
}
return nil
}

func resourceAppEngineApplicationCreate(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

Expand All @@ -138,7 +152,6 @@ func resourceAppEngineApplicationCreate(d *schema.ResourceData, meta interface{}
if err != nil {
return err
}
app.Id = project
log.Printf("[DEBUG] Creating App Engine App")
op, err := config.clientAppEngine.Apps.Create(app).Do()
if err != nil {
Expand All @@ -162,12 +175,8 @@ func resourceAppEngineApplicationRead(d *schema.ResourceData, meta interface{})
pid := d.Id()

app, err := config.clientAppEngine.Apps.Get(pid).Do()
if err != nil && !isGoogleApiErrorWithCode(err, 404) {
return fmt.Errorf("Error retrieving App Engine application %q: %s", pid, err.Error())
} else if isGoogleApiErrorWithCode(err, 404) {
log.Printf("[WARN] App Engine application %q not found, removing from state", pid)
d.SetId("")
return nil
if err != nil {
return handleNotFoundError(err, d, fmt.Sprintf("App Engine Application %q", pid))
}
d.Set("auth_domain", app.AuthDomain)
d.Set("code_bucket", app.CodeBucket)
Expand Down Expand Up @@ -220,7 +229,7 @@ func resourceAppEngineApplicationUpdate(d *schema.ResourceData, meta interface{}
}

func resourceAppEngineApplicationDelete(d *schema.ResourceData, meta interface{}) error {
log.Println("[DEBUG] App Engine applications cannot be destroyed once created. The project must be deleted to delete the application.")
log.Println("[WARN] App Engine applications cannot be destroyed once created. The project must be deleted to delete the application.")
return nil
}

Expand All @@ -245,9 +254,6 @@ func expandAppEngineApplicationFeatureSettings(d *schema.ResourceData) (*appengi
if len(blocks) < 1 {
return nil, nil
}
if len(blocks) > 1 {
return nil, fmt.Errorf("only one feature_settings block may be defined per app")
}
return &appengine.FeatureSettings{
SplitHealthChecks: d.Get("feature_settings.0.split_health_checks").(bool),
// force send SplitHealthChecks, so if it's set to false it still gets disabled
Expand Down
10 changes: 5 additions & 5 deletions website/docs/r/app_engine_application.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |-
Allows management of an App Engine application.
---

# google\_app_engine_application
# google_app_engine_application

Allows creation and management of an App Engine application.

Expand All @@ -19,14 +19,14 @@ Allows creation and management of an App Engine application.

```hcl
resource "google_project" "my_project" {
name = "My Project"
name = "My Project"
project_id = "your-project-id"
org_id = "1234567"
}
resource "google_app_engine_application" "app" {
project = "${google_project.my_project.project_id}"
location_id = "us-central'
project = "${google_project.my_project.project_id}"
location_id = "us-central'
}
```

Expand All @@ -39,7 +39,7 @@ The following arguments are supported:

* `auth_domain` - (Optional) The domain to authenticate users with when using App Engine's User API.

* `serving_status` - (Optional) The serving status of the app. Note that this can't be updated at the moment.
* `serving_status` - (Optional) The serving status of the app.

* `feature_settings` - (Optional) A block of optional settings to configure specific App Engine features:

Expand Down

0 comments on commit 691ae99

Please sign in to comment.