Service Creation unlocks a fully-automated workflow for spinning up new projects, including microservices, libraries, and more. Using templatization, Cortex's Service Creation product allows you to automatically generate the boilerplate and plumbing for new projects, ensuring they follow best practices from day 0.
The Service Creation product enables templating using the open source Cookiecutter project. Cookiecutter is the industry-standard tool to auto-generate boilerplate for your new projects.
Setting up your template
Cookiecutter templates define their variables in a special
cookiecutter.json file in the root of the template repository. To
use an existing template with Cortex's Service Creation product, you'll need to add a
version key to your
cookiecutter.json will look something like the following:
"project_name": "My Project",
"database": ["postgres", "mysql"],
This allows Cortex to track which version of the template was used to generate a given project in the Catalog.
Security restrictions for templates
For security reasons, for templates used on Cortex Cloud, we disable Cookiecutter hooks, network access, and any syscalls. If you get an exception when using your template, ensure it's not attempting any of these restricted actions.
These features are enabled for templates when using Cortex Server (self-hosted).
Adding the template to Cortex
Once you've set up your Cookiecutter template, navigate to Settings -> Service Templates.
Service Creation requires Git with write access
Give your template a name, which will be seen by developers when they try to create a service using the template.
Optionally, add tags to describe the template. For example, they can help developers understand whether the template is meant to be used for creating a library/backend/frontend, which language it uses, and more.
Point Cortex to the Git repo where the template lives (with the
cookiecutter.json at the root of this repo).
Cortex expects only one template per repo.
Using your template
Once you've set up your Git provider with the right permissions, created a template, and added it to Cortex, you can start creating new projects!
On the sidebar, you'll see a tab called "Service Creation". Here, you'll find all the templates that are available to your organization.
After selecting a template, fill out the form, follow the flow, and Cortex will create your repo, push the templated code, and add the service to the catalog.
Cortex will never push code to an existing repo. If the desired repo already exists, Cortex will throw an error and prevent the flow from continuing.