aws - pisanorg/w GitHub Wiki
AWS provides several services with a free-tier and additional services are often available under AWS Educate Starter Account.
Provides a cloud based environment for programming. Make sure you save your work to GitHub or some other location
The setup will take anywhere from 30 minutes to 3 hours depending on how fast emails are verified and accounts are approved, but once everything is in place you will be able to work from anywhere with all your documents stored in the cloud.
- [Instructor Only] Setup Classroom
- As a student, you should get an email inviting you to join an "AWS Educate Classroom"
-
Enter Classroom via All Services > Cloud9
(additional instructions as setup-classroom ) and follow the instructions to create your first environment.
- If it is your first time logging into AWS, you will go through "Tell us about yourself", Agree to Terms, Respond to an email to verify your email address, Respond to a second email to set your password, and then login via https://www.awseducate.com/signin/SiteLogin to Create AWS Student Account, and then Agree to Vocareum Terms and Conditions which will finally lead you you AWS Console where you can choose All Services > Cloud9
- AWS account verification can take up to 2 hours
- Create Environment, call it something like
firstenv - Choose "Ubuntu Server" rather than "Amazon Linux" to make installing programs easier
- Create your first program: File > New From Template > C++ File
- Save your program: File > Save as "hello.cpp" in Folder "/HelloWorldProject"
- Run your program: Run > Run with > C++
- Next time you run the same program, you can use Run > Run Last
- Learn more at AWS Cloud9 Documentation
When a Cloud9 environment is deleted, your programs in that environment will be deleted as well. So, you must save your work to another location. You can use File > Download Project to save it to your local computer, but a better way is to save it on GitHub
- Create a GitHub username if you do not have one already
- On GitHub, create a new repository. Let's call it HelloWorldProject. Make this a private repository, so you can selectively share your work rather than making it public to the whole world
- On Cloud9 IDE, use the terminal (titled "bash")
$ cd HelloWorldProject/
$ git init
Initialized empty Git repository in /home/ubuntu/environment/HelloWorldProject/.git/
$ git add hello.cpp
$ git config --global user.name "FirstName LastName"
$ git config --global user.email "[email protected]"
$ git config credential.helper 'cache --timeout 7200'
$ git commit -m "first commit"
$ git remote add origin https://github.com/myGitHubUserName/HelloWorldProject.git
$ git push -u origin master
Username for 'https://github.com': myGitHubUserName
Password for 'https://[email protected]':
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 334 bytes | 334.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/myGitHubUserName/HelloWorldProject.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.- Confirm that your project has been uploaded by visiting https://github.com/myGitHubUserName/HelloWorldProject
- Make some changes to HelloWorldProject/hello.cpp using Cloud9 IDE
$ git commit -a -m "Committing modified files already under source control."
$ git push
- On Cloud9 IDE, use the terminal (titled "bash")
$ git clone https://github.com/myGitHubUserName/HelloWorldProject
Cloning into 'HelloWorldProject'...
Username for 'https://github.com': myGitHubUserName
Password for 'https://[email protected]':
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3)
$ ls -al
total 20
drwxr-xr-x 4 ubuntu ubuntu 4096 Jun 20 19:29 .
drwx------ 14 ubuntu ubuntu 4096 Jun 20 19:23 ..
drwxr-xr-x 3 ubuntu ubuntu 4096 Jun 20 19:02 .c9
drwxrwxr-x 3 ubuntu ubuntu 4096 Jun 20 19:29 HelloWorldProject
-rw-r--r-- 1 ubuntu ubuntu 569 Jun 3 09:22 README.md- Make some changes to HelloWorldProject/hello.cpp using Cloud9 IDE
$ cd HelloWorldProject
$ git commit -a -m "Committing modified files already under source control."
$ git push
- On Cloud9 IDE, use the terminal (titled "bash") to create an shh key-pair. The ssh key is for this instance only. If you delete this instance (or environment), you will need to repeat this step.
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:7uvXOO7L2tqj/r6s+/4UweD4QqFLoHhX9A5t+eVEwRA ubuntu@ip-172-31-26-53
The key's randomart image is:
+---[RSA 2048]----+
| ..o . E+o. |
| . . o + = +. |
|. o . + B . = |
| . . . * o + . |
| . S o o |
| . . . |
| . o. |
| . ==.. |
| o@/#*. |
+----[SHA256]-----+
$ ls -al ~/.ssh
total 20
drwxr-xr-x 2 ubuntu ubuntu 4096 Jun 20 19:57 .
drwxr-xr-x 14 ubuntu ubuntu 4096 Jun 20 19:57 ..
-rw------- 1 ubuntu ubuntu 991 Jun 20 19:55 authorized_keys
-rw------- 1 ubuntu ubuntu 1679 Jun 20 19:57 id_rsa
-rw-r--r-- 1 ubuntu ubuntu 405 Jun 20 19:57 id_rsa.pub
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB....XnKyl RsZu9 ubuntu@ip-172-31-88-192- On GitHub, Settings > SSH and GPG Keys > New SSH Key
- Title: c9key
- Key: copy-and-paste the above key starting with ssh-rsa
- Make some changes to HelloWorldProject/hello.cpp using Cloud9 IDE
- Push the modified project using ssh
$ cd HelloWorldProject
$ git commit -a -m "again"
[master 16de09d] again
1 file changed, 1 insertion(+), 1 deletion(-)
$ git remote set-url origin [email protected]:myGitHubUserName/HelloWorldProject.git
$ git push
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Counting objects: 6, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 618 bytes | 618.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0)
To github.com:myGitHubUserName/HelloWorldProject.git
e111206..16de09d master -> master
- When cloning a GitHub repository, you can now use:
git clone [email protected]:myGitHubUserName/HelloWorldProject.git
We would like to add some additional tools we can use
- valgrind for memory leaks:
sudo snap install valgrind --classic - Clang tidy:
sudo apt install clang-tidy
Shell scripts are programs that work as if we had typed the commands on the command line.
Create a new file simplecompile.sh using this template.
You can use ./simplecompile.sh to compile your program and run checks using clang-tidy and valgrind.
Modify simplecompile.sh as needed.
Create a new file .clang-tidy using this template.
This file controls the checks that clang-tidy will perform,
so all options do not have to be entered on the command line.
If you want clang-tidy to check everything, you'd use
$ clang-tidy -checks="*" *.cpp -- -std=c++14 -Wall -Wextra -Wno-sign-compare
to only check for readability issues, you'd use
$ clang-tidy -checks="readability-*" *.cpp -- -std=c++14 -Wall -Wextra -Wno-sign-compare
with .clang-tidy in place, you can simply use
$ clang-tidy *.cpp -- -std=c++14 -Wall -Wextra -Wno-sign-compare
Travis CI is a continuous integration platorm that works with GitHub. When configured properly, every time you push your project to GitHub, Travis CI will compile and run it on a new virtual machine. This lets you see if your program actually works on another machine.
Travis CI is free for 100 builds. After that, you'll need to pay unless your project is part of an educational organization, such as a course, setup by your instructor. Talk to your instructor or email me for getting unlimited builds (as long as you are a student).
- Login to Travis CI and "Activate the GitHub Apps integration"
To setup Travis CI, create a new file,
.travis.ymlin your project with the following content:
# Travis.ci file https://docs.travis-ci.com/user/tutorial/
# Continous integration
# Login to https://travis-ci.com/ using your github credentials
# Add this repository to travis
# Every time there is a commit, this script will be run and result emailed
language: cpp
dist: xenial
before_install:
- sudo apt-get install valgrind
- sudo apt install clang-tidy
- uname -a
- g++ --version
- valgrind --version
script:
- ./simplecompile.sh
- echo "Travis CI is done!"-
Cloud9 normally hides files that start with
., to make them visible click on thegear iconnext toC and C++ Spaces: 4at the boottom right ofhello.cpp(or any file really) and selectShow Invisibles -
Add this new file to your git repository and push it to GitHub
$ git add .travis.yml
$ git commit -a -m "added travis"
$ git push- Login to Travis CI. Select your repository. You might have to choose More Options > Trigger Build to get the compilation started the first time around.