3. AWS - Provision Infrastructure

Overview

The image below illustrates the multiple components deployed. These include the EKS, Worker Nodes, Postgres DB, EBS Volumes, and Load Balancer.

EKS Architecture for DIGIT Setup

Steps

  1. Clone the DIGIT-DevOps repository:

  1. Navigate to the cloned repository and check out the kubernetes-1.31 branch:

  1. Check if the correct credentials are configured using the command below. Refer to the attached doc to setup the AWS Account on the local machine.

Make sure that the above command reflects the set AWS credentials. Proceed once the details are confirmed. (If the credentials are not set, follow Step 2: Setup AWS account )

  1. Choose either method below to generate SSH key pairs

  1. Add the public key to your GitHub account.

  2. Open input.yaml file in vscode. Use the code below to open it in VS Code:

    code infra-as-code/terraform/sample-aws/input.yaml

    If the command does not work, open the file in VS Code manually. Once the file is open, fill in the inputs. (If you are not using vscode, open it in any editor of your choice).

  3. Fill in the inputs as per the regex mentioned in the comments.

  4. Go to infra-as-code/terraform/sample-aws and run init.go script to enrich different files based on input.yaml.

Terraform Execution: Infrastructure Resources Provisioning

Once we have completed declaring the resources, we begin by deploying all resources.

Run the Terraform scripts to provision the infrastructure required to deploy DIGIT on AWS.

  1. CD (change directory) to the following directory and run the commands below to create the remote state.

Once the remote state is created, it is time to provision the DIGIT infra. Run the commands below:

Important:

  • DB password is asked for in the application stage. Remember the password you have provided. It should be at least 8 characters long. Otherwise, RDS provisioning will fail.

  • The output of the apply command will be displayed on the console. Store this in a file somewhere. Values from this file will be used in the next step of deployment.

2. Use this link to get the kubeconfig from EKS for the cluster. The region code is the default region provided in the availability zones in variables.tf. For example - ap-south-1. EKS cluster name also should've been filled in variables.tf.

3. Verify that you can connect to the cluster by running the following command

At this point, your basic infra has been provisioned.

Note: Refer to the DIGIT deployment documentation to deploy DIGIT services.

Destroying Infra

To destroy the previously created infrastructure with Terraform, run the command below:

  1. ELB is not deployed via Terraform. ELB was created at deployment time by the setup of Kubernetes Ingress. This has to be deleted manually by deleting the ingress service.

    • kubectl delete deployment nginx-ingress-controller -n <namespace>

    • kubectl delete svc nginx-ingress-controller -n <namespace>

      Note: Namespace can be either egov or jenkins.

  2. Delete S3 buckets manually from the AWS console and verify if ELB got deleted.

    • In case ELB is not deleted, you need to delete ELB from the AWS console.

  3. Run terraform destroy.

Sometimes, all artefacts associated with a deployment cannot be deleted through Terraform. For example, RDS instances might have to be deleted manually. It is recommended to log in to the AWS management console and look through the infrastructure to delete any remnants.

Note: Refer to the HCM deployment documentation to deploy HCM services.

Last updated

Was this helpful?