Pretend to delete, no error.

This commit is contained in:
Paddy Carver 2018-10-02 14:15:31 -07:00
parent 9ceb644460
commit 3ab8e95ef6
3 changed files with 10 additions and 68 deletions

View File

@ -68,10 +68,6 @@ func resourceAppEngineApplication() *schema.Resource {
MaxItems: 1,
Elem: appEngineApplicationFeatureSettingsResource(),
},
"ack_delete_noop": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
},
"name": &schema.Schema{
Type: schema.TypeString,
Computed: true,
@ -224,10 +220,7 @@ func resourceAppEngineApplicationUpdate(d *schema.ResourceData, meta interface{}
}
func resourceAppEngineApplicationDelete(d *schema.ResourceData, meta interface{}) error {
// only delete app engine applications if the user has acknowledged it does nothing
if !d.Get("ack_delete_noop").(bool) {
return fmt.Errorf("App Engine applications cannot be destroyed once created. The project must be deleted to delete the application. To acknowledge this limitation and let Terraform think it deleted your application--even though it won't--set the `ack_delete_noop` field to true, and this error will go away.")
}
log.Println("[DEBUG] App Engine applications cannot be destroyed once created. The project must be deleted to delete the application.")
return nil
}

View File

@ -2,7 +2,6 @@ package google
import (
"fmt"
"regexp"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
@ -29,44 +28,17 @@ func TestAccAppEngineApplication_basic(t *testing.T) {
),
},
{
ResourceName: "google_app_engine_application.acceptance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"ack_delete_noop"},
ResourceName: "google_app_engine_application.acceptance",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccAppEngineApplication_update(pid, org),
},
{
ResourceName: "google_app_engine_application.acceptance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"ack_delete_noop"},
},
},
})
}
func TestAccAppEngineApplication_delete(t *testing.T) {
t.Parallel()
org := getTestOrgFromEnv(t)
pid := acctest.RandomWithPrefix("tf-test")
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccAppEngineApplication_noDelete(pid, org),
},
{
Config: testAccAppEngineApplication_noDelete(pid, org),
Destroy: true,
ExpectError: regexp.MustCompile("set the `ack_delete_noop` field to true"),
},
{
// revert back to the same config, but with delete set, so the project can get deleted
Config: testAccAppEngineApplication_basic(pid, org),
ResourceName: "google_app_engine_application.acceptance",
ImportState: true,
ImportStateVerify: true,
},
},
})
@ -85,7 +57,6 @@ resource "google_app_engine_application" "acceptance" {
auth_domain = "hashicorptest.com"
location_id = "us-central"
serving_status = "SERVING"
ack_delete_noop = true
}`, pid, pid, org)
}
@ -102,22 +73,5 @@ resource "google_app_engine_application" "acceptance" {
auth_domain = "tf-test.club"
location_id = "us-central"
serving_status = "USER_DISABLED"
ack_delete_noop = true
}`, pid, pid, org)
}
func testAccAppEngineApplication_noDelete(pid, org string) string {
return fmt.Sprintf(`
resource "google_project" "acceptance" {
project_id = "%s"
name = "%s"
org_id = "%s"
}
resource "google_app_engine_application" "acceptance" {
project = "${google_project.acceptance.project_id}"
auth_domain = "hashicorptest.com"
location_id = "us-central"
serving_status = "SERVING"
}`, pid, pid, org)
}

View File

@ -11,9 +11,9 @@ description: |-
Allows creation and management of an App Engine application.
~> App Engine applications cannot be deleted once they're created; you have to delete the
entire project to delete the application. Terraform will force you to set the `ack_delete_noop`
field to `true` to acknowledge this limitation before you can successfully delete an App Engine
application. There's no harm in leaving the `ack_delete_noop` field set to true at all times.
entire project to delete the application. Terraform will report the application has been
successfully deleted; this is a limitation of Terraform, and will go away in the future.
Terraform is not able to delete App Engine applications.
## Example Usage
@ -27,7 +27,6 @@ resource "google_project" "my_project" {
resource "google_app_engine_application" "app" {
project = "${google_project.my_project.project_id}"
location_id = "us-central'
ack_delete_noop = true
}
```
@ -38,10 +37,6 @@ The following arguments are supported:
* `location_id` - (Required) The [location](https://cloud.google.com/appengine/docs/locations)
to serve the app from.
* `ack_delete_noop` - (Optional) Set to true to allow Terraform to "delete" your application without error.
Has no bearing except to indicate that you're aware that when Terraform says it deletes an application,
the application has not actually been deleted. To delete an application, the entire project must be deleted.
* `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.