Source URLs
A source.url
may point to any https://
URL that responds to a GET
with a tarball source code. When running terraform apply
,
the source code will only be fetched once for a successful build. Change the URL to force a new resource.
💡 Useful for building public, open-source source code, such as projects that publish releases on GitHub.
⛔ Not useful for private URLs that require credentials to access.
GitHub URLs
GitHub provides release tarballs through URLs. Create a release and then use the tag as a source.url
, such as:
Local source
A source.path
may point to either:
- a tarball of source code
- a directory of source code
- use
src/appname
relative paths tochildsubdirectories within the Terraform project repo (recommended) - use
/opt/src/appname
absolute or../appname
relative paths to external directories -
avoid ancestor paths that contain the Terraform configuration itself
- paths such as
../
will cause errors during apply
- paths such as
- use
When running terraform apply
, if the contents (SHA256) of the source path changed since the last apply
, then a new build will start.
🚚 The complete source must already be present at its path
when Terraform runs, so either:
- copy/clone/checkout the source to the
path
before Terraform runs, like this issue's solution - commit the source code into a subdirectory of the Terraform project repository, so that that it's all cloned together.
Example Usage with Local Source Directory
resource "heroku_app" "foobar" {
name = "foobar"
region = "us"
}
resource "heroku_build" "foobar" {
app_id = heroku_app.foobar.id
source {
# A local directory, changing its contents will
# force a new build during `terraform apply`
path = "src/example-app"
}
}
resource "heroku_formation" "foobar" {
app_id = heroku_app.foobar.id
type = "web"
quantity = 1
size = "Standard-1x"
depends_on = ["heroku_build.foobar"]
}