Skip to content

Commit

Permalink
Merge pull request #127 from terraform-providers/jstump-app-id
Browse files Browse the repository at this point in the history
Export the UUID of the Heroku app.
  • Loading branch information
davidji99 authored Oct 4, 2018
2 parents e3b7d16 + 069aeb7 commit c61319d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions heroku/resource_heroku_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type herokuApplication struct {
OrganizationName string
Locked bool
Acm bool
ID string
}

// type application is used to store all the details of a heroku app
Expand Down Expand Up @@ -57,12 +58,16 @@ func (a *application) Update() error {
a.App.GitURL = app.GitURL
a.App.WebURL = app.WebURL
a.App.Acm = app.Acm
a.App.ID = app.ID

if app.InternalRouting != nil {
a.App.InternalRouting = *app.InternalRouting
}

if app.Space != nil {
a.App.Space = app.Space.Name
}

if app.Organization != nil {
a.App.OrganizationName = app.Organization.Name
} else {
Expand Down Expand Up @@ -131,6 +136,12 @@ func resourceHerokuApp() *schema.Resource {
Computed: true,
},

"uuid": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"internal_routing": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -377,6 +388,7 @@ func setAppDetails(d *schema.ResourceData, app *application) (err error) {
d.Set("git_url", app.App.GitURL)
d.Set("web_url", app.App.WebURL)
d.Set("acm", app.App.Acm)
d.Set("uuid", app.App.ID)
d.Set("heroku_hostname", fmt.Sprintf("%s.herokuapp.com", app.App.Name))
return 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 @@ -28,6 +28,8 @@ func TestAccHerokuApp_Basic(t *testing.T) {
testAccCheckHerokuAppAttributes(&app, appName, "heroku-16"),
resource.TestCheckResourceAttr(
"heroku_app.foobar", "name", appName),
resource.TestCheckResourceAttrSet(
"heroku_app.foobar", "uuid"),
resource.TestCheckResourceAttr(
"heroku_app.foobar", "config_vars.0.FOO", "bar"),
resource.TestCheckResourceAttr(
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The following attributes are exported:
* `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.
* `uuid` - The unique UUID of the Heroku app. **NOTE:** Use this for `null_resource` triggers.

## Import

Expand Down

0 comments on commit c61319d

Please sign in to comment.