Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Todos mis scripts personales que uso o dejé de usar.
#!/bin/bash -xe
#
# Deploy latest revision without going to the AWS web console (used for failed deployments)
#
# jq needs to be installed
# https://stedolan.github.io/jq/
aws --region us-west-2 \
deploy list-application-revisions \
--application-name staging \
--sort-by lastUsedTime \
--sort-order descending \
--max-item 1 \
> revision.json
etag=$(cat revision.json | jq '.revisions[0] | .s3Location.eTag')
key=$(cat revision.json | jq '.revisions[0] | .s3Location.key')
bucket=$(cat revision.json | jq '.revisions[0] | .s3Location.bucket')
echo "The eTag value is: $etag"
echo "The key value is: $key"
echo "The bucket value is: $bucket"
aws --region us-west-2 \
deploy create-deployment \
--application-name staging \
--deployment-group-name api-in-staging \
--ignore-application-stop-failures \
--auto-rollback-configuration enabled=false \
--description "From AWS CLI" \
--s3-location bundleType=zip,bucket=$bucket,eTag=$etag,key=$key
rm ./revision.json
#!/bin/bash
# Para encontrar el proyecto frontend
# Nombre de la imagen.
# HOST/IMAGE:TAG
# bash ~/projects/scripts/search_container.sh staging.*therapist_frontend sh
# Para encontrar el proyecto backend en staging
# Nombre de la imagen:
# HOST/IMAGE:TAG
# bash ~/projects/scripts/search_container.sh api-staging:feature_staging_268 sh
# Para encontrar el proyecto backend en UAT
# Nombre de la imagen:
# HOST/IMAGE:TAG
# bash ~/projects/scripts/search_container.sh api-staging:develop_270 sh
project_name=$1
command=$2
username="ec2-user"
ips_file_path=~/.ips
ec2_instance_ips=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=luna-api-*" | grep PublicIpAddress | awk '{ print $2 }' | cut -d '"' -f 2)
if [ -n "$ec2_instance_ips" ]
then
# Comento porque no los guarda línea por línea y el comando explota
# echo $ec2_instance_ips > $ips_file_path
while read p
do
echo "Accessing IP address: $p"
echo "Project Name: $project_name"
echo "Command to Run in Docker Container: $command"
echo ""
container_id=$(ssh -n $username@$p docker ps | grep $project_name | head -n 1 | awk '{ print $1 }')
echo "Found Container ID: $container_id"
echo ""
if [ -n "$container_id" ]
then
echo "EC2 Instance IP: $p"
instance_ip=$p
break
fi
done < $ips_file_path
if [ -n "$container_id" ]
then
ssh -t $username@$instance_ip docker exec -it $container_id $command
fi
fi
#!/bin/bash
# The script to find the Docker container is quite tedious to user because
# I need to know many things to use the command.
#
# With this one I only need to know the stage and the build number generated by
# Circle CI.
# environment is one of: [staging, develop]
environment=$1
# the build number is found in Circle CI workflow
build_number=$2
# default command run in the docker container
command=sh
if [ $environment == "staging" ]
then
tag_name="feature_staging"
elif [ $environment == "uat" ]
then
tag_name="develop"
fi
bash ~/projects/scripts/search_container.sh \
"luna-api-staging:"$tag_name"_"$build_number \
$command
#!/bin/bash
# Copy vagrant + ansible files for provisioning Rails project
from="$HOME/projects/vagrant-ansible"
dest=$1
cp -R $from/group_vars \
$from/hosts \
$from/playbook.yml \
$from/roles \
$from/Vagrantfile \
$dest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.