Skip to content

Commit

Permalink
Set Load Balancer internal/external per process instead of per applic…
Browse files Browse the repository at this point in the history
…ation

Introduces EMPIRE_X_EXPOSURE which needs to be either `internal` or `internet-facing` (kept AWS terminology here).

If that environment variable is not set, we fallback to the default selection via application (where you use `domain-add`).

Fixes remind101#1076
  • Loading branch information
iserko committed Jun 13, 2017
1 parent df1b2bd commit 7d665c6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ build
*.dump
*.key
*.cert
\#*\#
.\#*
9 changes: 9 additions & 0 deletions procfile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ This allows you to set process specific environment variables. If these are set
environment:
EMPIRE_X_LOAD_BALANCER_TYPE: "alb"
```

We support the following environment variables per process:

Name | Default value | Available options | Description
---- | ------------- | -----------
`EMPIRE_X_LOAD_BALANCER_TYPE` | `elb` | `alb`, `elb`| Determines whether you will use an ALB or ELB
`EMPIRE_X_EXPOSURE` | not set | `public` | Sets whether your ALB or ELB will be a public one, the default is internal.
`EMPIRE_X_TASK_DEFINITION_TYPE` | not set | `custom` | Determines whether we use the Custom::ECSTaskDefinition (better explanation needed)
`EMPIRE_X_TASK_ROLE_ARN` | not set | any IAM role ARN | Sets the IAM role for that app/process. **Your ECS cluster MUST have this enabled!**
16 changes: 12 additions & 4 deletions releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,12 @@ func newSchedulerProcess(release *Release, name string, p Process) (*twelvefacto
)
// For `web` processes defined in the standard procfile, we'll
// generate a default exposure setting and also set the PORT
// environment variable for backwards compatability.
// environment variable for backwards compatibility.
if name == webProcessType && len(p.Ports) == 0 {
exposure = standardWebExposure(release.App)
env["PORT"] = "8080"
} else {
exposure, err = processExposure(release.App, name, p)
exposure, err = processExposure(release.App, name, p, env)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -437,7 +437,7 @@ func standardWebExposure(app *App) *twelvefactor.Exposure {
}
}

func processExposure(app *App, name string, process Process) (*twelvefactor.Exposure, error) {
func processExposure(app *App, name string, process Process, env map[string]string) (*twelvefactor.Exposure, error) {
// No ports == not exposed
if len(process.Ports) == 0 {
return nil, nil
Expand Down Expand Up @@ -474,8 +474,16 @@ func processExposure(app *App, name string, process Process) (*twelvefactor.Expo
Protocol: protocol,
})
}

external := app.Exposure == exposePublic
if v, ok := env["EMPIRE_X_EXPOSURE"]; ok {
if v == exposePublic {
external = true
}
}

return &twelvefactor.Exposure{
External: app.Exposure == exposePublic,
External: external,
Ports: ports,
}, nil
}
Expand Down

0 comments on commit 7d665c6

Please sign in to comment.