mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-01 07:42:40 +00:00
Pretend to delete, no error.
This commit is contained in:
parent
9ceb644460
commit
3ab8e95ef6
|
@ -68,10 +68,6 @@ func resourceAppEngineApplication() *schema.Resource {
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
Elem: appEngineApplicationFeatureSettingsResource(),
|
Elem: appEngineApplicationFeatureSettingsResource(),
|
||||||
},
|
},
|
||||||
"ack_delete_noop": &schema.Schema{
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
"name": &schema.Schema{
|
"name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
|
@ -224,10 +220,7 @@ func resourceAppEngineApplicationUpdate(d *schema.ResourceData, meta interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceAppEngineApplicationDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceAppEngineApplicationDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
// only delete app engine applications if the user has acknowledged it does nothing
|
log.Println("[DEBUG] App Engine applications cannot be destroyed once created. The project must be deleted to delete the application.")
|
||||||
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.")
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package google
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/acctest"
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
|
@ -29,44 +28,17 @@ func TestAccAppEngineApplication_basic(t *testing.T) {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: "google_app_engine_application.acceptance",
|
ResourceName: "google_app_engine_application.acceptance",
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: true,
|
ImportStateVerify: true,
|
||||||
ImportStateVerifyIgnore: []string{"ack_delete_noop"},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccAppEngineApplication_update(pid, org),
|
Config: testAccAppEngineApplication_update(pid, org),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ResourceName: "google_app_engine_application.acceptance",
|
ResourceName: "google_app_engine_application.acceptance",
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: 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),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -85,7 +57,6 @@ resource "google_app_engine_application" "acceptance" {
|
||||||
auth_domain = "hashicorptest.com"
|
auth_domain = "hashicorptest.com"
|
||||||
location_id = "us-central"
|
location_id = "us-central"
|
||||||
serving_status = "SERVING"
|
serving_status = "SERVING"
|
||||||
ack_delete_noop = true
|
|
||||||
}`, pid, pid, org)
|
}`, pid, pid, org)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,22 +73,5 @@ resource "google_app_engine_application" "acceptance" {
|
||||||
auth_domain = "tf-test.club"
|
auth_domain = "tf-test.club"
|
||||||
location_id = "us-central"
|
location_id = "us-central"
|
||||||
serving_status = "USER_DISABLED"
|
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)
|
}`, pid, pid, org)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@ description: |-
|
||||||
Allows creation and management of an App Engine application.
|
Allows creation and management of an App Engine application.
|
||||||
|
|
||||||
~> App Engine applications cannot be deleted once they're created; you have to delete the
|
~> 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`
|
entire project to delete the application. Terraform will report the application has been
|
||||||
field to `true` to acknowledge this limitation before you can successfully delete an App Engine
|
successfully deleted; this is a limitation of Terraform, and will go away in the future.
|
||||||
application. There's no harm in leaving the `ack_delete_noop` field set to true at all times.
|
Terraform is not able to delete App Engine applications.
|
||||||
|
|
||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ resource "google_project" "my_project" {
|
||||||
resource "google_app_engine_application" "app" {
|
resource "google_app_engine_application" "app" {
|
||||||
project = "${google_project.my_project.project_id}"
|
project = "${google_project.my_project.project_id}"
|
||||||
location_id = "us-central'
|
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)
|
* `location_id` - (Required) The [location](https://cloud.google.com/appengine/docs/locations)
|
||||||
to serve the app from.
|
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.
|
* `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. Note that this can't be updated at the moment.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user