diff --git a/builtin/providers/heroku/resource_heroku_app.go b/builtin/providers/heroku/resource_heroku_app.go index 05cae572f..fd59bd7d1 100644 --- a/builtin/providers/heroku/resource_heroku_app.go +++ b/builtin/providers/heroku/resource_heroku_app.go @@ -42,7 +42,7 @@ func (a *application) Update() error { func resourceHerokuApp() *schema.Resource { return &schema.Resource{ - Create: switchHerokuAppCreate, + Create: switchHerokuAppCreate, Read: resourceHerokuAppRead, Update: resourceHerokuAppUpdate, Delete: resourceHerokuAppDelete, @@ -94,21 +94,22 @@ func resourceHerokuApp() *schema.Resource { Computed: true, }, - "organization": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - }, + "organization": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } func switchHerokuAppCreate(d *schema.ResourceData, meta interface{}) error { - isOrg := d.Get("organization") - if len(isOrg.(string)) != 0 { - return resourceHerokuOrgAppCreate(d, meta) - } else { - return resourceHerokuAppCreate(d, meta) - } + isOrg := d.Get("organization") + if len(isOrg.(string)) != 0 { + return resourceHerokuOrgAppCreate(d, meta) + } else { + return resourceHerokuAppCreate(d, meta) + } } func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error { @@ -153,47 +154,47 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error { } func resourceHerokuOrgAppCreate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*heroku.Service) - // Build up our creation options - opts := heroku.OrganizationAppCreateOpts{} - if v := d.Get("organization"); v != nil { - vs := v.(string) - log.Printf("[DEBUG] App name: %s", vs) - opts.Organization = &vs - } - if v := d.Get("name"); v != nil { - vs := v.(string) - log.Printf("[DEBUG] App name: %s", vs) - opts.Name = &vs - } - if v := d.Get("region"); v != nil { - vs := v.(string) - log.Printf("[DEBUG] App region: %s", vs) - opts.Region = &vs - } - if v := d.Get("stack"); v != nil { - vs := v.(string) - log.Printf("[DEBUG] App stack: %s", vs) - opts.Stack = &vs - } + client := meta.(*heroku.Service) + // Build up our creation options + opts := heroku.OrganizationAppCreateOpts{} + if v := d.Get("organization"); v != nil { + vs := v.(string) + log.Printf("[DEBUG] App name: %s", vs) + opts.Organization = &vs + } + if v := d.Get("name"); v != nil { + vs := v.(string) + log.Printf("[DEBUG] App name: %s", vs) + opts.Name = &vs + } + if v := d.Get("region"); v != nil { + vs := v.(string) + log.Printf("[DEBUG] App region: %s", vs) + opts.Region = &vs + } + if v := d.Get("stack"); v != nil { + vs := v.(string) + log.Printf("[DEBUG] App stack: %s", vs) + opts.Stack = &vs + } - log.Printf("[DEBUG] Creating Heroku app...") - a, err := client.OrganizationAppCreate(opts) - if err != nil { - return err - } + log.Printf("[DEBUG] Creating Heroku app...") + a, err := client.OrganizationAppCreate(opts) + if err != nil { + return err + } - d.SetId(a.Name) - log.Printf("[INFO] App ID: %s", d.Id()) + d.SetId(a.Name) + log.Printf("[INFO] App ID: %s", d.Id()) - if v := d.Get("config_vars"); v != nil { - err = update_config_vars(d.Id(), client, nil, v.([]interface{})) - if err != nil { - return err - } - } + if v := d.Get("config_vars"); v != nil { + err = update_config_vars(d.Id(), client, nil, v.([]interface{})) + if err != nil { + return err + } + } - return resourceHerokuAppRead(d, meta) + return resourceHerokuAppRead(d, meta) } func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {