Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allowed_deletion Config Option to resourceHerokuApp #391

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:

jobs:
goreleaser:
runs-on: pub-hk-ubuntu-24.04-ip
permissions:
contents: write
runs-on: ubuntu-latest
steps:
-
name: Checkout
Expand Down
12 changes: 11 additions & 1 deletion heroku/resource_heroku_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ func resourceHerokuApp() *schema.Resource {
ForceNew: true,
},

"allow_deletion": {
Type: schema.TypeBool,
Optional: true,
},

"buildpacks": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -562,8 +567,13 @@ func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {

func resourceHerokuAppDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*Config).Api

log.Printf("[INFO] Deleting App: %s", d.Id())

canBeDeleted := d.Get("allow_deletion").(bool)
if !canBeDeleted {
return fmt.Errorf("error deleting App: %s", "allow_deletion is false")
}

_, err := client.AppDelete(context.TODO(), d.Id())
if err != nil {
return fmt.Errorf("error deleting App: %s", err)
Expand Down
2 changes: 2 additions & 0 deletions heroku/resource_heroku_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ func testAccCheckHerokuAppConfig_basic(appName string) string {
resource "heroku_app" "foobar" {
name = "%s"
region = "us"
allow_deletion = true

config_vars = {
FOO = "bar"
Expand Down Expand Up @@ -981,6 +982,7 @@ func testAccCheckHerokuAppConfig_locked(appName, org, locked string) string {
resource "heroku_app" "foobar" {
name = "%s"
region = "us"
allow_deletion = true

organization {
name = "%s"
Expand Down