From the very beginning, ProjectPlanton was designed to be CI/CD-friendly. The entire framework, from the concept of defining infrastructure as configuration files to the construction of the CLI, was developed with CI/CD integration in mind. By using declarative YAML configuration and a flexible command-line tool, ProjectPlanton makes it easy to adopt continuous deployment practices, ensuring infrastructure as code can be seamlessly automated.
Continuous Integration and Continuous Deployment (CI/CD) are essential practices for efficient infrastructure management and deployment. ProjectPlanton can be easily integrated into a CI/CD workflow using GitHub Actions. This guide walks you through setting up CI/CD using GitHub Actions to automate infrastructure deployment with ProjectPlanton.
Configuration Manifests
A key aspect of ProjectPlanton is its CI/CD compatibility. The configuration files used to define infrastructure can easily be integrated into existing version control practices, allowing for a smooth transition into CI/CD pipelines.
When working with ProjectPlanton and CI/CD, it’s important to properly organize your infrastructure configuration files. Users can choose to either:
- Monorepo: Store all infrastructure configuration files in a single repository.
- Multi-repo Setup: Store configuration files in separate repositories depending on the infrastructure component or team.
Both approaches are supported by ProjectPlanton, but for better maintainability and streamlined CI/CD, using a well-structured directory layout for your configurations is recommended.
Install project-planton
CLI
To automate infrastructure deployments, you need to install the project-planton
CLI in your GitHub Actions workflow. Below is a sample GitHub Action workflow that installs the ProjectPlanton CLI.
Sample GitHub Action to Install ProjectPlanton CLI:
name: Setup ProjectPlanton CI/CD
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v3
# Install the `project-planton` CLI
- uses: project-planton/install-project-planton-cli-action@main
# Ensure that `project-planton` is installed
- run: project-planton version
Pulumi CLI
To deploy infrastructure with ProjectPlanton, the Pulumi CLI must be installed in your GitHub Actions workflow. Below is a GitHub Action that installs the Pulumi CLI.
GitHub Action to Install Pulumi CLI:
- name: Install Pulumi
run: |
curl -fsSL https://get.pulumi.com | sh
export PATH="$PATH:$HOME/.pulumi/bin"
Language-Specific Tools
If you are creating custom Pulumi modules, you will need to ensure that the necessary language-specific tools are also installed. For example, if your Pulumi module is written in Python, you’ll need to install Python and the relevant dependencies. Below, we provide a detailed guide on setting up the environment for different languages.
If you have written your Pulumi module in a specific language, ensure that the required tools are available in your CI/CD pipeline. The following are common language setups for custom Pulumi modules:
Python Pulumi Module
If your Pulumi module is written in Python, add the following steps to install Python and the required packages:
- name: Install Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install Python Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
Node.js Pulumi Module
If your Pulumi module is written in JavaScript or TypeScript, add the following steps to install Node.js and the required dependencies:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install Node.js Dependencies
run: |
npm install
Go Pulumi Module
If your Pulumi module is written in Go, make sure Golang is set up (as shown earlier in the guide):
- name: Install Golang
uses: actions/setup-go@v3
with:
go-version: 1.17
These additional steps will ensure that your custom Pulumi modules, regardless of language, can run properly in the GitHub Actions environment.
In addition to the ProjectPlanton CLI, GitHub Actions will also need to install Pulumi CLI and Golang, as they are required for the infrastructure deployment process. Below is a modified version of the GitHub Action workflow that includes these additional installation steps.
Modified GitHub Action to Install Pulumi CLI and Golang:
name: Setup ProjectPlanton CI/CD
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v3
# Install the `project-planton` CLI
- uses: project-planton/install-cli-action@main
# Ensure that `project-planton` is installed
- run: project-planton version
# Install Pulumi CLI
- name: Install Pulumi
run: |
curl -fsSL https://get.pulumi.com | sh
export PATH="$PATH:$HOME/.pulumi/bin"
# Install Golang
- name: Install Golang
uses: actions/setup-go@v3
with:
go-version: 1.17
Run pulumi up
Once all required tools are installed, including language-specific tools if needed, you can use GitHub Actions to run the pulumi up
command to deploy your infrastructure.
Once all required tools are installed, you can use GitHub Actions to run the pulumi up
command to deploy your infrastructure. Depending on how your infrastructure is structured, you can specify the paths to your configuration files and use ProjectPlanton CLI to invoke Pulumi.
Sample GitHub Action to Deploy Infrastructure:
name: Deploy Infrastructure with ProjectPlanton
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Run `git checkout`
- uses: actions/checkout@v3
# Install the `project-planton` CLI
- uses: project-planton/install-cli-action@main
# Ensure that `project-planton` is installed
- run: project-planton version
# Install Pulumi CLI
- name: Install Pulumi
run: |
curl -fsSL https://get.pulumi.com | sh
export PATH="$PATH:$HOME/.pulumi/bin"
# Install Golang
- name: Install Golang
uses: actions/setup-go@v3
with:
go-version: 1.17
# Run `project-planton pulumi up`
- name: Deploy Infrastructure
run: |
project-planton pulumi up --manifest path/to/your/configuration.yaml
CI/CD Best Practices
- Custom Module Dependencies: Ensure that all language-specific dependencies are properly installed by including steps to set up Python, Node.js, Go, or any other required language for custom Pulumi modules.
- Secrets Management: Ensure that cloud provider credentials are managed securely using GitHub Secrets.
- Environment Separation: Use different branches or workflows to handle infrastructure deployments for different environments (e.g., staging, production).
- Testing: Run infrastructure validation tests before deploying to ensure that configuration errors are caught early.
Summary:
By integrating ProjectPlanton with GitHub Actions, users can set up a complete CI/CD pipeline that automates the process of deploying cloud infrastructure. With a properly organized repository structure, installation of necessary tools, and secure credential management, ProjectPlanton can be used to effectively manage infrastructure as code in a continuous deployment environment.