Skip to content

Credhub interpolation support in CF app manifests #279

Description

@gberche-orange

Is your feature request related to a problem? Please describe.

  • As a template author
  • In order to use credhub-generated passwords in Cf apps pushed by the Cf app support
  • I need COA to invoke the credhub interpolate command on the manifest.yml (following the spruce processing)

Describe the solution you'd like

  • given credhub is populated with a secret
$ credhub get -n /bosh-master/coa-cf-mysql-broker/broker-auth
id: 4846e5b3-...
name: /bosh-master/coa-cf-mysql-broker/broker-auth
type: user
value:
  password: randonuserpassword
  password_hash: redacted
  username: randonusername
version_created_at: "2019-09-25T09:26:02Z"
  • given a coab-depls/cf-apps-deployments/coa-cf-mysql-broker/template/coa-cf-mysql-broker_manifest-tpl.yml file with content
[...]
# interpolated by spruce using vars file
     pipeline.maxExecutionDurationSeconds: (( grab secrets.coa-cf-mysql-broker.pipeline.maxExecutionDurationSeconds ))
# interpolated by credhub, in this example a credential of type user with fields 
     spring.security.user.name: "(( /coa-cf-mysql-broker.broker-auth.username))"
     spring.security.user.password: "(( /coa-cf-mysql-broker.broker-auth.password))"
  • given a coab-depls/cf-apps-deployments/coa-cf-mysql-broker/secrets/secrets.yml file with content
    pipeline:
      maxExecutionDurationSeconds: 3600
  • then the resulting coa-cf-mysql-broker_manifest.yml file content is
[...]
# interpolated by spruce using vars file
     pipeline.maxExecutionDurationSeconds: 3600
# interpolated by credhub, in this example a credential of type user with fields 
     spring.security.user.name: "randonusername"
     spring.security.user.password: "randonuserpassword"

Note that this proposal currently conflicts with CF CLI interpolation proposal at #188

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context

See https://github.com/cloudfoundry-incubator/credhub-cli

$ credhub interpolate --help
Usage:
  credhub [OPTIONS] interpolate [interpolate-OPTIONS]

Fill a template with values returned from CredHub.

Uses double-paren placeholders in the style of the bosh cli. Example:

---
something-stored-in-credhub: ((path/to/var))
something-else: static value

In the above example, the whole value of the cred will be inserted.
For instance, if path/to/var is of type ssh, the output will have all the credential's fields, like this:

---
something-stored-in-credhub:
private_key: fake-private-key
public_key: fake-public-key
public_key_fingerprint: fake-fingerprint
some-other-key: static value

If you want just the password value, you'd need to use ((path/to/var.public_key)),
which would only have the specified field, like this:

---
something-stored-in-credhub: fake-public-key
something-else: static value

If the prefix flag is provided, the given prefix will be prepended
to any credentials that do not start with the '/' character.
Example:

---
something: ((/env-specific-path/path/to/var))
same-thing: ((path/to/var))

When this example is used with the prefix flag 'env-specific-path', they will be evaluated to the same thing.

Application Options:
      --version           Version of CLI and targeted CredHub API
      --token             Return your current CredHub authentication token

Help Options:
  -h, --help              Show this help message

[interpolate command options]
      -f, --file=         Path to the file to interpolate
      -p, --prefix=       Prefix to be applied to credential paths. Will not be applied to paths that start with '/'
      -s, --skip-missing  allow skipping missing params

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    To be reviewed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions