Skip to content

Latest commit

 

History

History
90 lines (64 loc) · 4.48 KB

CREATING_A_NEW_PROJECT.md

File metadata and controls

90 lines (64 loc) · 4.48 KB

Creating a new project

These steps will typically be performed by the trainer, however they are recorded here for completeness. To run them, you will need access to the AWS account.

Steps

Project Tag

For many of these steps, we will be using your project tag. This is a short unique string which will be used to distinguish your project from other Agent Discoveries project (of which there may be many in the future). This can be anything, you could ask your team for ideas, or come up with something sensible yourself. For example, the project which is builds the original source code is called "skeleton".

Note: You may want to consider creating separate ones for test and live, where only the test one is triggered automatically.

Create a New KeyPair

When AWS creates a new EC2 instance, it allows a user with a specific key pair to SSH into it. Visit https://eu-west-2.console.aws.amazon.com/ec2/v2/home?region=eu-west-2#KeyPairs and create a key pair.

Make sure you save the file it gives you, as this is the only way of accessing the server you're about to create!

Create Resources

Run the Jenkins build called "Agent Discoveries Create New". This will create all of the resources you will need for your project.

Note: After the build finishes, you will have to wait 10 mins or so for all of your resources to build. You can find your stack and follow its progress here.

This creates all the resources needed. It creates a stack using template in ./infrastructure, which creates the EC2 instance etc. And then sets up the code deploy resources so that Jenkins will be able to deploy straight to the server.

Create a Jenkins Build

You should create a Jenkins build for your project. A good starting place is to clone the Skeleton build. Then edit the values in the configuration to use your git repo and your project tag.

The idea is to create a build that is automatically triggered (you will need to add the following hook to your github repo: instructions). This build will then trigger the generic Agent Discoveries Build and Agent Discoveries Deploy builds in turn to build your project to your server (again, give the deployment a few minutes before panicking).

Checking that it works

Find your new instance in the list of EC2 instances here Visit the url listed under the Public DNS (IPv4) value in the description for this instance.

Hopefully, you are able to see your website!

Create a Jenkins Job for Integration Tests

It is also possible to run integration tests against the deployed instance.

Like the Jenkins build above, the easiest way to do this is to clone the Integration Test Skeleton, then edit the parameters in the configuration to use your Github Repository, and your Deployment Address (the test one if you have separated test and live environments). This job will trigger the generic Agent Discoveries Integration Testing job and report the results.

You should then add your team's email addresses at the bottom so you'll be notified quickly if any tests fail, optionally can configure the job to run on a different schedule to the current one.

Giving users SSH access

You should do this, even if it's just so that you can login as yourself, instead of the root user.

The first time, log in to your instance as ec2-user

ssh -i /path/to/key/pair/pem/file ec2-user@<Public DNS (IPv4)>
# For example
ssh -i ~/.ssh/skeleton.pem [email protected]

Run the following commands the first time to set up sudo permissions for the "academy" group:

# Set up groups
sudo groupadd academy
sudo visudo # Add a line like '%academy ALL=(ALL) NOPASSWD: ALL' to provide the academy group with sudo permission

Run the following commands to give another user access (in this case, AGP):

sudo useradd AGP
sudo mkdir /home/AGP/.ssh
sudo nano /home/AGP/.ssh/authorized_keys # Paste in the user's public key - id_rsa.pub
sudo chown -R AGP:AGP /home/AGP/.ssh
sudo usermod -aG academy AGP