Deploy containerized services to Azure with Pulumi.
Project description
Defang Pulumi Provider
The Pulumi Providers for Defang — Take your app from Docker Compose to a secure and scalable cloud deployment with Pulumi. Develop once, deploy anywhere.
The repo also contains the source of our CD program in the cd/ directory, which serves as the
driver for the Defang deployments: it receive a Compose file, translates it to a Pulumi program, and runs pulumi up (or destroy etc.) to (de)provision the resources in it.
Most users will want to use these components through the Defang CLI, which connects to your cloud account, bootstraps the CD environment and runs the CD image built by this repo.
If you're a Pulumi user, check out our Pulumi Registry listing for installation instructions, API docs, and example usage of using the providers in your own Pulumi programs.
The examples/ directory in this repo also contains complete working samples for all clouds and languages, incuding examples/multi-cloud which deploys a single Compose app to all three clouds from a single Pulumi program.
Components
Each provider (defang-aws, defang-gcp, defang-azure) exposes the same Pulumi resource palette:
Project— the recommended entry point. Takes a fullservicesmap (Compose-style) and provisions shared infrastructure (VPC, networking, DNS, load balancers, build pipelines) alongside each service.Service— a single container service. Standalone use is image-only:imagemust refer to a pre-built image. Build-from-source is aProjectresponsibility because it needs the shared build pipeline (Artifact Registry + Cloud Build on GCP, ECR + CodeBuild on AWS, ACR on Azure).Build(AWS only) — an image-build resource used internally byProject.Postgres/Redis— managed database / cache components. Can be used standalone or as part of aProject.
Managed components (Service, Postgres, Redis) share one implementation between standalone and project-scoped use. Standalone instantiations skip the shared-infra provisioning and therefore don't support features that depend on it (VPC access, build-from-source, external load-balancer wiring).
Resource naming
When creating Pulumi resources, these Pulumi components will only specify the logical names, which is either the service name (e.g. app) or a name to describe the resource's role (e.g. shared-vpc, ecr-public).
The physical name of the underlying cloud resource is determined by the Pulumi engine. By default, this will be the logical name followed by a hyphen and 7 random hex characters (e.g. app-abc1234).
To control the physical name, configure autonaming rules in the Pulumi configuration files, either globally or per resource type. See the Pulumi autonaming docs for details. See the CD code for examples of how autonaming is used in Defang.
Installation and Configuration
See our Installation and Configuration docs
Development
See the Contributing doc.
Example usage
The examples below use AWS. GCP and Azure follow the same pattern — just swap the package name (e.g. defang-aws → defang-gcp).
Complete working samples for all clouds and languages are in the ./examples directory.
{{< chooser language "typescript,python,go,dotnet,yaml" >}} {{% choosable language typescript %}}
import * as pulumi from "@pulumi/pulumi";
import * as defang_aws from "@defang-io/pulumi-defang-aws";
const awsDemo = new defang_aws.Project("aws-demo", {services: {
app: {
image: "nginx",
ports: [{
target: 80,
mode: "ingress",
appProtocol: "http",
}],
},
}});
export const endpoints = awsDemo.endpoints;
{{% /choosable %}}
{{% choosable language python %}}
import pulumi
import pulumi_defang_aws as defang_aws
aws_demo = defang_aws.Project("aws-demo", services={
"app": {
"image": "nginx",
"ports": [{
"target": 80,
"mode": "ingress",
"app_protocol": "http",
}],
},
})
pulumi.export("endpoints", aws_demo.endpoints)
{{% /choosable %}}
{{% choosable language go %}}
package main
import (
defangaws "github.com/DefangLabs/pulumi-defang/sdk/v2/go/defang-aws"
"github.com/DefangLabs/pulumi-defang/sdk/v2/go/defang-aws/compose"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
awsDemo, err := defangaws.NewProject(ctx, "aws-demo", &defangaws.ProjectArgs{
Services: compose.ServiceConfigMap{
"app": &compose.ServiceConfigArgs{
Image: pulumi.String("nginx"),
Ports: compose.ServicePortConfigArray{
&compose.ServicePortConfigArgs{
Target: pulumi.Int(80),
Mode: pulumi.String("ingress"),
AppProtocol: pulumi.String("http"),
},
},
},
},
})
if err != nil {
return err
}
ctx.Export("endpoints", awsDemo.Endpoints)
return nil
})
}
{{% /choosable %}}
{{% choosable language dotnet %}}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DefangAws = DefangLabs.DefangAws;
return await Deployment.RunAsync(() =>
{
var awsDemo = new DefangAws.Project("aws-demo", new()
{
Services =
{
{ "app", new DefangAws.Compose.Inputs.ServiceConfigArgs
{
Image = "nginx",
Ports = new[]
{
new DefangAws.Compose.Inputs.ServicePortConfigArgs
{
Target = 80,
Mode = "ingress",
AppProtocol = "http",
},
},
} },
},
});
return new Dictionary<string, object?>
{
["endpoints"] = awsDemo.Endpoints,
};
});
{{% /choosable %}}
{{% choosable language yaml %}}
name: defang-aws
runtime: yaml
description: Example using defang-aws to deploy services to AWS
plugins:
providers:
- name: defang-aws
path: ../../bin
resources:
aws-demo:
type: defang-aws:index:Project
properties:
services:
app:
image: nginx
ports:
- target: 80
mode: ingress
appProtocol: http
outputs:
endpoints: ${aws-demo.endpoints}
{{% /choosable %}} {{< /chooser >}}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pulumi_defang_azure-2.0.0b5.tar.gz.
File metadata
- Download URL: pulumi_defang_azure-2.0.0b5.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddcc7a68c5680e053d31d7185077089f4c64fcc14a0b0985c9d136dfc41ea1cd
|
|
| MD5 |
836a8d99f3a2a13a8eb3daeb0512b13b
|
|
| BLAKE2b-256 |
2153f7c83bdd1cf6707fd4697040b4c22f46782445303eac37e279716e6790b9
|
Provenance
The following attestation bundles were made for pulumi_defang_azure-2.0.0b5.tar.gz:
Publisher:
release.yml on DefangLabs/pulumi-defang
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pulumi_defang_azure-2.0.0b5.tar.gz -
Subject digest:
ddcc7a68c5680e053d31d7185077089f4c64fcc14a0b0985c9d136dfc41ea1cd - Sigstore transparency entry: 1454048823
- Sigstore integration time:
-
Permalink:
DefangLabs/pulumi-defang@559f3106a3c63ebdee4e434cae519ec78e312039 -
Branch / Tag:
refs/tags/v2.0.0-beta.5 - Owner: https://github.com/DefangLabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@559f3106a3c63ebdee4e434cae519ec78e312039 -
Trigger Event:
push
-
Statement type: