Skip to content

Latest commit

 

History

History
183 lines (121 loc) · 6.75 KB

infrastructure.md

File metadata and controls

183 lines (121 loc) · 6.75 KB

Infrastructure

Deployment to AWS with Terraform

Pre-requisites

Before deploying the infrastructure to AWS using Terraform, ensure you have the following pre-requisites:

  1. Terraform installed on your local machine.
  2. An AWS account with the necessary permissions to create and manage EC2 instances.
  3. AWS CLI installed and configured with the necessary credentials.

Steps

  1. Clone the repository to your local machine:
# NB: SKIP THIS STEP if you have already cloned the repository

git clone https://github.com/ndamulelonemakh/zabantu-beta.git
  1. Navigate to the infra directory:
cd zabantu-beta/infra
  1. Configure your AWS credentials using the AWS CLI:
aws configure

Note: You will need to create an IAM user with programmatic access and attach the necessary permissions to create and manage EC2 instances. The access key and secret key generated for the IAM user will be used to configure the AWS CLI.

  1. Review and modify the aws_dvsm.tf file according to your requirements. Update the instance type, region, and any other relevant configurations.
  2. Initialize the Terraform working directory:
terraform init
  1. Preview the changes that Terraform will make:
terraform plan
  1. If the plan looks good, apply the changes to provision the EC2 instance:
terraform apply

Confirm the changes by typing "yes" when prompted.

  1. Once the provisioning is complete, Terraform will output the public IP address of the EC2 instance. Use this IP address to connect to the instance via SSH.
ssh ubuntu@<public-ip-from-terraform-output>

Deployment to Google Cloud with Terraform

Pre-requisites

Before deploying the infrastructure to Google Cloud using Terraform, ensure you have the following pre-requisites:

  1. Terraform installed on your local machine.
  2. A Google Cloud account with the necessary permissions to create and manage Compute Engine instances.
  3. Google Cloud Service Account and a JSON Key File for authentication.

Steps

  1. Clone the repository to your local machine:
# NB: SKIP THIS STEP if you have already cloned the repository

git clone https://github.com/ndamulelonemakh/zabantu-beta.git
  1. Navigate to the infra directory:
cd zabantu-beta/infra
  1. Configure your Google Cloud credentials by setting the path to the service account key file in the GOOGLE_APPLICATION_CREDENTIALS environment variable, or by using the gcloud command-line tool to authenticate.
# Example for authenticatiing using gcould

gcloud auth activate-service-account --key-file=service-account-key.json
  1. Review and modify the gcp_dvsm.tf file according to your requirements. Update the instance type, region, and any other relevant configurations.
  2. Initialize the Terraform working directory:
terraform init
  1. Preview the changes that Terraform will make:
terraform plan
  1. If the plan looks good, apply the changes to provision the Compute Engine instance:
terraform apply

Confirm the changes by typing "yes" when prompted.

  1. Once the provisioning is complete, Terraform will output the public IP address of the Compute Engine instance. Use this IP address to connect to the instance via SSH.

Deployment to Azure with Bicep

Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively. It aims to drastically simplify the authoring experience with a cleaner syntax and better support for modularity and code re-use compared to ARM templates.

Pre-requisites

Before you can use the provided Bicep scripts to deploy your infrastructure on Azure, you need to have the following pre-requisites:

  1. Azure Account: You need to have an Azure account. If you don't have one, you can create it from the Azure portal.

  2. Azure CLI: You need to have the Azure CLI installed on your local machine. You can download it from the official website. Make sure to install a version that is compatible with the scripts provided in this repository.

  3. Bicep CLI: You need to have the Bicep CLI installed on your local machine. You can download it from the official GitHub repository.

Authentication

To authenticate with Azure, you can use the Azure CLI. Run the following command and follow the instructions:

az login

# If you are using a managed identity, you can run the following command
#az login --identity

# Or if you want to opt for device login
#az login --use-device-code
  • This will open a new window in your default web browser where you can log in with your Azure credentials. Once you're logged in, the CLI will be able to manage resources in your Azure account.

Deployment

  • To deploy your infrastructure with Bicep, run the following command:
az group create --name myrg100 --location westeurope
az deployment group create --name MyGPUVmDeplyment0010 \
                           --resource-group myrg100 \
                           --template-file infra/azure_dvsm.bicep \
                           --parameters location=westeurope adminUsername=ubuntu vmName=myT4Vm010
  • Replace myrg100, MyGPUVmDeplyment0010, westeurope, ubuntu, and myT4Vm010 with your desired settings.

Single Click Deployment

  • You can also deploy the infrastructure directly from the GitHub repository using the "Deploy to Azure" button.
  • Click on the button below to deploy the infrastructure to Azure:

Deploy to Azure

  • Similarly, for AWS:

[![Deploy to AWS](https://

  • And GCP:

[![Deploy to GCP](https://