Pulumi is an open-source infrastructure as code (IaC) tool that enables you to define, provision, and manage cloud infrastructure using familiar programming languages like Python, TypeScript, JavaScript, Go, .NET, and Java. It bridges the gap between traditional IaC tools and modern cloud development practices, offering flexibility, productivity, and collaboration benefits.
1. **Creating an AWS S3 Bucket (TypeScript):**
```typescript import * as aws from “@pulumi/aws”;
const bucket = new aws.s3.Bucket(“my-bucket”); ```
2. **Deploying a Kubernetes Deployment (Python):**
```python import pulumi import pulumi_kubernetes as k8s
app_labels = { “app”: “nginx” } deployment = k8s.apps.v1.Deployment(“nginx”,
spec={ "selector": { "match_labels": app_labels }, "replicas": 1, "template": { "metadata": { "labels": app_labels }, "spec": { "containers": [{ "name": "nginx", "image": "nginx:latest", "ports": [{ "container_port": 80 }] }], } } })```
3. **Provisioning an Azure Resource Group (C#):**
```csharp using Pulumi; using Pulumi.AzureNative.Resources;
var resourceGroup = new ResourceGroup(“my-resource-group”, new ResourceGroupArgs {
Location = "West US"}); ```
These examples demonstrate how Pulumi allows you to define infrastructure using code in different programming languages, simplifying provisioning and management across various cloud platforms.