Skip to content
This repository has been archived by the owner on Jan 30, 2021. It is now read-only.

Init #1

Merged
merged 8 commits into from
Oct 13, 2017
Merged

Init #1

merged 8 commits into from
Oct 13, 2017

Conversation

goruha
Copy link
Contributor

@goruha goruha commented Oct 5, 2017

What

  • Allow to aggregate user data scripts and store it on s3
  • Allow fetch this data from s3 and execute as normal user data

Why

  • AWS user data is limited by size. This is workaround to avoid limit.

@goruha goruha requested a review from osterman October 5, 2017 15:38
@osterman
Copy link

osterman commented Oct 5, 2017

Terraform module name does not follow registry imposed naming convention.

Also, I think the better approach may be to use this with gzip turned on. Amazon Linux supports cloud init

https://www.terraform.io/docs/providers/template/d/cloudinit_config.html

@osterman
Copy link

osterman commented Oct 6, 2017

main.tf Outdated
namespace = "${var.namespace}"
name = "${var.name}"
stage = "${var.stage}"
attributes = ["s3", "stored"]
Copy link

Choose a reason for hiding this comment

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

s/stored/user-data/

Copy link

@osterman osterman Oct 6, 2017

Choose a reason for hiding this comment

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

drop s3 since I don't think we need that in the bucket name (it's implied)

Aha, I see. I thought it would be used for the bucket name, but it's used for a policy. We can keep it.

main.tf Outdated
resource "aws_s3_bucket_object" "default" {
bucket = "${var.bucket}"
key = "${var.path}/user_data.sh"
content = "${join("\n", var.user_data)}"
Copy link

Choose a reason for hiding this comment

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

Use a local value for the join output?

user_data.sh Outdated

aws s3 cp s3://${s3_path} /tmp/user_data.sh

eval "$(cat /tmp/user_data.sh)"
Copy link

Choose a reason for hiding this comment

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

Why eval as opposed to just running it? .... eval limits user data to bash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because user data does not contains
'#/bin/bash' to specifiy shell

main.tf Outdated
effect = "Allow"

resources = [
"arn:aws:s3:::*",
Copy link

Choose a reason for hiding this comment

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

This should not be necessary and is too permissive.

main.tf Outdated
}

statement {
actions = [ "s3:*" ]
Copy link

Choose a reason for hiding this comment

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

The instances should only need to be able to retrieve the object, not manipulate it.

main.tf Outdated
template = "${file("${path.module}/user_data.sh")}"

vars {
s3_path = "${aws_s3_bucket_object.default.bucket}${aws_s3_bucket_object.default.key}"
Copy link

@osterman osterman Oct 6, 2017

Choose a reason for hiding this comment

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

s/s3_path/s3_user_data_uri/ and add s3:// to the uri

user_data.sh Outdated
# Install AWS Client
pip install --upgrade awscli

aws s3 cp s3://${s3_path} /tmp/user_data.sh
Copy link

Choose a reason for hiding this comment

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

Drop the s3:// and use s3_user_data_uri

user_data.sh Outdated

##############
# Install deps
##############
Copy link

@osterman osterman Oct 6, 2017

Choose a reason for hiding this comment

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

This preamble is disproportionately large to the other comments and there is no "main" section. I think you can drop the #######

Copy link

@osterman osterman left a comment

Choose a reason for hiding this comment

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

Rename "stored" to "backend"

@goruha goruha merged commit 4c9a299 into master Oct 13, 2017
@goruha goruha deleted the init branch October 13, 2017 06:07
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.

3 participants