top of page
  • Writer's pictureShaked Braimok Yosef

How to create your first template using Cookiecutter 🙌

As promised in the previous post, we are starting an interesting series about TEMPLATES. I'll also be publishing tutorials, so if you haven't subscribed to our YouTube channel yet, don't miss out:

In this post, we'll provide a quick overview of Cookiecutter and how it can be used for our Platform templates.


What is Cookiecutter?

"Cookiecutter is a templating library for creating boilerplate for projects in any programming language. In this article, we will delve deeper into Cookiecutter’s capabilities, use cases, and trade-offs." (https://Cookiecutter.io)


As a Platform Engineer,

your role involves creating and serving templates for developers, including pipeline templates, infrastructure templates, service code templates, and more. Cookiecutter offers an easy way to create and use templates, and it can also be integrated with developer portals such as Backstage and Port. By utilizing Cookiecutter, you can provide an amazing onboarding experience for developers who are creating new services and projects.


How to create a template?

Let's learn together by using Senora's template for CloudFormation to create a VPC Lambda. You can find the link to the Github repository at the end of this post.


1. Create a cookiecutter.json file

(you can also use the YAML format) and add the keys that you want to replace in the template.


2. Create the template files

You can create any files you want to duplicate for the developers, making it easier and quicker for them to create new projects while maintaining the standards and conventions of the organization.


You can use the {{cookiecutter}} keys in the file names, like this:



How to use a template?

There are several ways to create a new service from the template, such as:

  • Using the Cookiecutter CLI command (similar to the one I used in the screen recording below).

  • Utilizing the scaffolder feature in a Developers-Portal (Recommended).

  • Installing the Cookiecutter VSCode plugin and using it within the VSCode UI.




That's all! 😎

If you want to learn more about template strategies and methods, our Platform Engineering course will be published very soon. Stay tuned! 🚀


Comments


bottom of page