-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts to build and show compliance instances
Signed-off-by: Nathen Harvey <nharvey@chef.io>
- Loading branch information
Nathen Harvey
committed
Nov 9, 2016
1 parent
5c59041
commit 134167a
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |