Skip to content

Latest commit

 

History

History
138 lines (105 loc) · 6.02 KB

README.md

File metadata and controls

138 lines (105 loc) · 6.02 KB

CloudFoundry Application Module

Requirements

Name Version
archive 2.4.0
cloudfoundry 0.51.2
local 2.4.0

Providers

Name Version
archive 2.4.0
cloudfoundry 0.51.2
local 2.4.0

Modules

No modules.

Resources

Name Type
cloudfoundry_app.this resource
cloudfoundry_network_policy.egress_proxy resource
cloudfoundry_network_policy.ingress_proxy resource
cloudfoundry_route.external resource
cloudfoundry_route.internal resource
local_sensitive_file.this resource
archive_file.this data source

Inputs

Name Description Type Default Required
cloudfoundry The settings object for Cloudfoundry. any n/a yes
env The settings object for this environment. any n/a yes
secrets Sensitive credentials to be used to set application environmental variables. map {} no
services Services generated from the service module. any
{
"instance": null,
"service_key": null,
"user_provided": null
}
no

Outputs

Name Description
apps A map of cloudfoundry_app resource outputs. The key is the app name.
external_endpoints A map of external URL's (app.cloud.gov) to used to reach an application. The key is the app name.
internal_endpoints A map of internal URL's (apps.internal) to used to reach an application. The key is the app name.

Example

module "applications" {
  source = "./modules/application"

  cloudfoundry = local.cloudfoundry
  env = local.env
  secrets = local.secrets
  services = local.services
}

Variables

cloudfoundry

A variable that contains a map(string) of data lookups for pre-existing resources from Cloud.gov. This includes thing such as the organization and space ids. These are defined in data.tf in the root directory.

env

A mixed type object variable that contains application settings. It is passed as an any type to allow optional variables to be ommitted from the object. It is defined in locals.tf, in the root directory. The object local.env[terraform.workspace].apps stores the values for the specific application that is to be deployed.

Valid options are the attributes for the cloudfoundry_app resource.

secrets

A variable that has secrets and other credentials that the application uses. The local.secrets variable is generated in locals_dynamic.tf, as it merges a variety of credentials from the random and services modules.

services

A variable that contains a map(map(string)) of the services deployed in the environment. local.services is generated in locals_dynamic.tf, due to needing to be generated after the creation of the services, after the instance id are known. The services are then bound to the application.

See the service module for more information.

Usage

Here is an example of how to define an application in locals.tf.

locals {
  env = {
    workspace1 = {
      apps = {
        application1 = {
          buildpacks = [
            "staticfile_buildpack"
          ]
          command = "./start"
          disk_quota = 256
          enable_ssh = true
          environment = {
            environment = terraform.workspace
            LD_LIBRARY_PATH = "/home/vcap/deps/0/lib/"      
          }
          health_check_timeout = 180
          health_check_type = "port"
          instances = 1
          labels = {
            environment = terraform.workspace
          }
          memory        = 64
          port          = 8080
          public_route  = false

          source        = "/path/to/application/directory"

          templates     = [
            {
              source      = "${path.cwd}/path/to/templates/template.tmpl"
              destination = "${path.cwd}}/path/to/templates/file"
            }
          ]
        }
      }
    }
  }
}

Additional Notes

  • Buildpacks
    • Valid built-in Cloud.gov buildpacks can be found by running cf buildpacks from the CLI.
    • External buildpacks, such as the apt-buildpack by referencing the URL to the buildpack repository: https://github.com/cloudfoundry/apt-buildpack.