Announcing Koyeb Pulumi Provider
8 minToday, we are glad to share that you can interact with your Koyeb resources in your infrastructure using Pulumi.
Pulumi is a modern infrastructure as code platform that allows you to define, deploy, and manage cloud infrastructure on any cloud using your favorite programming languages.
This provider enhances the Koyeb developer toolbox, which already includes the Koyeb CLI, API and SDKs to keep the developer experience easy, intuitive and integrate with tools you already use.
In this article, we will showcase how to deploy a simple Golang application on Koyeb using Pulumi by writing infrastructure code in TypeScript, Golang, and Python.
What is Pulumi?
Pulumi is a tool for defining, deploying and managing cloud infrastructure using general-purpose programming languages including TypeScript, Python, C#, and Golang. This means that you can use the same programming language you use for your application to define your infrastructure and get strong type checking, functions, loop constructs, and other features that make it easier to write and maintain your infrastructure.
The Koyeb Pulumi provider allows you to manage all Koyeb resources such as apps, services, domains, and so on. Deployments are performed from the Pulumi CLI and can also be integrated with your CI/CD pipeline.
Installing Pulumi and the Koyeb provider
If you are not already using Pulumi, check out Pulumi's installation instructions to learn how to install Pulumi for your system.
Configure your API key
To be able to manage Koyeb resources using Pulumi, you first need a Koyeb API access token to allow Pulumi to authenticate to Koyeb. To retrieve your Koyeb API access token, go to your Account settings and click the Create API Access Token button.
Give your API access token a name and description to differentiate it from other tokens and save the generated token in a safe place as you will not be able to see it again.
Then, to use your Koyeb API access token to authenticate the Koyeb Pulumi provider, set the KOYEB_TOKEN environment variable running the following command:
We are now ready to create and deploy our first application using Pulumi.
Create a new Pulumi project
With the previous steps completed, we are now ready to create a new Pulumi project. A Pulumi project contains a Pulumi.yaml
and all projects specify which runtime to use and indicate where to find the program that should be executed during deployments.
Open your terminal and navigate to a location of your choice and create a directory that will store the Pulumi project:
Within the newly created directory, run one of the following commands to create a new Pulumi project depending on the language you want to use:
Python
Golang
Typescript
With the project created, the next step is to install the Koyeb Pulumi provider. As for the previous step, this operation depends on the language you chose to use.
Python
Golang
TypeScript
The Pulumi project is now properly configured with the Koyeb provider installed. In the next step, we will create the infrastructure code to deploy our sample application on Koyeb.
Create the infrastructure code to deploy a Golang application on Koyeb
The Pulumi project created in the previous step generates a set of files that vary depending on the language you chose. The entry point file where we will write our infrastructure code is:
index.ts
for TypeScriptmain.go
for Golang__main__.py
for Python
You may notice a Pulumi.yaml
file is also present in the project directory. This file contains the project metadata such as the name, description, and the programming language used.
To be able to deploy our sample Golang application on Koyeb, we will need to create two Koyeb resources:
Depending on the language you selected, use the appropriate infrastructure code below to create the App and Service resources on Koyeb:
Python
Golang
TypeScript
Provision the resources on Koyeb
We are now ready to provision the resources and deploy our sample application on Koyeb. In your terminal, run the following command to generate the graph of the resources that will be created.
In our case the graph is pretty simple and shows a wealth of information about the resources that will be created such as the type and name of the resources that will be created.
As everything looks as expected, we can now run the following command to provision our resources and deploy our application on Koyeb.
Your resources are then created and our Golang sample application is being deployed. If you go to the Koyeb control panel, you should see the Koyeb app and service have been created successfully. Once your Koyeb service becomes healthy, you can perform a request to the Koyeb app public URL to see the sample application in action.
Conclusion
You now have everything you need to manage your Koyeb resources using Pulumi. We covered how to use the Koyeb Pulumi provider to provision resources and deploy a sample Golang application on Koyeb using infrastructure-as-code written in Python, Golang, and TypeScript.
The provider is available via the official Pulumi Registry and you can learn more about available resources and how to use them by reading the documentation.
If you have any comments or simply want to contribute, the code is available on GitHub. If you have an idea to improve the platform, you can tell us on our request platform. Lastly, if you want to join our mission to build Koyeb, we are hiring! Check out our careers pages for more information.
Want to stay in the loop about what is going on at Koyeb? Join the friendliest serverless community or tweet us at @gokoyeb.
Ready to give the platform a try? Create your account and receive $5 per month of free credit. That is the equivalent of two nano services, which means you can use up to 512MB of RAM. 😉