Name: Vidhisha Jaswani Unity ID: vjaswan
Documentation: Digital Ocean
-
Create an account on Digital Ocean and generated a Personal Access Token (with both read and write access) to use the API.
-
Set the token
# Mac/Linux
export DOTOKEN="xxx"
# Windows
setx DOTOKEN xxx
-
Create an SSH Key on your computer using
ssh-keygen
. This will generate keys in the location~/.ssh
where id_rsa is the private key and id_rsa.pub is the public key. Press Enter when it asks to enter a paraphrase. -
Next, In your Digital Ocean account, under Security add a SSH Key. Paste the content of id_rsa.pub as the SSH key content and give the key a name.
-
Retrieve the ID associated with your SSH key using
curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $DOTOKEN" "https://api.digitalocean.com/v2/account/keys"
-
Update the code in createDroplet function from
"ssh_keys":null
to"ssh_keys":[12345...]
For the purpose of submission, I have removed my ID from the code. -
Run the following commands
mkdir HW1-DevOps-ProvisioningServers
cd HW1-DevOps-ProvisioningServers
git clone https://github.ncsu.edu/vjaswan/HW1-DevOps-ProvisioningServers
cd HW1-DevOps-ProvisioningServers/DigitalOcean
npm install
node main.js
- Now SSH into the droplet using the IP address and no password will be required.
ssh root@<ip-address>
- To delete the instance, update the Droplet ID in line 244 of main.js. Comment out line 239 and uncomment line 264.
Documentation: Amazon EC2
Prerequisite: Python 3 version 3.3+
-
For creating and running the instance we need AWS CLI installed. Refer this link for installation.
-
Navigate to the folder where
HW1-DevOps-ProvisioningServers/AWS
and runpip install -r requirements.txt --user
if you do not have boto3 installed already. -
Run
aws configure
where it will ask you to enter your Access Key ID and Secret Access Key. To get these keys refer this link -
Run command
python main.py
. This will create an instance which you can also see in your dashboard. -
Run the following commands to then SSH into the EC2 instance
chmod 400 aws-key.pem
ssh -i "aws-key.pem" ec2-user@<ip-address>
- Finally, to delete the instance run, edit line 3 in delete.py to update the Instance ID to be deleted and run
python delete.py
Thank you!