Skip to main content

Automation for Operations

In a Nutshell
What will I learn?In this tutorial, we will create a CI workflow focused on code operations using Autoworx. This workflow will help ensure that your code adheres to best practices and is efficiently deployed, managed, and maintained throughout its lifecycle.
Difficulty

Operation Workflows with worX

What you'll need

Software & Services

GitLab repository

  • A GitLab account and repository to set up your CI/CD pipeline.
  • A GitLab repository with sample Infrastructure as Code (IaC) files. You can fork the Autoworx CI/CD examples repository.
  • A .gitlab-ci.yml file in your repository, which we will be configuring with Autoworx security jobs.
  • An Infracost API key (free. read more below)

Tutorial

In this tutorial, we will walk through the process of setting up various operation jobs in GitLab CI/CD using Autoworx snippets. These jobs will help ensure that your infrastructure is optimized and cost-effective.

Autoworx Operation Jobs

The following Operation jobs will be added to your GitLab CI/CD pipeline:

Infracost (Infrastructure Cost Estimation)

Estimate the cost of your infrastructure before provisioning it to prevent unexpected expenses and optimize resource usage. This step helps you maintain control over your cloud spending and ensures compliance with budget constraints. We use Infracost, a popular infrastructure cost estimation tool, to calculate the cost estimates for the infrastructure defined in your Terraform code.

infracost

Register for a Free Infracost Account

Register for a free API key, which is used by the GitLab job to retrieve prices from our Cloud Pricing API, e.g. get prices for instance types.

  • Navigate to: https://www.infracost.io/docs/ and click "Sign up/Login"
  • Register or login in using your credentials
  • Once logged, click on Org Settings and copy your free the API Key
  • No cloud credentials or secrets are sent to the API and you can also self-host it.
  • Infracost does not make any changes to your Terraform state or cloud resources.
  • Add the API key on the GitLab repository as key INFRACOST_API_KEY and value as API Key

Sample GitLab CI/CD configuration

.gitlab-ci.yml
# This sample GitLab CI/CD configuration is part of the Autoworx tutorial
# and demonstrates a complete CI workflow for various operations-related tasks.
# The pipeline focuses on optimizing code and infrastructure operations, such as calculating
# infrastructure costs using Infracost and other operations-related tasks.
#
# The pipeline consists of the following stages:
# - operations: Run operations-related tasks, such as Infracost for estimating cloud infrastructure costs
#
# Sample code and infrastructure files used in this tutorial can
# be found in the public repository at:
# https://gitlab.com/hestio-community/autoworx/autoworx-cicd-examples

stages:
- operations

include:
- project: 'hest-io/hestio-product/hestio-worx/autoworx/ci/templates'
file:
- 'Jobs/Terraform/terraform-infracost.gitlab-ci.yml'

infracost:
stage: operations

TL;DR

This tutorial guided you through setting up an operations-focused GitLab CI/CD pipeline using Autoworx for an infrastructure-based project. The pipeline includes infrastructure cost estimation using Infracost, ensuring your infrastructure remains cost-effective during development.


Want to find out more?

At Hestio, we have taken our experience with designing and building on cloud to codify these patterns and made them available as a low-code pattern library for AWS. Why spend time and effort on reinventing the wheel when it's already a solved problem? Would you start developing office productivity software in a world where Microsoft Office already exists?

If you'd like to find out about worX, our low-code patterns library for AWS you can read more here or get in touch today to schedule a demo.

If you'd like to find out more about the products and services Hestio has to offer, select one of the options below.