This repository contains a demonstration of how to use Pulumi for deploying a serverless application to Azure. The project includes Infrastructure as Code (IaC) and Policy as Code (PaC) components. It deploys the following resources:
- Azure Blob Storage Account: Configured for static website hosting.
- Azure Function: A serverless compute resource written in JavaScript.
Figure 1. Architecture of the Azure Serverless Application from the Pulumi website - https://www.pulumi.com/templates/serverless-application/azure/
Before you begin, ensure you have the following prerequisites in place:
-
Pulumi CLI: Install the Pulumi CLI by following the instructions in the official Pulumi documentation.
-
Azure Account: You'll need an Azure account and the Azure CLI installed. If you don't have one, you can create a free account on the Azure portal.
-
Programming Language: Familiarity with the programming language used for your Azure Function is helpful for code customization and understanding.
Follow these steps to set up and deploy the serverless application:
-
Clone the repository
git clone https://github.com/AdoraNwodo/policy-as-code-demo.git cd policy-as-code-demo
-
Initialize Pulumi Project: Initialize your Pulumi project by running:
pulumi login pulumi stack init dev
Configurations already exist in the
Pulumi.dev.yaml
file in this project so you don't need to do anything else. -
Deploy Infrastructure: Deploy the infrastructure using Pulumi by running:
pulumi up
Review the proposed changes and confirm the deployment.
-
Policy as Code (PaC): This project includes Policy as Code (PaC) to enforce specific policies during deployment. Ensure that the policies align with your compliance requirements.
-
Access Your Serverless Application: Once the deployment is complete, you can access your serverless application. The Blob Storage account hosts the static website, and the Azure Function provides dynamic functionality.
-
Clean up (optional) To remove the resources and clean up the deployment, run:
pulumi destroy
Confirm the deletion of resources when prompted.
This project demonstrates the use of Policy as Code (PaC) to enforce policies during infrastructure deployment. The policies are defined in the policy
directory. Customize these policies according to your compliance requirements.
To associate and enforce policies during deployment, use the --policy-pack flag when running pulumi up. For example:
pulumi up --policy-pack policy/
Contributions to this project are welcome. Feel free to open issues, submit pull requests, or provide feedback to help improve this demo 💜
This project is licensed under the MIT License - see the LICENSE.md file for details.