Skip to content

Commit

Permalink
Add scripts to build and show compliance instances
Browse files Browse the repository at this point in the history
Signed-off-by: Nathen Harvey <nharvey@chef.io>
  • Loading branch information
Nathen Harvey committed Nov 9, 2016
1 parent 5c59041 commit 134167a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions build_compliance_workstations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
# Builds training instances in EC2
USAGE="Usage: $0 [number] [name] [department] [contact] [project] [termination-date]"

AMI_ID=ami-352f0d22

NUMHOSTS=$1
NAME=$2
DEPT=$3
CONTACT=$4
PROJECT=$5
TERM_DATE=$6

INSTANCE_TYPE="t2.small"
KEY_NAME=$AWS_KEYPAIR_NAME

if [ "$#" -ne 6 ]; then
echo $USAGE
exit 1
fi

for host in $(aws ec2 run-instances --image-id $AMI_ID --region us-east-1 --count $NUMHOSTS --instance-type $INSTANCE_TYPE --key-name $KEY_NAME --security-group-ids "sg-a1c3b1db" --subnet-id subnet-46b55431 | jq -r ".Instances|.[].InstanceId"); do
echo "Created instance: $host"
echo "Tagging $host with \"$NAME\""
aws ec2 create-tags --resources $host --tags "Key=Name,Value=\"$NAME\""
aws ec2 create-tags --resources $host --tags "Key=X-Dept,Value=\"$DEPT\""
aws ec2 create-tags --resources $host --tags "Key=X-Contact,Value=\"$CONTACT\""
aws ec2 create-tags --resources $host --tags "Key=X-Project,Value=\"$PROJECT\""
aws ec2 create-tags --resources $host --tags "Key=X-Termination-Date,Value=\"$TERM_DATE\""
done
5 changes: 5 additions & 0 deletions show_running_compliance_instances.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

AMI_ID=ami-352f0d22

aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,ImageId,PublicIpAddress,State.Name,Tags[?Key==`Name`].Value | [0]]' --output text | grep running | grep $AMI_ID

0 comments on commit 134167a

Please sign in to comment.