This repository contains the infrastructure-as-code and configuration files to deploy a serverless cloud resume, fulfilling the requirements of the Cloud Resume Challenge.
The Cloud Resume Challenge is a hands-on project designed to demonstrate proficiency in cloud technologies. This repository specifically focuses on deploying the resume using serverless architecture on Azure, leveraging Terraform for infrastructure provisioning and GitHub Actions for CI/CD.
The project utilizes the following Azure services:
- Azure Functions: Hosts the backend API to handle visitor counts.
- Azure Storage (Static Website): Serves the static HTML, CSS, and JavaScript files for the resume website.
- Azure Cosmos DB: Stores the visitor count data.
- Azure AD (Federated Identity Credentials): Enables secure authentication for GitHub Actions to deploy to Azure.
- Serverless Deployment: Leverages Azure Functions and static website hosting for cost-effective and scalable deployment.
- Infrastructure as Code (IaC): Uses Terraform to provision and manage Azure resources.
- Continuous Integration/Continuous Deployment (CI/CD): Implements GitHub Actions workflows for automated deployment.
- Visitor Counter: Implements a dynamic visitor counter using Azure Functions and Cosmos DB.
- Security Best Practices: Uses Federated Identity Credentials to secure Azure deployments from GitHub Actions.
- Automated Code Quality and Security Checks: Implements
tflint
andcheckov
checks in the Github actions workflow.
cloud-resume-challenge-serverless/
┣ .github/
┃ ┗ workflows/
┃ ┣ bcknd.yml
┃ ┣ ci-app.yml
┃ ┣ ci.yml
┃ ┣ infra-cd.yml
┃ ┣ infra-ci.yml
┃ ┗ OIDC.yml
┣ docs/
┃ ┣ architecture.md
┃ ┗ deployment.md
┣ infrastructure/
┃ ┣ environments/
┃ ┃ ┣ dev/
┃ ┃ ┃ ┣ backend.tf
┃ ┃ ┃ ┣ data.tf
┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┣ oidc_dev.tf
┃ ┃ ┃ ┣ terraform-dev.tfvars
┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┗ prod/
┃ ┃ ┣ backend.tf
┃ ┃ ┣ main.tf
┃ ┃ ┗ variables.tf
┃ ┗ modules/
┃ ┣ cosmosdb/
┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┣ output.tf
┃ ┃ ┃ ┗ variables.tf
┃ ┣ functions/
┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┣ output.tf
┃ ┃ ┃ ┗ variables.tf
┃ ┣ infrares/
┃ ┃ ┃ ┣ kv/
┃ ┃ ┃ ┃ ┣ secrets/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┣ rg/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ output.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┗ stg/
┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┗ variables.tf
┃ ┣ monitoring/
┃ ┃ ┃ ┣ azGrafana/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ output.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┗ azPrometheus/
┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┣ output.tf
┃ ┃ ┃ ┗ variables.tf
┃ ┣ networking/
┃ ┃ ┃ ┣ nsg/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┣ nsg_association/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┣ privatedns/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┣ privateendpoint/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┣ subnet/
┃ ┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┃ ┗ variables.tf
┃ ┃ ┃ ┗ vnet/
┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┣ outputs.tf
┃ ┃ ┃ ┗ variables.tf
┃ ┣ OIDC/
┃ ┃ ┃ ┣ data.tf
┃ ┃ ┃ ┣ main.tf
┃ ┃ ┃ ┣ output.tf
┃ ┃ ┃ ┗ variables.tf
┃ ┗ staticwebapp/
┃ ┃ ┣ main.tf
┃ ┃ ┣ output.tf
┃ ┃ ┗ variables.tf
┣ scripts/
┃ ┣ cleanup.sh
┃ ┣ move.ps1
┃ ┗ setup.ps1
┣ src/
┃ ┣ backend/
┃ ┃ ┣ .funcignore
┃ ┃ ┣ .gitignore
┃ ┃ ┣ .pre-commit-config.yaml
┃ ┃ ┣ function_app.py
┃ ┃ ┣ host.json
┃ ┃ ┣ README.md
┃ ┃ ┗ requirements.txt
┃ ┗ frontend/
┃ ┗ index.html
┣ .gitignore
┗ README.md
- Azure subscription
- GitHub account
- Terraform CLI (optional for local testing)
- Azure CLI (optional for local testing)
The deployment is fully automated through the GitHub Actions workflow (oidc.yml
). To deploy the resume:
- Fork this repository.
- Configure Azure Credentials:
- Set up Azure AD Federated Identity Credentials (refer to the workflow file for required secrets).
- Configure the required secrets in your GitHub repository's secrets settings.
- Trigger the Workflow:
- Push changes to the
main
branch. - Manually trigger the
Deploy
workflow from the GitHub Actions tab.
- Push changes to the
The Terraform configuration in infrastructure/environments/dev/oidc/
defines the necessary Azure resources. Ensure you have the correct Azure provider configuration and variables.
The GitHub Actions workflow (oidc.yml
) automates the following steps:
- Checkout Repository: Clones the repository.
- Setup Terraform: Installs Terraform.
- Azure Login: Authenticates with Azure using Federated Identity Credentials.
- Terraform Formatting Check: Checks the Terraform code formatting using
terraform fmt -check
. - Terraform Validation: Validates the Terraform configuration using
terraform validate
. - TFLint: Lints the Terraform code using
tflint
. - Checkov Security Scan: Scans the Terraform code for security vulnerabilities using
checkov
. - Terraform Initialization: Initializes the Terraform working directory.
- Terraform Plan: Generates a Terraform plan.
- Terraform Apply: Applies the Terraform configuration to deploy the resources.
This project is licensed under the MIT License.