recursive.codes

recursive.codes

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

Querying Autonomous Database from an Oracle Function (The Quick, Easy & Completely Secure Way)

Querying Autonomous Database from an Oracle Function (The Quick, Easy & Completely Secure Way)

I've written many blog posts about connecting to an Autonomous DB instance in the past. Best practices evolve as tools, services, and frameworks become...

Brain to the Cloud - Part III - Examining the Relationship Between Brain Activity and Video Game Performance

Brain to the Cloud - Part III - Examining the Relationship Between Brain Activity and Video Game Performance

In my last post, we looked at the technical aspects of my Brain to the Cloud project including much of the code that was used to collect and analyze the...

Brain to the Cloud - Part II - How I Uploaded My Brain to the Cloud

Brain to the Cloud - Part II - How I Uploaded My Brain to the Cloud

In my last post, we went over the inspiration, objectives, and architecture for my Brain to the Cloud project. In this post, we'll look in-depth at the...

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!