diff --git a/builtin/providers/heroku/resource_heroku_app.go b/builtin/providers/heroku/resource_heroku_app.go index 156a3be248..a225982421 100644 --- a/builtin/providers/heroku/resource_heroku_app.go +++ b/builtin/providers/heroku/resource_heroku_app.go @@ -74,6 +74,11 @@ func resourceHerokuApp() *schema.Resource { }, }, + "all_config_vars": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + }, + "git_url": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -140,16 +145,18 @@ func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error { return err } - // Only get the config vars that we care about + // Only set the config_vars that we have set in the configuration. + // The "all_config_vars" field has all of them. + configVars := make(map[string]string) care := make(map[string]struct{}) for _, v := range d.Get("config_vars").([]interface{}) { for k, _ := range v.(map[string]interface{}) { care[k] = struct{}{} } } - for k, _ := range app.Vars { + for k, v := range app.Vars { if _, ok := care[k]; !ok { - delete(app.Vars, k) + configVars[k] = v } } @@ -158,7 +165,8 @@ func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error { d.Set("region", app.App.Region.Name) d.Set("git_url", app.App.GitURL) d.Set("web_url", app.App.WebURL) - d.Set("config_vars", []map[string]string{app.Vars}) + d.Set("config_vars", []map[string]string{configVars}) + d.Set("all_config_vars", app.Vars) // We know that the hostname on heroku will be the name+herokuapp.com // You need this to do things like create DNS CNAME records diff --git a/website/source/docs/providers/heroku/r/app.html.markdown b/website/source/docs/providers/heroku/r/app.html.markdown index 22d236f638..c0de44d604 100644 --- a/website/source/docs/providers/heroku/r/app.html.markdown +++ b/website/source/docs/providers/heroku/r/app.html.markdown @@ -53,4 +53,6 @@ The following attributes are exported: at by default. * `heroku_hostname` - A hostname for the Heroku application, suitable for pointing DNS records. - +* `all_config_vars` - A map of all of the configuration variables that + exist for the app, containing both those set by Terraform and those + set externally.