Pulumi Any Terraform

Portainer Provider

Manage container environments with Portainer using Pulumi

The Portainer provider enables you to manage container environments, stacks, users, and teams in Portainer using Pulumi. This provider is dynamically bridged from the Terraform Portainer Provider.

Installation

Install the Portainer provider package using your preferred package manager:

bun add pulumi-portainer
pnpm add pulumi-portainer
yarn add pulumi-portainer
npm install pulumi-portainer

Configuration

Provider Setup

pulumi config set portainer:url https://portainer.example.com
pulumi config set portainer:username admin
pulumi config set portainer:password YOUR_PASSWORD --secret

Or using environment variables:

export PORTAINER_URL="https://portainer.example.com"
export PORTAINER_USERNAME="admin"
export PORTAINER_PASSWORD="your-password"

Quick Start

import * as pulumi from "@pulumi/pulumi";
import * as portainer from "pulumi-portainer";

// Deploy a stack
const stack = new portainer.Stack("web-app", {
    name: "web-application",
    environmentId: 1,
    stackFile: `
version: '3'
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
`,
});

export const stackId = stack.id;

Key Features

Stack Management

const appStack = new portainer.Stack("app", {
    name: "web-application",
    environmentId: environment.id,
    stackFile: stackContent,
});

Environment Management

const environment = new portainer.Environment("docker", {
    name: "Production Docker",
    type: "docker",
    url: "tcp://docker.example.com:2375",
});

User Management

const user = new portainer.User("developer", {
    username: "dev-user",
    password: "secure-password",
    role: 2, // Standard user
});