-
Notifications
You must be signed in to change notification settings - Fork 3
microservice adjustments for ebs #7
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
base: master
Are you sure you want to change the base?
Conversation
…ummy one which doesn't do anything and only fullfiling parameter
… whats left is to create function which check if attached volume has filesystem on it. If filesystem not exist then format to specific one , if exist proceed with mounting
…g, checking, formating and mounting inside EC2 instance. Volumes are picked by the unique tag which need to be set both inside ASG and EBS module. What is not covered, checking if volume is attached elsewhere , detaching and reataching to right ec2 instance
…ged way of attaching volumes to instance to match AWS device naming. Also some probelm arise with userdata script not formating volumes on run, going to look into it since it could be some rhel based issues
…titions list, when it does rest of the process continue to do the job
…ive possibility of specifying which template to use
…o change code userdata.tmpl
…ht module output as subnets_route_tables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. Have a few suggestions mostly bash related. However, Would like to see a little more error handling, just to test the output of the aws binary calls and have a standard error function for failure that ensures instances arent left inconsistent.
@@ -5,10 +5,11 @@ resource "aws_launch_configuration" "launch_configuration" { | |||
instance_type = "${var.lc_instance_type}" | |||
security_groups = ["${aws_security_group.security_group.id}", "${var.additional_security_group_ids}"] | |||
iam_instance_profile = "${aws_iam_instance_profile.iam_instance_profile.id}" | |||
|
|||
key_name = "${var.lc_key_name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this going back in again?
Keys go in via packer, not at launch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it doesn't and this parameter can be empty then it is ignored. Keeping it here will give the module better flexibility.
@@ -10,6 +10,12 @@ variable "asg_health_check_grace_period" { | |||
description = "Time (in seconds) after instance comes into service before checking health" | |||
} | |||
|
|||
variable "lc_key_name" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.. LCs don't need keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't hurt to have additional option and giving possibility to add key if we need one
#!/bin/bash | ||
/usr/local/bin/aws configure set profile.default.region eu-west-1 | ||
/usr/local/bin/aws configure set profile.default.output json | ||
/usr/local/bin/aws configure set profile.ebs.role_arn $(wget -q -O - 169.254.169.254/latest/meta-data/iam/info | grep "InstanceProfileArn" | awk -F\" '$2 == "InstanceProfileArn" {print $4}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not incoporate the grep into the awk command? Not a problem, just a thought.
Also isn't curl a lighterweight option than wget for this type of thing?
@@ -0,0 +1,39 @@ | |||
#!/bin/bash | |||
/usr/local/bin/aws configure set profile.default.region eu-west-1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export PATH="/usr/local/bin:${PATH}"
aws ...
or: aws="/usr/local/bin/aws"
${aws} ...
/usr/local/bin/aws configure set profile.ebs.source_profile default | ||
instance_id=$(wget -q -O - 169.254.169.254/latest/meta-data/instance-id) | ||
instance_role=$(/usr/local/bin/aws ec2 describe-instances --instance-ids ${instance_id} --query 'Reservations[*].Instances[].Tags[?Key==`Role`].Value[]' --output text) | ||
volumes_ids=$(/usr/local/bin/aws ec2 describe-volumes --filter Name=tag:Name,Values="${instance_role}" --query 'Volumes[].[VolumeId]' --output text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be safer in a bash array rather than string, just in case since we are depending on IFS for the for-loop iteration
for volumes in ${volumes_ids} ; do | ||
mountpoint=$(/usr/local/bin/aws ec2 describe-volumes --volume-ids ${volumes} --query 'Volumes[].Tags[?Key==`MountPoint`].Value[]' --output text); | ||
dev=$(/usr/local/bin/aws ec2 describe-volumes --volume-ids ${volumes} --query 'Volumes[].Tags[?Key==`Dev`].Value[]' --output text); | ||
rhelmp=$(echo ${dev} | sed 's/sd/xvd/g') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"${dev/sd/xvd}" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed that using bash replacing
This is initial pull request , some changes are not final and are object to be changed