Useful Commands

SSH to an EC2 instnace

ssh -i ~/repos/aws/keypair/awsAccess.pem ec2-user@

Copy a file to remote server

scp -i ~/repos/aws/keypair/awsAccess.pem ~/repos/aws/keypair/awsAccess.pem ec2-user@

Get docker login

Get docker login bash command

aws ecr get-login --no-include-email

Create stack using aws-cli

aws cloudformation create-stack --stack-name simpleSite --template-body file://s3_simple_website.json --parameters ParameterKey=Stackname,ParameterValue=stage1,ParameterKey=AppName,ParameterValue=something

aws cloudformation delete-stack --stack-name simpleSite

Redirect all TCP traffic to another ip address.

sudo yum install socat
socat TCP-LISTEN:8080,fork TCP:

Install redis-cli to aws-ami

sudo yum install -y gcc wget && tar xvzf redis-stable.tar.gz && cd redis-stable && make sudo cp src/redis-cli /usr/bin/

Connect to remote redis

redis-cli -h -p 30000


redis-cli ping should get PONG back

redis-cli> set red-count 0 OK> get red-count “0”

AWS ECS delete hosted zone - service discovery

aws servicediscovery list-services --region ap-southeast-2
aws servicediscovery delete-service --id srv-pass65zl4auilb4e  --region ap-southeast-2
aws servicediscovery list-namespaces --region ap-southeast-2
aws servicediscovery delete-namespace --id ns-nsslrl7nl2u6safn --region ap-southeast-2

Create, attach and use a new EBS

-- View available disks

# create fs if its new
sudo mkfs -t ext4 /dev/xvdf

sudo mkdir /etc/conf

sudo mount /dev/xvdf  /etc/conf

df -h