Skip to content

Instantly share code, notes, and snippets.

View pavan168's full-sized avatar
:octocat:
typing...

Pavan Welihinda pavan168

:octocat:
typing...
  • Sri Lanka
View GitHub Profile
@pavan168
pavan168 / init.sh
Last active March 29, 2020 05:01
A script file with Terraform commands and a set of ssh/scp commands to remotely execute in new ec2 instance
#!/bin/bash
projectfolder=$1
if [ -z "$projectfolder" ]; then
exit 1
fi
./terraform apply -auto-approve
ssh -i ~/.ssh/<aws-ssh-pem-file> -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ubuntu@<new-instance-private-ip> "mkdir -p /home/ubuntu/\"$projectfolder\""
scp -i ~/.ssh/<aws-ssh-pem-file> -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r /var/www/$projectfolder ubuntu@<new-instance-private-ip>:/home/ubuntu
@pavan168
pavan168 / setup.sh
Created March 29, 2020 04:43
A script file to setup the new instance environment with Docker, Build the new image, and Export
#!/bin/bash
projectfolder=$1
# setup docker environment
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable edge"
sudo apt-get update