Skip to content
This repository was archived by the owner on Feb 4, 2026. It is now read-only.

Commit b31066c

Browse files
committed
Initial release
1 parent 158dfca commit b31066c

58 files changed

Lines changed: 1579 additions & 9 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.sh
2+
.env
3+
.fun
4+
build.sh
5+
exec.sh
6+
logs.sh
7+
pull.sh
8+
push.sh
9+
run.sh
10+
status.sh
11+
stop.sh
12+

.env

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
# Source helper functions
9+
source .fun
10+
11+
# Proxy settings [optional] - set if your network requires a proxy to connect to the Internet
12+
export http_proxy=
13+
export https_proxy=
14+
export no_proxy=localhost
15+
16+
# Docker image settings
17+
## REGISTRY: [optional] - Docker registry path including trailing "/". Example: registry.company.com/demo/
18+
export REGISTRY=594704452476.dkr.ecr.us-west-2.amazonaws.com/
19+
if [ -n "${REGISTRY}" ]; then
20+
if [ "${REGISTRY: -1}" != "/" ]; then
21+
export REGISTRY="${REGISTRY}/"
22+
fi
23+
fi
24+
## IMAGE: <required> - Docker image name for this project. Example: myapp
25+
export IMAGE=aws-do-cli
26+
## VERSION: [optional] - Version tag for this Docker image. Example: v20180302
27+
#export VERSION=v$(date +%Y%m%d)
28+
export VERSION=latest
29+
export TAG=$(if [ -z "${VERSION}" ]; then echo ""; else echo ":${VERSION}"; fi)
30+
## BUILD_OPTS: [optional] - arguments for the docker image build command
31+
export BUILD_OPTS="--progress=plain --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy} --build-arg no_proxy=${no_proxy}"
32+
33+
# Docker container runtime settings
34+
## CONTAINER_NAME: [optional] - Name of the Docker container including the --name switch. Example --name myapp
35+
export CONTAINER=${IMAGE}
36+
export CONTAINER_NAME="--name ${CONTAINER}"
37+
## Port map [optional] - Mapping of external to internal ports including the -p switch. Example -p 80:8080
38+
#export PORT_MAP="-p 80:8080"
39+
## Volume map [optional] - Mapping of external to internal paths including the -v switch. Example $(pwd):/wd
40+
export VOL_MAP="-v ${HOME}/.aws:/root/.aws -v $(pwd):/wd"
41+
## Network [optional] - Network name including the --net switch. Example --net mynet
42+
export NETWORK=
43+
## RUN_OPTS [optional] - additional options to specify with the run comman. Example -e POSTGRES_DB=dbname
44+
export RUN_OPTS="-e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy"
45+

.fun

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
# Helper functions
9+
## Detect current operating system
10+
function os
11+
{
12+
UNAME=$(uname -a)
13+
if [ $(echo $UNAME | awk '{print $1}') == "Darwin" ]; then
14+
export OPERATING_SYSTEM="MacOS"
15+
elif [ $(echo $UNAME | awk '{print $1}') == "Linux" ]; then
16+
export OPERATING_SYSTEM="Linux"
17+
elif [ ${UNAME:0:5} == "MINGW" ]; then
18+
export OPERATING_SYSTEM="Windows"
19+
export MSYS_NO_PATHCONV=1 # turn off path conversion
20+
else
21+
export OPERATING_SYSTEM="Other"
22+
fi
23+
}
24+
## End os function
25+
os
26+
27+
## Determine current host IP address
28+
function hostip
29+
{
30+
case "${OPERATING_SYSTEM}" in
31+
"Linux")
32+
export HOST_IP=$(hostname -I | tr " " "\n" | head -1) # Linux
33+
;;
34+
"MacOS")
35+
export HOST_IP=$(ifconfig | grep -v 127.0.0.1 | grep -v inet6 | grep inet | head -n 1 | awk '{print $2}') # Mac OS
36+
;;
37+
"Windows")
38+
export HOST_IP=$( ((ipconfig | grep IPv4 | grep 10.187 | tail -1) && (ipconfig | grep IPv4 | grep 3. | head -1)) | tail -1 | awk '{print $14}' ) # Git bash
39+
;;
40+
*)
41+
export HOST_IP=$(hostname)
42+
;;
43+
esac
44+
}
45+
## End hostip function
46+
hostip
47+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
wd
2+
Container-Root/aws-do-cli/ec2/ec2-template/launch-template-*.json
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
source ./ec2.conf
9+
10+
function usage(){
11+
echo ""
12+
echo "Usage: $0 <auto_scaling_group_name> <template_id> <min_size> <max_size> <desired_size>"
13+
echo ""
14+
}
15+
16+
if [ "$5" == "" ]; then
17+
usage
18+
else
19+
echo ""
20+
echo "Creating Auto Scaling Group $1 from Launch Template $2 ..."
21+
# Check if launch template exists
22+
CMD="aws ec2 describe-launch-templates --launch-template-ids $2 > /dev/null"
23+
eval "$CMD"
24+
if [ "$?" == "0" ]; then
25+
CMD="aws autoscaling create-auto-scaling-group --auto-scaling-group-name $1 --launch-template LaunchTemplateId=$2 --min-size $3 --max-size $4 --desired-capacity $5"
26+
echo ""
27+
eval "$CMD"
28+
if [ "$?" == "0" ]; then
29+
echo "Auto Scaling Group $1 created."
30+
else
31+
echo "Failed to create Auto Scaling Group $1"
32+
fi
33+
fi
34+
echo ""
35+
fi
36+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
source ./ec2.conf
9+
10+
function usage(){
11+
echo ""
12+
echo "Usage: $0 <auto_scaling_group_name>"
13+
echo ""
14+
}
15+
16+
if [ "$1" == "" ]; then
17+
usage
18+
else
19+
echo ""
20+
echo "Deleting Auto Scaling Group $1 ..."
21+
# Check if auto scaling group exists
22+
CMD="aws ec2 describe-auto-scaling-groups --auto-scaling-group-names $1 > /dev/null"
23+
eval "$CMD"
24+
if [ "$?" == "0" ]; then
25+
CMD="aws autoscaling delete-auto-scaling-group --auto-scaling-group-name $1"
26+
echo ""
27+
eval "$CMD"
28+
if [ "$?" == "0" ]; then
29+
echo "Auto Scaling Group $1 deleted."
30+
else
31+
echo "Failed to delete Auto Scaling Group $1"
32+
fi
33+
fi
34+
echo ""
35+
fi
36+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
source ./ec2.conf
9+
10+
echo ""
11+
echo "Listing auto scaling groups ..."
12+
echo ""
13+
CMD="aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[*].{Name: AutoScalingGroupName,LaunchTemplate: MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification.LaunchTemplateId, MinSize: MinSize, MaxSize: MaxSize, TargetSize: DesiredCapacity, CurrentSize: length(Instances), Subnet: VPCZoneIdentifier}' --output ${output_format}"
14+
echo "$CMD"
15+
eval "$CMD"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
source ./ec2.conf
9+
10+
function usage(){
11+
echo ""
12+
echo "Usage: $0 <auto_scaling_group_name> <min_size> <max_size> <desired_size>"
13+
echo ""
14+
}
15+
16+
if [ "$4" == "" ]; then
17+
usage
18+
else
19+
echo ""
20+
echo "Updating Auto Scaling Group $1 ..."
21+
# Check if auto scaling group exists
22+
CMD="aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $1 > /dev/null"
23+
eval "$CMD"
24+
if [ "$?" == "0" ]; then
25+
CMD="aws autoscaling update-auto-scaling-group --auto-scaling-group-name $1 --min-size $2 --max-size $3 --desired-capacity $4"
26+
echo ""
27+
eval "$CMD"
28+
if [ "$?" == "0" ]; then
29+
echo "Auto Scaling Group $1 updated."
30+
else
31+
echo "Failed to update Auto Scaling Group $1"
32+
fi
33+
fi
34+
echo ""
35+
fi
36+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
vi ./ec2.conf
9+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
######################################################################
4+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
5+
# SPDX-License-Identifier: Apache-2.0 #
6+
######################################################################
7+
8+
source ec2.conf
9+
10+
sed -i.bak "s/^[#]*\s*current_vpc=.*/current_vpc=$1/" ec2.conf

0 commit comments

Comments
 (0)