Skip to content

Commit d8cc32b

Browse files
committed
providers/heroku: all_config_vars for reading
1 parent 0a03ff9 commit d8cc32b

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

builtin/providers/heroku/resource_heroku_app.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ func resourceHerokuApp() *schema.Resource {
7474
},
7575
},
7676

77+
"all_config_vars": &schema.Schema{
78+
Type: schema.TypeMap,
79+
Computed: true,
80+
},
81+
7782
"git_url": &schema.Schema{
7883
Type: schema.TypeString,
7984
Computed: true,
@@ -140,16 +145,18 @@ func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {
140145
return err
141146
}
142147

143-
// Only get the config vars that we care about
148+
// Only set the config_vars that we have set in the configuration.
149+
// The "all_config_vars" field has all of them.
150+
configVars := make(map[string]string)
144151
care := make(map[string]struct{})
145152
for _, v := range d.Get("config_vars").([]interface{}) {
146153
for k, _ := range v.(map[string]interface{}) {
147154
care[k] = struct{}{}
148155
}
149156
}
150-
for k, _ := range app.Vars {
157+
for k, v := range app.Vars {
151158
if _, ok := care[k]; !ok {
152-
delete(app.Vars, k)
159+
configVars[k] = v
153160
}
154161
}
155162

@@ -158,7 +165,8 @@ func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {
158165
d.Set("region", app.App.Region.Name)
159166
d.Set("git_url", app.App.GitURL)
160167
d.Set("web_url", app.App.WebURL)
161-
d.Set("config_vars", []map[string]string{app.Vars})
168+
d.Set("config_vars", []map[string]string{configVars})
169+
d.Set("all_config_vars", app.Vars)
162170

163171
// We know that the hostname on heroku will be the name+herokuapp.com
164172
// You need this to do things like create DNS CNAME records

website/source/docs/providers/heroku/r/app.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@ The following attributes are exported:
5353
at by default.
5454
* `heroku_hostname` - A hostname for the Heroku application, suitable
5555
for pointing DNS records.
56-
56+
* `all_config_vars` - A map of all of the configuration variables that
57+
exist for the app, containing both those set by Terraform and those
58+
set externally.

0 commit comments

Comments
 (0)