You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/pulumi.md
+94-7Lines changed: 94 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,13 +13,11 @@ import TabItem from '@theme/TabItem';
13
13
Pulumi support is currently only available for Defang Playground. We are working on support for Defang BYOC.
14
14
:::
15
15
16
-
You can use Pulumi to define your Defang services. This allows you to integrate your Defang services with other cloud resources.
16
+
[Pulumi](https://www.pulumi.com) is a modern infrastructure-as-code toolkit that allows developers to use a programming language like Typescript to provision and manage cloud resources.
17
17
18
-
For example, you might define an Aiven PostgreSQL database in your Pulumi code and then use the outputs of that resource to configure the secrets to connect to the database in your Defang service.
18
+
Defang provides a Pulumi [_Provider_](https://www.pulumi.com/docs/iac/concepts/resources/providers/) written in Typescript which can be used to deploy Defang services alongside other Pulumi-managed infrastructure.
19
19
20
-
It also allows you to manage configuration for different environments using Pulumi's config system.
21
-
22
-
## Defang Pulumi Provider
20
+
## Install the Defang Pulumi Provider
23
21
24
22
To get started with Pulumi and Defang you will need to install the Defang provider in [your Pulumi project](https://www.pulumi.com/learn/pulumi-fundamentals/create-a-pulumi-project/):
The Defang Pulumi Provider is a good option for developers with more complex requirements than those supported by a [Compose File](/docs/concepts/compose).
51
+
52
+
One reason to use the Defang Pulumi provider is if you wish to integrate your services with other cloud resources. This is particularly true if you need to configure your services dynamically as other cloud resources are being provisioned.
53
+
54
+
Another reason would be if you want to deploy your services alongside cloud-specific resources, like a DynamoDB table, or an S3 bucket.
50
55
51
-
## Sample
56
+
## Example
52
57
53
58
The following is a minimal example of a Pulumi program that defines a Defang service:
54
59
@@ -63,4 +68,86 @@ const service = new defang.DefangService("my-service", {
63
68
protocol: "http",
64
69
}],
65
70
});
66
-
```
71
+
```
72
+
73
+
:::info
74
+
See the [Deploy using Pulumi](/docs/tutorials/deploy-using-pulumi) tutorial for more information about how to use it.
75
+
:::
76
+
77
+
## API
78
+
79
+
### `DefangService`
80
+
81
+
```typescript
82
+
constructor(
83
+
name: string,
84
+
args: DefangServiceArgs,
85
+
opts?:pulumi.CustomResourceOptions
86
+
)
87
+
```
88
+
89
+
### `DefangServiceArgs`
90
+
91
+
```typescript
92
+
interfaceDefangServiceArgs {
93
+
/** the DNS name of the Defang Fabric service; defaults to the value of DEFANG_FABRIC or prod, if unset */
94
+
fabricDNS?:pulumi.Input<string>;
95
+
/** the name of the service; defaults to the name of the resource */
96
+
name?:pulumi.Input<string>;
97
+
/** the container image to deploy; required when no build configuration was provided */
98
+
image?:pulumi.Input<string>;
99
+
/** the platform to deploy to; defaults to "linux/amd64" */
100
+
platform?:pulumi.Input<Platform>;
101
+
/** which network the service is in, ie. whether the service requires a public IP or not; defaults to "private" (was: internal=true) */
102
+
networks?: { [keyinNetworkName]?:Network };
103
+
/** the optional deployment configuration */
104
+
deploy?:pulumi.Input<Deploy>;
105
+
/** the ports to expose */
106
+
ports?:pulumi.Input<pulumi.Input<Port>[]>;
107
+
/** the environment variables to set; use `null` to mark at sensitive */
Copy file name to clipboardExpand all lines: docs/tutorials/deploy-using-pulumi.mdx
+29-29Lines changed: 29 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,33 +5,41 @@ sidebar_position: 400
5
5
6
6
# Deploy Using Pulumi
7
7
8
+
:::warning
9
+
At the time of writing, the Defang Pulumi Provider only works with [Defang Playground](../concepts/defang-playground.md). We are working on [BYOC](../concepts/defang-byoc.md) support.
10
+
:::
11
+
12
+
This tutorial will show you how to deploy Minio with Pulumi using the Defang Provider.
13
+
8
14
<iframewidth="560"height="315"src="https://www.youtube.com/embed/A4uiP5FIgg0?si=BHZLOxN4noJ56f7x"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>
9
15
10
-
## Installing Dependencies
16
+
## Pre-requisites
11
17
12
-
Make sure to install the [Pulumi CLI](https://www.pulumi.com/docs/install/) and the [Defang CLI](../getting-started#install-the-defang-cli.md).
Make sure you are logged into the [Defang CLI](/docs/concepts/authentication.md). Don't worry about the Pulumi CLI for now.
15
26
16
-
## Project Directory Setup
27
+
## Step 2 - Configure the Pulumi Backend
17
28
18
-
Create a new directory for your project and navigate to it.
29
+
Navigate to your project directly. (If you don't have a project yet, try one of our [samples](https://defang.io/#samples))
19
30
20
-
```bash
21
-
mkdir project &&cd project
22
-
```
23
31
24
-
If you're familiar with Pulumi and/or are already logged in with the Pulumi CLI, you can skip the next step.
32
+
Pulumi uses the `pulumi login` command to select a backend. In this tutorial, we will use the Local Filesystem backend for simplicity. When you are ready to deploy to production, you will probably want to look into other [Pulumi backend options](https://www.pulumi.com/docs/iac/concepts/state-and-backends).
25
33
26
-
If you are new to Pulumi and/or don't have an account, you can "login" to the filesystem by running the following command:
34
+
Run the following command to "login" to the filesystem backend in the local directory.
27
35
28
36
```bash
29
37
pulumi login file://./
30
38
```
31
39
32
40
This will make the Pulumi CLI store the state of your infrastructure in the current directory.
33
41
34
-
## Initialize the Project
42
+
## Step 3 - Initialize the Pulumi Project
35
43
36
44
Run the following command to set your encryption passphrase for this terminal session:
37
45
@@ -53,17 +61,9 @@ Run the following command to add to the `.gitignore` file:
53
61
echo".pulumi">> .gitignore
54
62
```
55
63
56
-
## Install the Defang Provider
57
-
58
-
Run the following command to install the Defang provider:
59
-
60
-
```bash
61
-
npm install @defang-io/pulumi-defang
62
-
```
63
-
64
-
## Write the Pulumi Code
64
+
## Step 4 - Write Your Pulumi Code
65
65
66
-
Your `index.ts` file should look like this:
66
+
Create an `index.ts` file to contain your Pulumi code. This code will describe our services, our service's dependencies, and our service's configuration.
@@ -107,27 +107,23 @@ export const service = new defang.DefangService('minio', {
107
107
});
108
108
```
109
109
110
-
## Deploy to Defang
111
-
112
-
:::warning
113
-
At the time of writing, the Defang Pulumi Provider only works with [Defang Playground](../concepts/defang-playground.md). We are working on [BYOC](../concepts/defang-byoc.md) support.
114
-
:::
110
+
## Step 5 - Deploy to Defang
115
111
116
-
Run the following command to deploy your service:
112
+
Now we're ready to deploy to Defang with Pulumi! Run the following command to deploy your service:
117
113
118
114
```bash
119
115
pulumi up --stack=dev
120
116
```
121
117
122
-
## Monitor the Deployment
118
+
## Step 6 - Monitor the Deployment
123
119
124
120
You can monitor the deployment by running the following command:
125
121
126
122
```bash
127
123
defang tail --name minio
128
124
```
129
125
130
-
## Logging Into Minio
126
+
###Logging Into Minio
131
127
132
128
The [Defang Playground](../concepts/defang-playground.md) will give you a domain, which you can obtain by running the following command:
133
129
@@ -137,10 +133,14 @@ defang ls | grep 'minio.*9001'
137
133
138
134
If you navigate to the domain in your browser, you will be prompted to log in. Use the username `minio` and the password `minio123`.
139
135
140
-
## Clean Up
136
+
###Clean Up
141
137
142
138
To clean up the deployment, run the following command:
143
139
144
140
```bash
145
141
pulumi destroy --stack=dev
146
142
```
143
+
144
+
---
145
+
146
+
See the [Pulumi concept docs](/docs/concepts/pulumi) for more information about the Defang Pulumi Provider.
0 commit comments