Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh: accept private key contents instead of path #3846

Merged
merged 1 commit into from
Nov 12, 2015

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Nov 10, 2015

We've been moving in the direction of pushing away from config fields
expecting file paths that Terraform will load, instead prefering fields
that expect file contents, leaning on file() to do loading from a
path.

This helps with consistency and also flexibility - since this makes it
easier to shift sensitive files into environment variables.

Here we add a little helper package to manage the transitional period
for these fields where we support both behaviors.

These fields already had this behavior, just got to move to a shared
implementation:

  • provider/azure: settings_file
  • provider/google: account_file

These fields move to the new contents-preferrred
path-supported-but-deprecated behavior:

  • provisioner/chef: validation_key and secret_key
  • connection/ssh: key_file

@KFishner
Copy link
Contributor

LGTM

@apparentlymart
Copy link
Contributor

Isn't it kinda weird to have an argument that ends in _file that doesn't accept a filename?

@phinze
Copy link
Contributor Author

phinze commented Nov 10, 2015

@apparentlymart yeah agreed it's kinda weird

I guess we could make:

  • key_file -> private_key for connection
  • settings_file -> publish_settings for azure
  • account_file -> credentials for google

@jen20
Copy link
Contributor

jen20 commented Nov 10, 2015

@phinze As we discussed earlier we should probably make the template_file resource behave in the same manner, and rename the filename argument to template. This also gives the benefit of allowing very simple templates to be specified inline.

We've been moving away from config fields expecting file paths that
Terraform will load, instead prefering fields that expect file contents,
leaning on `file()` to do loading from a path.

This helps with consistency and also flexibility - since this makes it
easier to shift sensitive files into environment variables.

Here we add a little helper package to manage the transitional period
for these fields where we support both behaviors.

Also included is the first of several fields being shifted over - SSH
private keys in provisioner connection config.

We're moving to new field names so the behavior is more intuitive, so
instead of `key_file` it's `private_key` now.

Additional field shifts will be included in follow up PRs so they can be
reviewed and discussed individually.
@phinze
Copy link
Contributor Author

phinze commented Nov 12, 2015

Okay! This got to be a rather large change, so I decided to chunk it up. This PR will serve as the base, and I'll follow on with individual PRs for the other fields that are changing, since they each have potential semantic discussion around the new field names.

@phinze phinze changed the title ensure all fields expect file contents, not paths ssh: accept private key contents instead of path Nov 12, 2015
@jen20
Copy link
Contributor

jen20 commented Nov 12, 2015

LGTM.

@jen20
Copy link
Contributor

jen20 commented Nov 12, 2015

The expansion code in the new helper package should help solve #3856 as well when it comes around to that PR.

phinze added a commit that referenced this pull request Nov 12, 2015
ssh: accept private key contents instead of path
@phinze phinze merged commit d6a61bd into master Nov 12, 2015
@phinze phinze deleted the phinze/pathorcontents branch November 12, 2015 21:35
phinze added a commit that referenced this pull request Nov 12, 2015
Builds on the work of #3846, shifting the Chef provisioner's
configuration options from `secret_key_path` and `validation_key_path`
over to `secret_key` and `validation_key`.
phinze added a commit that referenced this pull request Nov 12, 2015
Building on the work in #3846, shifting the Azure provider's
configuration option from `settings_file` to `publish_settings`.
phinze added a commit that referenced this pull request Nov 12, 2015
Builds on the work of #3846, shifting the Chef provisioner's
configuration options from `secret_key_path` and `validation_key_path`
over to `secret_key` and `validation_key`.
phinze added a commit that referenced this pull request Nov 12, 2015
Building on the work in #3846, shifting the Azure provider's
configuration option from `settings_file` to `publish_settings`.
phinze added a commit that referenced this pull request Nov 12, 2015
Building on the work in #3846, shifting the Google provider's
configuration option from `account_file` to `credentials`.
phinze added a commit that referenced this pull request Nov 13, 2015
Building on the work of #3846, deprecate `filename` in favor of a
`template` attribute that accepts file contents instead of a path.

Required a bit of work in the interpolation code to prevent Terraform
from assuming that template interpolations were resource variables that
needed to be resolved. Leaving them as "Unknown Variables" prevents
interpolation from happening early and lets the `template_file` resource
do its thing.
phinze added a commit that referenced this pull request Nov 13, 2015
Building on the work of #3846, deprecate `filename` in favor of a
`template` attribute that accepts file contents instead of a path.

Required a bit of work in the interpolation code to prevent Terraform
from assuming that template interpolations were resource variables that
needed to be resolved. Leaving them as "Unknown Variables" prevents
interpolation from happening early and lets the `template_file` resource
do its thing.
phinze added a commit that referenced this pull request Nov 16, 2015
Building on the work in #3846, shifting the Google provider's
configuration option from `account_file` to `credentials`.
phinze added a commit that referenced this pull request Nov 16, 2015
Building on the work in #3846, shifting the Google provider's
configuration option from `account_file` to `credentials`.
phinze added a commit that referenced this pull request Nov 16, 2015
Building on the work in #3846, shifting the Azure provider's
configuration option from `settings_file` to `publish_settings`.
@ketzacoatl
Copy link
Contributor

@phinze, In the context of SSH keys, I am a bit surprised to see this change, and the deprecation of key_file. Passing in these values as environment variables is a worthy use case, but does that need to come at the expense of forcing our private keys through Terraform? If my private key is on disk, and Terraform only needs to provide SSH a reference to that file, I do not want Terraform reading that file.

@phinze
Copy link
Contributor Author

phinze commented Nov 30, 2015

@ketzacoatl I definitely understand the concern, however Terraform was already reading that file prior to this change. We use Go standard libraries for SSH communication, so it has to be in memory with respect to Terraform.

@ketzacoatl
Copy link
Contributor

ah, ok, connecting over SSH thru Go makes sense - sorry for the noise!

omeid pushed a commit to omeid/terraform that referenced this pull request Mar 30, 2018
…isterner-link-to-cert-resource

docs/resource/aws_lb_listener: Add link to aws_lb_listener_certificate resource
@ghost
Copy link

ghost commented Apr 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants