Skip to main content

Deploy Using Pulumi

Installing Dependencies

Make sure to install the Pulumi CLI and the Defang CLI.

Make sure you are logged into the Defang CLI. Don't worry about the Pulumi CLI for now.

Project Directory Setup

Create a new directory for your project and navigate to it.

mkdir project && cd project

If you're familiar with Pulumi and/or are already logged in with the Pulumi CLI, you can skip the next step.

If you are new to Pulumi and/or don't have an account, you can "login" to the filesystem by running the following command:

pulumi login file://./

This will make the Pulumi CLI store the state of your infrastructure in the current directory.

Initialize the Project

Run the following command to set your encryption passphrase for this terminal session:

export PULUMI_CONFIG_PASSPHRASE="super-secure-passphrase"

Now let's initialize the Pulumi project:

pulumi new typescript -y --force

This will create a new Pulumi project in the current directory and will create a Pulumi stack called dev by default. We use the --force flag because the directory isn't empty (we created a folder when we logged in with the Pulumi CLI).

Run the following command to add to the .gitignore file:

echo ".pulumi" >> .gitignore

Install the Defang Provider

Run the following command to install the Defang provider:

npm install @defang-io/pulumi-defang

Write the Pulumi Code

Your index.ts file should look like this:

import * as defang from '@defang-io/pulumi-defang/lib';

export const service = new defang.DefangService('minio', {
name: 'minio',
image: 'quay.io/minio/minio',
// starts the server with the console address set to :9001
command: ['server', '--console-address', ':9001', '/data'],
// Set the root username
environment: {
MINIO_ROOT_USER: 'minio',
},
secrets: [
// Set the root password as a secret which will be encrypted at rest
{
source: 'MINIO_ROOT_PASSWORD',
value: 'minio123',
},
],
// Run a healthcheck every 30 seconds
healthcheck: {
test: ['CMD', 'curl', 'http://localhost:9000/minio/health/live'],
interval: 30,
timeout: 5,
retries: 3,
},
// Expose the server on port 9000 and the console on port 9001
ports: [
{
target: 9000,
protocol: 'http',
mode: 'ingress',
},
{
target: 9001,
protocol: 'http',
mode: 'ingress',
},
],
});

Deploy to Defang

warning

At the time of writing, the Defang Pulumi Provider only works with Defang Playground. We are working on BYOC support.

Run the following command to deploy your service:

pulumi up --stack=dev

Monitor the Deployment

You can monitor the deployment by running the following command:

defang tail --name minio

Logging Into Minio

The Defang Playground will give you a domain, which you can obtain by running the following command:

defang ls | grep 'minio.*9001'

If you navigate to the domain in your browser, you will be prompted to log in. Use the username minio and the password minio123.

Clean Up

To clean up the deployment, run the following command:

pulumi destroy --stack=dev