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

Simplification in example of upload pub file #53

Merged
merged 1 commit into from
Oct 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions samples/s3_ssh_public_keys.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This is an example of how to put public keys into S3 bucket and manage them in Terraform
variable "ssh_public_key_names" {
default = "user1,user2,admin"
default = ["user1","user2","admin"]
type = "list"
}

resource "aws_s3_bucket" "ssh_public_keys" {
Expand Down Expand Up @@ -32,11 +33,11 @@ EOF

resource "aws_s3_bucket_object" "ssh_public_keys" {
bucket = "${aws_s3_bucket.ssh_public_keys.bucket}"
key = "${element(split(",", var.ssh_public_key_names), count.index)}.pub"
key = "${element(var.ssh_public_key_names, count.index)}.pub"

# Make sure that you put files into correct location and name them accordingly (`public_keys/{keyname}.pub`)
content = "${file("public_keys/${element(split(",", var.ssh_public_key_names), count.index)}.pub")}"
count = "${length(split(",", var.ssh_public_key_names))}"
source = "public_keys/${element(var.ssh_public_key_names, count.index)}.pub"
count = "${length(var.ssh_public_key_names)}"

depends_on = ["aws_s3_bucket.ssh_public_keys"]
}