Install Using GitHub Actions in AWS
Overview
This guide provides step-by-step instructions for installing DIGIT using GitHub Actions in an AWS environment.
Pre-requisites
Github account - signup
Kubectl installed in the system - installation guide
AWS account - signup
Install AWS CLI locally - installation guide
Postman - installation guide and import data guide
A domain host - (like go daddy to configure you server to a domain)
Install
Prepare AWS IAM User
Create an IAM User in your AWS account - official document
Generate ACCESS_KEY and SECRET_KEY for the IAM user - AWS document
Assign administrator access to the IAM user for necessary permissions.
Set up the AWS profile locally by running the following commands:
aws configure --profile {profilename}
fill in the key values as they are prompted
AWS_ACCESS_KEY_ID: <GENERATED_ACCESS_KEY>
AWS_SECRET_ACCESS_KEY: <GENERATED_SECRET_KEY>
AWS_DEFAULT_REGION: ap-south-1
export AWS_PROFILE={profilename}
Note :: AWS Account should have S3 Bucket access to make Filestore service to work
Fork the GitHub Repositories
Fork the following repositories with all the branches into your organisation account on GitHub:
Master data (We dont need master data repo, since we use mdms-v2 by default with data seeded)
Uncheck the copy, the master only box, as shown below:
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252FH0D5akV6Lh7q9nqOFioc%252FScreenshot%25202024-08-01%2520at%25204.53.01%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D2df290a9-567b-416b-a457-1cf176af305e&width=768&dpr=4&quality=100&sign=74e724be&sv=1)
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252Ft6W2tUcuecZtk5iGuvmF%252FScreenshot%25202024-08-01%2520at%25204.54.18%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D9c4d7b32-5ab3-415d-ae92-d34a3dd432f8&width=768&dpr=4&quality=100&sign=fe8ad77f&sv=1)
Adding AWS Keys to the Repository
Go to the forked health-campaign-devops repository:
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252FVyBXtt3eLqYGbMWTa9o1%252Fsetting%2520and%2520secrets.png%3Falt%3Dmedia%26token%3Df7b358e5-6d47-42cd-931e-143e3bb57a62&width=768&dpr=4&quality=100&sign=c1fe6c20&sv=1)
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252F5IHoZDHP7qfpAT2x7Dhl%252FScreenshot%25202024-08-01%2520at%25205.01.26%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D68c5fc8b-4201-4d91-b75e-a44dfb971e95&width=768&dpr=4&quality=100&sign=1de633fe&sv=1)
Navigate to the repository settings.
Go to Secrets and Variables.
Click on the actions options below secrets and variables.
On the new page, choose the new repository secret option in repository secrets and add the following keys mentioned below:
AWS_ACCESS_KEY_ID: <GENERATED_ACCESS_KEY>
AWS_SECRET_ACCESS_KEY: <GENERATED_SECRET_KEY>
AWS_DEFAULT_REGION: ap-south-1
AWS_REGION: ap-south-1
To Enable Filestore service:
Replace the aws key and secret with the actual value in the environment secret file.
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252Fpjq6hTnBt5joAvsgk34p%252FScreenshot%25202024-08-19%2520at%252012.40.25%2520PM.png%3Falt%3Dmedia%26token%3Dfe453efa-6f55-4389-b2d7-6efd04b489ad&width=768&dpr=4&quality=100&sign=1bbf6b47&sv=1)
Changes to be Made in the Repository
Navigate to the release-githubactions branch in the forked DevOps repository.
Enable GitHub Actions.
Click on Actions, then click on "I understand my workflows, go ahead and enable them":
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252FD1PpDm13KFuXgmFXYX9n%252FScreenshot%25202024-08-01%2520at%25204.55.18%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3Dd9ddee47-538d-4d97-8a28-5e27ee1f28b2&width=768&dpr=4&quality=100&sign=d472ed&sv=1)
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252Fb2DENV001NYOFXYmJjOK%252FScreenshot%25202024-08-01%2520at%25204.55.53%25E2%2580%25AFPM.png%3Falt%3Dmedia%26token%3D7388992a-8c0a-480d-8b30-bf16fb047260&width=768&dpr=4&quality=100&sign=227c7ab7&sv=1)
How to Edit the GitHub Files
The following steps can be done either directly in the browser or the local system if you are familiar with git usage.
Before following any of the steps switch to the release-githubactions branch.
Steps to edit the git repository in the browser - Git guide
Steps to edit in the local system if you are familiar with Git basics:
Git clone {forked DevOps repolink}
Follow the below steps and make changes
Then commit and push to the release-githubactions branch
NOTE: Complete all changes at once then commit and push the code to remote to trigger the installation.
Replace the Master and Configuration Repositories
Note: Make these repository/branch changes before installation; making changes to the configuration repository link in the DevOps repository after installation without understanding what impact they may have will lead to failure in the application functionality.
Navigate to egov-demo.yaml (config-as-code/environments/egov-demo.yaml).
Under the egov-persister: change the gitsync link of the health-campaign-config repository to the forked config repository and the branch to DEMO.
Under the egov-indexer: change the gitsync link of the health-campaign-config repository to the forked config repository and the branch to DEMO.
![](https://health.digit.org/~gitbook/image?url=https%3A%2F%2F3642574345-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FfFR3lGsiPj6krasSLTd4%252Fuploads%252F1A1ObWD94ZF92l8D6Niy%252FScreenshot%25202024-08-01%2520at%25202.21.31%2520PM.png%3Falt%3Dmedia%26token%3Def2a7f6a-99a7-4b63-8f39-4ecaeca38100&width=768&dpr=4&quality=100&sign=aa239570&sv=1)
Configure infrastructure-as-code
Navigate to infra-as-code/terraform/sample-aws.
Open input.yaml and enter details such as domain_name, cluster_name, bucket_name, and db_name.
Configure application secrets
Generate SSH key pair.
How to Generate SSH Key Pair - choose one of the following methods to generate an SSH key pair:
Method a: Use an online website. (Note: This is not recommended for production setups, only for demo purposes): https://8gwifi.org/sshfunctions.jsp
Method b: Use OpenSSL commands:
OpenSSL genpkey -algorithm RSA -out private_key.pem
openssl rsa -pubout -in private_key.pem -out public_key.pem
To view the key run the commands or use any text editor to open the files
vi private_key.pem
vi public_key.pem
Once generated Navigate to config-as-code/environments
Open egov-demo-secrets.yaml
Replace ssh_private_key (note: please make sure the private key is indented as given)
Add the public_key to your GitHub account - Git guide
Finalise Installation
Once all details are entered, push these changes to the remote GitHub repository. Open the Actions tab in your GitHub account to view the workflow. You should see that the workflow has started, and the pipelines are completed successfully.
Configure domain name
Connect to the Kubernetes cluster, from your local machine by using the following command:
Get the CNAME of the nginx-ingress-controller
The output of this will be something like this:
ae210873da6ff4c03bde2ad22e18fe04-233d3411.ap-south-1.elb.amazonaws.com
Add the displayed CNAME to your domain provider against your domain name. e.g. GoDaddy domain provider - https://www.godaddy.com/en-in/help/add-a-cname-record-19236
Last updated