recursive.codes


The Personal Blog of Todd Sharp

IaC in the Cloud: Integrating Terraform and Resource Manager into your CI/CD Pipeline - Release Assets

Posted By: Todd Sharp on 3/12/2021 1:00 GMT
Tagged: Cloud, Cloud, Cloud Native, Cloud Native

Welcome back to this series where we’re learning all about using Terraform and Resource Manager to manage your infrastructure in the Oracle Cloud. In part 1, we learned the basics of Terraform that a developer needs to know to get started working with it. In part 2, we installed and ran our very first Terraform script. Part 3 took us into the cloud and we ran our first Terraform script with Resource Manager and we took it a step further in part 4 where we introduced variable input and validation in to the process with Resource Manager schema documents. In this post, we’re going to start wrapping up the series by talking about how we might distribute our Terraform Infrastructure as Code and how we can integrate Terraform and Resource Manager into our build process via our CI/CD pipeline. We’ll look specifically at GitHub and GitHub Actions, but certainly the process would be similar for other CI/CD tools. 

Adding a Workflow To Create a Distributable Stack With GitHub Actions

The first quick thing I want to cover in this post is creating a distributable stack from your Terraform scripts. Basically what that means is creating a .zip file that you can share with other developers so that they can run your script in their own tenancy. Certainly the archive can be used in your own tenancy, but, we’ll look at better solutions for that down below. Creating a zip with GitHub Actions is pretty easy, just add a YAML file in your repository in the directory .github/workflows and call it build-stack.yaml

The gist of this workflow is that every time a new ’tag’ version is pushed to GitHub, the workflow will:

Here’s the YAML file.

For my demo repo, I saved this file and tagged and pushed to GitHub. Once the job is complete, you can go to your “Releases” page for the repo and see that the zip has been published.

Tip:  Your latest releases are always found at https://github.com/[user name]/[repo name]/releases/latest.

Adding a “Deploy to Oracle Cloud” Button to Your Project

Now that you’ve got a nice zip that others can use, why not add a simple ‘Deploy to Oracle Cloud’ button to your README.md so that others can deploy your stack with one click? Just follow the format defined in the docs and paste the markup into your README.md.

Check out my repo for this blog post to see it in action at https://github.com/recursivecodes/oci-resource-manager-demo.

Summary

This was a quick, but I think important blog post in this Terraform series where we learned how to use GitHub Actions to create and publish a release asset and add a ‘Deploy to Oracle Cloud’ button to our GitHub repos. In the next post, we’ll look at how we can create our Resource Manager stacks and jobs in our pipeline and apply those jobs directly from our CI/CD workflow. 

Photo by Nazrin B-va on Unsplash



Related Posts

Enterprise Messaging via Oracle Advanced Queuing with Autonomous DB & Micronaut

Enterprise Messaging via Oracle Advanced Queuing with Autonomous DB & Micronaut

I’ve written about messaging many, many times on this blog. And for good reason, too. It’s a popular subject that developers can’t seem to get enough of...

How to Securely Connect to Private Resources (for Free!) via the OCI Bastion Service

How to Securely Connect to Private Resources (for Free!) via the OCI Bastion Service

When working in the cloud, there are often times when your servers and services are not exposed to the public internet. Private virtual cloud networks ...

How To Set Up and Run a (Really Powerful) Free Minecraft Server in the Cloud

How To Set Up and Run a (Really Powerful) Free Minecraft Server in the Cloud

In this post, I’m going to show you how to set up and run your very own private, dedicated Minecraft server in the cloud. I have blogged about this before...

Note: Comments are currently closed on this blog. Disqus is simply too bloated to justify its use with the low volume of comments on this blog. Please visit my contact page if you have something to say!