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

Terraform TLS SSH key pair to SSM initial implementation #2

Merged
merged 4 commits into from
Jan 10, 2019
Merged

Conversation

joshmyers
Copy link
Contributor

@joshmyers joshmyers commented Jan 10, 2019

what

This PR is an initial implementation for writing SSH keys to AWS SSM parameter store. It supports both RSA and ECDSA key algos and enforces a convention on how these keys should be written to SSM, name /foo/bar or /foo/bar_badger. If no key name is given for public/private SSH keys, the label module is used, but the delimiter is forced to be underscore for consistency e.g. /ssh_keys/cpco_testing_$app_public_key. This can be useful for namespacing SSM IAM permissions when for multiple keys in the same account.

why

Rather than mounting an s3 based file system using goofys for secrets, we should write them into SSM, to be fetched by chamber.

notes

Fixes #1

LICENSE Outdated
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2018 Cloud Posse, LLC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Copyright 2018 Cloud Posse, LLC
Copyright 2019 Cloud Posse, LLC

README.yaml Outdated Show resolved Hide resolved
README.yaml Outdated Show resolved Hide resolved
README.yaml Outdated Show resolved Hide resolved
README.yaml Outdated Show resolved Hide resolved
examples/complete/main.tf Outdated Show resolved Hide resolved
examples/complete/output.tf Outdated Show resolved Hide resolved
main.tf Show resolved Hide resolved
main.tf Outdated
name = "${local.ssh_private_key_ssm_path}"
description = "TLS Private Key"
type = "SecureString"
value = "${tls_private_key.default_rsa.private_key_pem}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value = "${tls_private_key.default_rsa.private_key_pem}"
value = "${join("", tls_private_key.default_rsa.*.private_key_pem)}"

main.tf Outdated
name = "${local.ssh_public_key_ssm_path}"
description = "TLS Public Key (OpenSSH - ${var.ssh_key_algorithm})"
type = "String"
value = "${tls_private_key.default_rsa.public_key_openssh}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value = "${tls_private_key.default_rsa.public_key_openssh}"
value = "${join("", tls_private_key.default_rsa.*.public_key_openssh)}"

main.tf Outdated
name = "${local.ssh_private_key_ssm_path}"
description = "TLS Private Key (${var.ssh_key_algorithm})"
type = "SecureString"
value = "${tls_private_key.default_ecdsa.private_key_pem}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value = "${tls_private_key.default_ecdsa.private_key_pem}"
value = "${join("", tls_private_key.default_ecdsa.*.private_key_pem)}"

main.tf Outdated
name = "${local.ssh_public_key_ssm_path}"
description = "TLS Public Key (${var.ssh_key_algorithm})"
type = "String"
value = "${tls_private_key.default_ecdsa.public_key_openssh}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value = "${tls_private_key.default_ecdsa.public_key_openssh}"
value = "${join("", tls_private_key.default_ecdsa.*.public_key_openssh)}"

variables.tf Outdated
@@ -0,0 +1,73 @@
variable "namespace" {
type = "string"
description = "Namespace (e.g. `cp` or `cloudposse`)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description = "Namespace (e.g. `cp` or `cloudposse`)"
description = "Namespace (e.g. `eg` or `cp`)"

Copy link
Member

@aknysh aknysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@joshmyers
Copy link
Contributor Author

@aknysh Have rebased and pushed requested changes, thanks!

@joshmyers
Copy link
Contributor Author

@osterman KMS key added and rebased

@joshmyers joshmyers force-pushed the init_v2 branch 2 times, most recently from 19df679 to a0b3d84 Compare January 10, 2019 18:36
This commit adds some default variables and locals for naming of SSM
params.

We expect SSM params to be written in the form `/foo/bar` or
`/foo/bar_badger` where foo is var.ssm_path_prefix and bar is passed in
explicitly, or else we default to label.id where we replace the
delimiter with underscores to maintain consistency.

Both RSA + ECDSA key algo’s are supported.
@osterman osterman merged commit c84b1b6 into master Jan 10, 2019
@osterman osterman deleted the init_v2 branch January 10, 2019 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants