Skip to content

ljwoodley/azure_cloud_resume_challenge

Repository files navigation

Azure Cloud Resume Challenge

Overview

In the pursuit to expand my skills and knowledge in Azure, I embarked on the Azure Cloud Resume Challenge. This repository is the outcome of my efforts, showcasing a cloud-based resume hosted on Azure. My journey included creating cloud resources with Terraform, automating deployments with GitHub Actions, developing a serverless backend function using Azure Functions and crafting a responsive frontend. My primary objective was to design a process that was easily reproducible by adhering to Infrastructure as Code (IaC) principles. This experience enhanced my technical abilities and deepened my understanding of Azure cloud and IaC.

The completed resume can be found at https://www.laurencejwoodley.com.

A blog post on my journey can be found here.

The main knowledge sources used to complete this challenge were:

Prerequisite

Before starting, ensure the following tools are installed on your system:

  1. Azure CLI: For managing Azure resources
  2. Terraform: For creating Azure resources
  3. Python: For running backend scripts and tests
  4. GitHub CLI: For creating repository secrets

Additionally, set up dedicated Azure subscriptions for production and development environments. This ensures that production resources are developed and maintained independently of development resources.

Azure Subscription Setup

You must be logged into an Azure subscription for this project. Follow these steps if you need to log into your subscription.

  1. Azure Account Login: Run az login.

  2. Subscription Verification: Use az account show to show the Azure subscription. If an account switch is needed run

# lists the subscription names
az account list --output table

az account set --subscription <subscription_name>

Development Environment

Complete the following steps for developing on Azure from your local machine. These steps should be completed before any changes are made to terraform scripts. Step 1 is only necessary on initial setup. Steps 2 and 3 are not necessary if you are already logged into the desired subscription.

  1. Terraform Variables: Copy examples/terraform.tfvars to terraform and populate.

  2. Azure Account Login: Refer to the previous section for login instructions.

  3. Initialize Development Environment: Run ./build.sh to set up the Azure development environment.

  4. Clean Up: Once done, run ./destroy.sh to destroy the development environment.

Note, the remaining sections are only necessary for setting up and understanding the CI/CD pipelines.

Configuring Secrets and Azure Credentials for GitHub Actions

OpenID Connect (OIDC) is used to authenticate with Azure from a GitHub Actions workflow. The GitHub docs contain information on setting up a workflow for OIDC.

  1. GitHub Environemnts: Create PROD and TEST GitHub environments.

  2. GitHub Secrets Management: Copy examples/prod.env to prod.env and populate the required variables. The variables are necessary for terraform to build Azure resources. Run gh secret set -f prod.env --env PROD to set the secrets in the PROD environment. Repeat these steps for the TEST environment.

  3. OIDC Configuration: Run the following to configure OIDC and store the credentials in the desired environemnt.

./oidc.sh <APP_NAME> <SUBSCRIPTION_NAME> <GITHUB_ENVIRONMENT>

Testing Process

Tests are automatically triggered upon modifications to any of the following directories: ./terraform, ./backend/api, or ./frontend. This process applies to both pull requests and pushes to the main branch.

Each pull request initiates the build of a fresh Azure testing environment created via .github/workflows/build-test.yml. This ensures that every code change is tested in a clean environment before integration.

Two main tests are ran:

  1. ./backend/tests/test_api.py tests that the API is functional and responsive.

  2. ./backend/tests/test_webpage.py tests that the visit count is displayed on the the webpage.

Production Deployment

The production deployment is triggered when there are changes to ./terraform, ./backend/api or ./frontend directories of the main branch. .github/workflows/deploy-prod.yml orchestrates the deployment by calling several jobs, each tailored to handle specific components of the deployment:

  • Infrastructure Deployment: Azure resources are deployed with Terraform via deploy-azure-resources.

  • Backend Deployment: The severless backend is deployed with deploy-backend

  • Frontend Deployment: The frontend is deployed with deploy-frontend

  • Automated Tests: Tests are executed via .github/workflows/run-tests.yml

These jobs are executed sequentially. Additionally, any job corresponding to a directory without changes will be skipped.

About

Azure cloud resume deployed with Terraform and GitHub Actions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published