A tool that enables infrastructure as code to set up servers in AWS EC2.
To set up a developer's development environment in AWS, run this terraform project. The scripts will allow the joining of an existing VPC, the creation of a public subnet and a variable number of EC2 instances that the user will have SSH access to. Alarms have been created in the scripts which will auto-shutdown the instances after a configurable period, based on CPU metrics. A Lambda scheduled event can also be configured which can run at a regular interval to shut down any instances that may still be running.
Pre-requisites
This should only be done once per AWS account as there is a limit of 5 per region. Please check if this has already been run and use the existing VPC_ID
and SUBNET_ID
for the following section if it does and skips to the next section.
Navigate to the infrastructure/terraform/vpc
directory
Initialize Terraform project:
Execute the following:
Copy the output for the next step, e.g for ICAP this has already been run and this is the result:
Navigate to the infrastructure/terraform
directory
Initialize Terraform project:
The following properties have to be set:
The configuration can be done using an terraform variable file. Create a file called my.tfvars
. Below is an example that illustrates the structure of the environment variables file. This example is of a configuration that you can use for the ICAP CDR. Please replace {user}
with your own user.
The AWS account to be used is defined in the ~/.aws/credentials
file. If you don't have file this make sure you have configured the AWS CLI.
The sample file above has access to 3 accounts and the options for <account_name>
could be "default", "jembi-sandbox", "jembi-icap"
Optionally, add ACCOUNT = "<account_name>"
to my.tfvars
if you want to use something other than default
.
The flag for specifying an environment variables file is -var-file
, create the AWS stack by running:
Once the script has run successfully, the ip addresses and domains for the servers will be displayed:
SSH access should be now available - use the default 'ubuntu' user - ssh ubuntu@<ip_address>
Destroying the AWS stack - run:
A tool that enables infrastructure as code for provision of the servers.
Linux OS to run commands
Install Ansible (as per )
Ansible Docker Community Collection installed
Please see the /inventories/{ENVIRONMENT}/hosts
file for IP details of the designated servers. Set these to the server that you created via Terraform or to an on-premises server.
To authenticate yourself on the remote servers your ssh key will need to be added to the sudoers
var in the /inventories/{ENVIRONMENT}/group_vars/all.yml.
To have docker access you need to add your ssh key to the docker_users
var in the /inventories/{ENVIRONMENT}/group_vars/all.yml file.
An authorised user will need to run the provision_servers.yml
playbook to add the SSH key of the person who will run the Ansible scripts to the servers.
Before running the ansible script add the server to your known_hosts
file else ansible will throw an error, for each server run:
To run a playbook you can use:
Alternatively, to run all provisioning playbooks with the development inventory (most common for setting up a dev server), use:
The vault password required for running the playbooks can be found in the database.kdbx
KeePass file.
To encrypt a new secret with the Ansible vault run:
The New password is the original Ansible Vault password.
Copies of all the passwords used here are kept in the encrypted database.kdbx
file.
Please ask your admin for the decryption password of the database.kdbx file.
Infrastructure tools for the OpenHIM Platform
Deploying from your local environment to a remote server or cluster is easy. All you have to do is ensure the remote servers are setup as a Docker Swarm cluster. Then, from your local environment you may target a remote environment by using the `DOCKER_HOST` env var. e.g.
In addition, as part of the OpenHIM Platform Github repository we also provide scripts to easily setup new servers. The Terraform script are able to instantiate server in AWS and the Ansible script are able to configure those server to be ready to accept OpenHIM Platform packages.
See here.
It is used for:
Adding users to the remote servers
Provision of the remote servers in single and cluster mode: user and firewall configurations, docker installation, docker authentication and docker swarm provision.
All the passwords are saved securely using Keepass.
In the inventories, there is different environment configuration (development, production and staging) that contains: users and their ssh keys list, docker credentials and definition of the hosts.
Is used to create and set AWS servers. See here.