### Starting Backstage Backend (Yarn) Source: https://github.com/pulumi/workshops/blob/main/build-a-self-service-platform-for-oracle-cloud-with-pulumi/00-backstage/backstage/packages/backend/README.md This command starts the Backstage example backend application. It should be run from within the `packages/backend` directory after dependencies have been installed. ```bash yarn start ``` -------------------------------- ### Starting Backstage Application (Shell) Source: https://github.com/pulumi/workshops/blob/main/build-a-self-service-platform-for-oracle-cloud-with-pulumi/00-backstage/backstage/README.md This snippet provides the shell commands required to install project dependencies and start the Backstage development server. `yarn install` fetches all necessary packages, and `yarn dev` launches the application in development mode. ```Shell yarn install yarn dev ``` -------------------------------- ### Pulumi Project Initialization Wizard Output (Shell) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md Displays the interactive output of the `pulumi new` command, guiding the user through project and stack name creation, AWS region configuration, and dependency installation. It confirms the successful setup of a new Pulumi project. ```shell This command will walk you through creating a new Pulumi project. Enter a value or leave blank to accept the (default), and press . Press ^C at any time to quit. project name (aws-getting-started-lambda-ts): project description (A minimal AWS TypeScript Pulumi program): Created project 'aws-getting-started-lambda-ts' Please enter your desired stack name. To create a stack in an organization, use the format / (e.g. `acmecorp/dev`). stack name (dev): dev Created stack 'dev' aws:region: The AWS region to deploy into (us-east-1): eu-central-1 Saved config Installing dependencies... added 340 packages, and audited 341 packages in 14s 82 packages are looking for funding run `npm fund` for details found 0 vulnerabilities Finished installing dependencies Your new project is ready to go! ✨ To perform an initial deployment, run `pulumi up` ``` -------------------------------- ### Full Setup Commands for Pulumi GCP Project (Bash) Source: https://github.com/pulumi/workshops/blob/main/cloud-engineering-with-gcp/python/content/lab-01/README.md This comprehensive set of bash commands guides a presenter through the entire setup process for a new Pulumi GCP project using Python. It includes creating a directory, initializing the Pulumi project, activating the virtual environment, adding the GCP provider to `requirements.txt`, installing dependencies, and configuring the GCP project ID. This snippet provides a quick reference for a complete setup. ```bash mkdir my-first-gcp-app cd my-first-gcp-app pulumi new python -y source venv/bin/activate echo "pulumi_gcp>=6.0.0,<7.0.0" >> requirements.txt pip3 install -r requirements.txt pulumi config set gcp:project pulumi-workshops-project ``` -------------------------------- ### Setting Up Lambda Function Application Directory (Bash) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md Creates a new directory named `app`, navigates into it, initializes a new Node.js project, and installs development and runtime dependencies required for the AWS Lambda function, including `aws-lambda` types, `esbuild`, and `node-fetch`. ```bash mkdir app cd app npm init -y npm install -D @types/aws-lambda esbuild npm install node-fetch --save ``` -------------------------------- ### Initializing a New Pulumi YAML Project Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command initializes a new Pulumi project using the YAML template, guiding the user through project and stack creation. It sets up the basic project structure. ```bash pulumi new yaml ``` -------------------------------- ### Installing Pulumi Docker Provider (Bash) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md Navigates back to the root project directory and installs the `@pulumi/docker` package. This package provides the necessary resources and functions for Pulumi to interact with Docker, enabling the management of Docker images and registries. ```bash cd .. npm install @pulumi/docker --save ``` -------------------------------- ### Creating a New Pulumi Project with a Template in Bash Source: https://github.com/pulumi/workshops/blob/main/github-aws-cicd-getting-started/README.md This snippet demonstrates how to initialize a new Pulumi project using a template. It provides two methods: an interactive prompt-based approach for learners and a non-interactive advanced setting. It also includes commands to update and install npm dependencies. ```bash # To walk through the prompts **recommended for learners** $ mkdir infra && cd infra $ pulumi new # Select template # Select static-website-aws-typescript # Project name: live-workshop # Description: to select the default # Stack name: dev # Select defaults for the remaining prompts # Wait a few seconds while dependencies are installed # Or, using advanced settings $ pulumi new static-website-aws-typescript --dir infra --template-mode --stack dev --name live-workshop --yes --non-interactive # Wait a few seconds while dependencies are installed # Note: The --dir specified will be created if it doesn't exist. $ cd infra $ npm install -g npm-check-updates && ncu -u && npm install ``` -------------------------------- ### Installing Dependencies for Backstage Backend (Yarn) Source: https://github.com/pulumi/workshops/blob/main/build-a-self-service-platform-for-oracle-cloud-with-pulumi/00-backstage/backstage/packages/backend/README.md This command installs all necessary project dependencies at the root of the Backstage project. It should be executed once to set up the development environment. ```bash yarn install ``` -------------------------------- ### Initializing Pulumi YAML Project with Force Flag Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command initializes a new Pulumi project using the YAML template, forcing creation even in a non-empty directory. It demonstrates the interactive project setup process, including project and stack naming. ```shell pulumi new yaml --force This command will walk you through creating a new Pulumi project. Enter a value or leave blank to accept the (default), and press . Press ^C at any time to quit. project name (az-getting-started-aks-yaml): project description (A minimal Pulumi YAML program): Created project 'az-getting-started-aks-yaml' Please enter your desired stack name. To create a stack in an organization, use the format / (e.g. `acmecorp/dev`). stack name (dev): Created stack 'getting-started-kubernetes-aks-20240326/dev' Your new project is ready to go! ✨ To perform an initial deployment, run `pulumi up` ``` -------------------------------- ### Initializing a New Pulumi AWS TypeScript Project (Bash) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md Initializes a new Pulumi project using the `aws-typescript` template. This command sets up the basic project structure and installs necessary dependencies for deploying AWS resources with TypeScript. ```bash pulumi new aws-typescript ``` -------------------------------- ### Installing Pulumi Azure Native Provider Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command installs the `azure-native` resource provider plugin for Pulumi, which is necessary to interact with Azure resources using the native Azure API. ```shell pulumi plugin install resource azure-native ``` -------------------------------- ### Dockerfile for AWS Lambda Node.js 18 ARM64 (Dockerfile) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md A multi-stage Dockerfile for building and packaging the Node.js Lambda function. The first stage (`builder`) installs dependencies and builds the application using `esbuild`, while the second stage copies the bundled output to a lean Node.js 18 ARM64 Lambda base image, setting the `index.handler` as the command. ```Dockerfile FROM public.ecr.aws/lambda/nodejs:18-arm64 as builder WORKDIR /usr/app COPY package.json index.ts ./ RUN npm install RUN npm run build FROM public.ecr.aws/lambda/nodejs:18-arm64 WORKDIR ${LAMBDA_TASK_ROOT} COPY --from=builder /usr/app/dist/* ./ CMD ["index.handler"] ``` -------------------------------- ### Deploying Pulumi Stack Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md This Bash command initiates the Pulumi deployment process, creating or updating the cloud resources defined in the Pulumi program. It prompts for confirmation before applying changes. ```Bash pulumi up ``` -------------------------------- ### Deploying Pulumi Stack Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md Executes the `pulumi up` command to preview and deploy the defined infrastructure resources to the target Kubernetes cluster. This command prompts for confirmation before applying changes. ```shell pulumi up ``` -------------------------------- ### Building and Installing Pulumi Provider Plugin - Bash Source: https://github.com/pulumi/workshops/blob/main/packages/go-gcp/lab2/README.md This command builds the Pulumi provider plugin for the current project and installs it into the `$GOPATH/bin` directory. It's a crucial step for verifying the correct setup of build tools and making the provider available for use. ```bash make install_provider ``` -------------------------------- ### Setting Up a New Project Directory in Bash Source: https://github.com/pulumi/workshops/blob/main/github-aws-cicd-getting-started/README.md This command creates a new directory named `live-workshop` and then changes the current working directory into it. This is the initial step to prepare the environment for a new Pulumi project. ```bash mkdir live-workshop && cd live-workshop ``` -------------------------------- ### Building and Installing Pulumi Provider Plugin (Bash) Source: https://github.com/pulumi/workshops/blob/main/packages/go-gcp/lab1/README.md This command builds the Pulumi provider plugin and installs it into the `$GOPATH/bin` directory. It's used to verify the correct setup of build tools and ensure the provider is ready for use. ```bash make install_provider ``` -------------------------------- ### Initializing Pulumi Project with GCP YAML Template Source: https://github.com/pulumi/workshops/blob/main/deploy-cloud-functions-on-gcp-with-pulumi/README.md This command initializes a new Pulumi project using the `gcp-yaml` template. It guides the user through setting the project name, description, stack name, and Google Cloud project ID, saving the configuration for future deployments. ```shell pulumi gcp-yaml --force This command will walk you through creating a new Pulumi project. Enter a value or leave blank to accept the (default), and press . Press ^C at any time to quit. project name (deploy-cloud-functions-on-gcp-with-pulumi): project description (A minimal Google Cloud Pulumi YAML program): Created project 'deploy-cloud-functions-on-gcp-with-pulumi' Please enter your desired stack name. To create a stack in an organization, use the format / (e.g. `acmecorp/dev`). stack name (dev): Created stack 'dev' gcp:project: The Google Cloud project to deploy into: Saved config Your new project is ready to go! ✨ To perform an initial deployment, run `pulumi up` ``` -------------------------------- ### Deploying Pulumi Program with `pulumi up` (Bash) Source: https://github.com/pulumi/workshops/blob/main/github-aws-cicd-getting-started/README.md These commands deploy the Pulumi program to the cloud. The first command performs a preview before deployment, recommended for learners. The second command uses advanced settings to skip the preview and confirm changes automatically, deploying to the `dev` stack non-interactively. ```bash # A preview of the changes will be printed on the screen **recommended for learners** $ pulumi up # Give it a couple of seconds, then # Select 'yes' to confirm the changes # Wait a few more seconds for the changes to occur # Or, using advanced settings to skip the preview $ pulumi up --yes --skip-preview --non-interactive --stack dev # Wait a few seconds ``` -------------------------------- ### Initializing Git Repository and Pushing to GitHub (Bash) Source: https://github.com/pulumi/workshops/blob/main/github-aws-cicd-getting-started/README.md This sequence of commands initializes a local Git repository, configures a `.gitignore` file, performs the initial commit, sets up the `main` branch, adds a remote GitHub repository, and then creates the repository on GitHub while pushing the initial changes. It includes steps for setting owner and repository variables and authenticating with GitHub CLI. ```bash # Ensure you're in the project, `live-workshop`, directory $ cd ../ # if currently in the infra dir. # Update the owner value to your GitHub handle $ owner=desteves $ repo=live-workshop # Initialize the repository locally $ git init # Initialized empty Git repository in ..... # Prepare your first commit $ echo "**node_modules" >> .gitignore $ git add .gitignore $ git commit -m "Initial commit" # Add the main branch $ git branch -M main # Add your remote repo $ git remote add origin "https://github.com/${owner}/${repo}.git" # Verify the values $ git remote -v # origin https://github.com/desteves/live-workshop.git (fetch) # origin https://github.com/desteves/live-workshop.git (push) # Login to GitHub, if necessary $ gh auth login # Create the repo and push the changes $ gh repo create "${repo}" --public --push --source . # $ git push -u origin main ``` -------------------------------- ### Installing Go Dependencies (Bash) Source: https://github.com/pulumi/workshops/blob/main/fundamentals/go/lab-2/README.md This command uses `go get` to download and install the necessary Go modules and dependencies required by the Pulumi program, ensuring all imported packages are available for compilation and execution. ```bash go get ``` -------------------------------- ### Deploying Pulumi Stack (Bash) Source: https://github.com/pulumi/workshops/blob/main/serverless-architecture-on-aws/lab-1/README.md This command initiates the deployment of the Pulumi stack, which provisions the cloud resources defined in the project's code. Users will be prompted to review and confirm the proposed changes before deployment proceeds. ```Bash pulumi up ``` -------------------------------- ### Deploying Pulumi Stack Changes Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command executes the Pulumi deployment, applying the defined infrastructure changes to Azure. It prompts for confirmation and shows the status of resource creation. ```shell pulumi up ``` -------------------------------- ### Building Docker Image for Lambda (Bash) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md Builds a Docker image for the Lambda function, specifying `linux/arm64` as the target platform and tagging the image as `my-lambda:test`. This command compiles the Dockerfile in the current directory to create a deployable container image. ```bash docker build --platform linux/arm64 -t my-lambda:test . ``` -------------------------------- ### Starting Chat Application with Docker Compose Source: https://github.com/pulumi/workshops/blob/main/new-relic-ai-observability/app/web/README.md This command initiates the chat application by orchestrating all services defined in the `docker-compose.yml` file. It is the recommended method for running the application, simplifying the setup and execution of its components. ```bash docker compose up ``` -------------------------------- ### Deploying Kubernetes Application with Pulumi YAML Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This Pulumi YAML configuration defines a complete Kubernetes application stack, including a Kubernetes provider, RabbitMQ deployment, various microservices (order, product, frontend), and their associated services and configurations. It sets up a message queue, backend services, and a public-facing frontend with a LoadBalancer. ```yaml resources: # omitted for brevity myk8sProvider: type: pulumi:providers:kubernetes properties: kubeconfig: fn::fromBase64: ${kubeconfig.kubeconfigs[0].value} enableServerSideApply: true rabbitmqDeployment: type: kubernetes:apps/v1:Deployment options: provider: ${myk8sProvider} properties: metadata: name: rabbitmq spec: replicas: 1 selector: matchLabels: {app: rabbitmq} template: metadata: {labels: {app: rabbitmq}} spec: nodeSelector: {"kubernetes.io/os": linux} volumes: - name: rabbitmq-enabled-plugins configMap: name: rabbitmq-enabled-plugins items: - key: rabbitmq_enabled_plugins path: enabled_plugins containers: - name: rabbitmq image: mcr.microsoft.com/mirror/docker/library/rabbitmq:3.10-management-alpine ports: - name: rabbitmq-amqp containerPort: 5672 - name: rabbitmq-http containerPort: 15672 env: - name: RABBITMQ_DEFAULT_USER value: "username" - name: RABBITMQ_DEFAULT_PASS value: "password" resources: requests: cpu: 10m memory: 128Mi limits: cpu: 250m memory: 256Mi volumeMounts: - name: rabbitmq-enabled-plugins mountPath: /etc/rabbitmq/enabled_plugins subPath: enabled_plugins rabbitmqConfigMap: type: kubernetes:core/v1:ConfigMap options: provider: ${myk8sProvider} properties: metadata: name: rabbitmq-enabled-plugins data: rabbitmq_enabled_plugins: | [rabbitmq_management,rabbitmq_prometheus,rabbitmq_amqp1_0]. rabbitmqService: type: kubernetes:core/v1:Service options: provider: ${myk8sProvider} properties: metadata: name: rabbitmq spec: selector: {app: rabbitmq} type: ClusterIP ports: - name: rabbitmq-amqp port: 5672 targetPort: 5672 - name: rabbitmq-http port: 15672 targetPort: 15672 orderServiceDeployment: type: kubernetes:apps/v1:Deployment options: provider: ${myk8sProvider} properties: metadata: name: order-service spec: replicas: 1 selector: matchLabels: {app: order-service} template: metadata: {labels: {app: order-service}} spec: nodeSelector: {"kubernetes.io/os": linux} initContainers: - name: wait-for-rabbitmq image: busybox command: ['sh', '-c', 'until nc -zv rabbitmq 5672; do echo waiting for rabbitmq; sleep 2; done;'] resources: requests: cpu: 1m memory: 50Mi limits: cpu: 75m memory: 128Mi containers: - name: order-service image: ghcr.io/azure-samples/aks-store-demo/order-service:latest ports: [{containerPort: 3000}] resources: requests: cpu: 1m memory: 50Mi limits: cpu: 75m memory: 128Mi env: - name: ORDER_QUEUE_HOSTNAME value: "rabbitmq" - name: ORDER_QUEUE_PORT value: "5672" - name: ORDER_QUEUE_USERNAME value: "username" - name: ORDER_QUEUE_PASSWORD value: "password" - name: FASTIFY_ADDRESS value: "0.0.0.0" orderServiceService: type: kubernetes:core/v1:Service options: provider: ${myk8sProvider} properties: metadata: name: order-service spec: type: ClusterIP ports: - name: http port: 3000 targetPort: 3000 selector: app: order-service productServiceDeployment: type: kubernetes:apps/v1:Deployment options: provider: ${myk8sProvider} properties: metadata: name: product-service spec: replicas: 1 selector: matchLabels: {app: product-service} template: metadata: {labels: {app: product-service}} spec: nodeSelector: {"kubernetes.io/os": linux} containers: - name: product-service image: ghcr.io/azure-samples/aks-store-demo/product-service:latest ports: [{containerPort: 3002}] resources: requests: cpu: 1m memory: 1Mi limits: cpu: 1m memory: 7Mi productServiceService: type: kubernetes:core/v1:Service options: provider: ${myk8sProvider} properties: metadata: name: product-service spec: type: ClusterIP ports: - name: http port: 3002 targetPort: 3002 selector: app: product-service frontendDeployment: type: kubernetes:apps/v1:Deployment options: provider: ${myk8sProvider} properties: metadata: name: store-front spec: replicas: 1 selector: matchLabels: {app: store-front} template: metadata: {labels: {app: store-front}} spec: nodeSelector: {"kubernetes.io/os": linux} containers: - name: store-front image: ghcr.io/azure-samples/aks-store-demo/store-front:latest ports: [{containerPort: 8080, name: store-front}] resources: requests: cpu: 1m memory: 200Mi limits: cpu: 1000m memory: 512Mi env: - name: VUE_APP_ORDER_SERVICE_URL value: "http://order-service:3000/" - name: VUE_APP_PRODUCT_SERVICE_URL value: "http://product-service:3002/" frontendService: type: kubernetes:core/v1:Service options: provider: ${myk8sProvider} properties: metadata: name: store-front spec: type: LoadBalancer selector: {app: store-front} ports: - port: 80 targetPort: 8080 outputs: serviceIp: ${frontendService.status.loadBalancer.ingress[0].ip} ``` -------------------------------- ### Deploying Pulumi Stack (Bash) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md Executes the `pulumi up` command to deploy the defined infrastructure resources to AWS. This command provisions the ECR repository and pushes the Docker image as specified in the Pulumi program. ```bash pulumi up ``` -------------------------------- ### Pulumi Deployment Output (Shell) Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md Shows the console output after running `pulumi up`, detailing the resources created (Pulumi stack, ECR repository, and Docker image). It includes the `repoDigest` output, confirming the successful deployment and push of the Docker image to ECR. ```shell ➜ pulumi up -y -f Updating (dev) View in Browser (Ctrl+O): https://app.pulumi.com/dirien/aws-getting-started-lambda-ts/dev/updates/12 Type Name Status + pulumi:pulumi:Stack aws-getting-started-lambda-ts-dev created (84s) + ├─ aws:ecr:Repository myrepository created (0.83s) + └─ docker:index:Image my-image created (77s) Outputs: repoDigest: "052848974346.dkr.ecr.eu-central-1.amazonaws.com/my-first-pulumi-lambda@sha256:1751581ac5857418ae69222269957e305e228888726c24d672afd0aef7ea406f" Resources: + 3 created Duration: 1m25s ``` -------------------------------- ### Creating GitHub Actions Workflow Directories and Files (Bash) Source: https://github.com/pulumi/workshops/blob/main/github-aws-cicd-getting-started/README.md These commands navigate to the project root, create the necessary directory structure for GitHub Actions workflows (`.github/workflows`), and then open `branch.yml` and `main.yml` files for editing. These files will contain the CI/CD pipeline definitions for Pulumi deployments. ```bash # Ensure you're in the project, `live-workshop`, directory $ cd ../ # if currently in the infra dir. $ mkdir -p .github/workflows $ cd .github/workflows $ vi branch.yml # paste the contents of branch.yml shown below # save the file. $ vi main.yml ``` -------------------------------- ### Listing Azure Subscriptions Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command lists all Azure subscriptions accessible by the authenticated identity, allowing users to identify the subscription ID for subsequent operations. ```shell az account list ``` -------------------------------- ### Initializing Pulumi Project - Java - Bash Source: https://github.com/pulumi/workshops/blob/main/cloud-engineering-with-azure/java/content/lab-01/README.md This command initializes a new Pulumi project using the Java template. The `-y` flag automatically confirms the creation of a new stack named `dev` and installs required Maven dependencies, automating the project setup process. ```bash pulumi new java -y ``` -------------------------------- ### Authenticating to Azure CLI Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command initiates the Azure CLI login process, opening a web browser for authentication. It's a prerequisite for Pulumi to interact with Azure resources. ```shell az login A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code` ``` -------------------------------- ### Creating Project Directory (Bash) Source: https://github.com/pulumi/workshops/blob/main/serverless-architecture-on-aws/lab-1/README.md This command creates a new directory named 'my-serverless-app' and then changes the current working directory into it. This is a prerequisite step for initializing a new Pulumi project within its own dedicated folder. ```Bash mkdir my-serverless-app && cd my-serverless-app ``` -------------------------------- ### Pulumi Stack Configuration for Azure Region Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This YAML snippet shows the `Pulumi.dev.yaml` file after setting the Azure region. It demonstrates how stack-specific configurations are stored, allowing for environment-specific deployments. ```yaml config: azure-native:location: westeurope ``` -------------------------------- ### Deploying AKS Cluster with Pulumi Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command initiates the Pulumi deployment to create or update the Azure Kubernetes Service (AKS) cluster as defined in the `Pulumi.yaml` file. It requires user confirmation to proceed. ```shell pulumi up ``` -------------------------------- ### Initializing Pulumi Project with AWS Serverless Template (Bash) Source: https://github.com/pulumi/workshops/blob/main/serverless-architecture-on-aws/lab-1/README.md This command initializes a new Pulumi project using the 'serverless-aws-typescript' template. It sets up the necessary project structure, configuration files, and boilerplate code for a serverless application on AWS written in TypeScript. ```Bash pulumi new serverless-aws-typescript ``` -------------------------------- ### API Gateway Response Example Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md This JSON output represents a typical successful response from the deployed API Gateway endpoint, indicating a message returned by the integrated Lambda function. ```JSON { "message": "What animal is always at a game of cricket? A bat." } ``` -------------------------------- ### Initial Pulumi Python Project Structure (Bash) Source: https://github.com/pulumi/workshops/blob/main/embedding-pulumi/1-getting-started/README.md This snippet illustrates the initial directory structure for a Pulumi Python project, showing separate directories for the API and infrastructure components, along with virtual environments and Pulumi configuration files, created using `pulumi new python`. ```bash time-auto-api/ api/ time/ venv/ .gitignore __main__.py Pulumi.yaml requirements.txt infra/ venv/ .gitignore __main__.py Pulumi.yaml requirements.txt ``` -------------------------------- ### Displaying Pulumi Project Directory Structure in Bash Source: https://github.com/pulumi/workshops/blob/main/github-aws-cicd-getting-started/README.md This snippet shows the typical file and directory structure of a new Pulumi TypeScript project. It highlights key configuration files like `Pulumi.yaml` and `Pulumi..yaml`, the main program entry point `index.ts`, and Node.js dependency files. ```bash . ├── Pulumi.dev.yaml ├── Pulumi.yaml ├── index.ts ├── node_modules ├── package-lock.json ├── package.json ├── tsconfig.json └── www 3 directories, 6 files ``` -------------------------------- ### Google Cloud Function for File Upload Event Source: https://github.com/pulumi/workshops/blob/main/deploy-cloud-functions-on-gcp-with-pulumi/README.md This Python function, `fileUpload`, is designed to be triggered by Google Cloud Storage events. It extracts the bucket name, file name, and file size from the event data and prints them to the console, serving as a basic example for processing uploaded files. ```python def fileUpload(event, context): file_data = event # Extract relevant information from the event bucket_name = file_data['bucket'] file_name = file_data['name'] file_size = file_data['size'] # Perform desired operations on the uploaded file # For example, you can process the file, store metadata, or trigger other actions print(f"File uploaded: {file_name} in bucket: {bucket_name}") print(f"File size: {file_size} bytes") # Add your custom logic here # Return a response (optional) return "File processing completed" ``` -------------------------------- ### Installing Maven Dependencies - Bash Source: https://github.com/pulumi/workshops/blob/main/cloud-engineering-with-azure/java/content/lab-01/README.md This command executes `mvn install`, which resolves and installs all declared Maven dependencies, including the Pulumi Azure Native SDK and its corresponding provider plugin. This step is crucial for making the Azure provider available to the Pulumi program. ```bash mvn install ``` -------------------------------- ### Complete Pulumi Go Program for Docker Application Setup Source: https://github.com/pulumi/workshops/blob/main/fundamentals/go/lab-3/README.md This comprehensive Pulumi program in Go defines the infrastructure for a multi-container Docker application. It includes configuration variable setup, pulling remote Docker images for backend, frontend, and MongoDB, and sets the stage for network and container definitions, demonstrating the initial structure of a Pulumi Go project. ```Go package main import ( "fmt" "github.com/pulumi/pulumi-docker/sdk/v3/go/docker" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" ) func main() { pulumi.Run(func(ctx *pulumi.Context) error { cfg := config.New(ctx, "") _ := cfg.RequireFloat64("frontendPort") _ := cfg.RequireFloat64("backendPort") _ := cfg.RequireFloat64("mongoPort") backendImageName := "backend" frontendImageName := "frontend" _, err := docker.NewRemoteImage(ctx, fmt.Sprintf("%v-image", ctx.backendImageName), &docker.RemoteImageArgs{ Name: pulumi.String("pulumi/tutorial-pulumi-fundamentals-backend:latest"), }) if err != nil { return err } _, err := docker.NewRemoteImage(ctx, fmt.Sprintf("%v-image", ctx.frontendImageName), &docker.RemoteImageArgs{ Name: pulumi.String("pulumi/tutorial-pulumi-fundamentals-frontend:latest"), }) if err != nil { return err } _, err := docker.NewRemoteImage(ctx, "mongo-image", &docker.RemoteImageArgs{ Name: pulumi.String("pulumi/tutorial-pulumi-fundamentals-database-local:latest"), }) if err != nil { return err } return nil }) } ``` -------------------------------- ### Example Pulumi Deployment Output (Shell) Source: https://github.com/pulumi/workshops/blob/main/deploy-cloud-functions-on-gcp-with-pulumi/README.md This shell output displays a typical result after running `pulumi up -y -f`, showing the status of created GCP resources, including storage buckets, service accounts, IAM members, and the Cloud Function. It also highlights the `function_url` output, providing the accessible URL for the deployed Cloud Function. ```shell pulumi up -y -f Updating (dev) View in Browser (Ctrl+O): https://app.pulumi.com/dirien/deploy-cloud-functions-on-gcp-with-pulumi/dev/updates/37 Type Name Status + pulumi:pulumi:Stack deploy-cloud-functions-on-gcp-with-pulumi-dev created (92s) + ├─ gcp:storage:Bucket cloudFunctionBucket created (2s) + ├─ gcp:storage:Bucket inputBucket created (1s) + ├─ gcp:serviceaccount:Account account created (3s) + ├─ gcp:storage:BucketObject functionSourceZip created (0.83s) + ├─ gcp:projects:IAMMember invoking created (9s) + ├─ gcp:projects:IAMMember eventReceiving created (9s) + └─ gcp:cloudfunctionsv2:Function cloudFunction created (72s) Outputs: function_url: "https://europe-west2-minectl-fn.cloudfunctions.net/cloud-function-trigger-using-pulumi-gen2" Resources: + 8 created Duration: 1m33s ``` -------------------------------- ### Example Output of `pulumi up` Preview Source: https://github.com/pulumi/workshops/blob/main/cloud-engineering-with-gcp/python/content/lab-02/README.md Displays a typical output from the `pulumi up` command's preview phase. It shows the resources Pulumi plans to create, including the stack, storage bucket, ACL, and individual bucket objects, allowing users to verify the planned changes. ```text Previewing update (dev) View Live: https://app.pulumi.com/jkodroff/my-first-gcp-app/dev/previews/8e2d59f2-bf22-4491-ac44-208bcc485ebc Type Name Plan + pulumi:pulumi:Stack my-first-gcp-app-dev create + ├─ gcp:storage:Bucket website create + ├─ gcp:storage:DefaultObjectAccessControl website create + ├─ gcp:storage:BucketObject index.html create + └─ gcp:storage:BucketObject python.png create ``` -------------------------------- ### Verifying Pulumi Provider Installation Output (Bash) Source: https://github.com/pulumi/workshops/blob/main/packages/go-gcp/lab1/README.md This output shows the successful build and installation process of the Pulumi provider plugin. It details the steps of cleaning previous builds, generating Go code, building the executable, and copying it to the Go binary path, confirming the plugin is ready. ```bash rm -rf /Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/bin/pulumi-resource-ced cd provider/cmd/pulumi-resource-ced && VERSION=0.0.1 SCHEMA=/Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/schema.yaml go generate main.go cd provider/cmd/pulumi-resource-ced && go build -o /Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/bin/pulumi-resource-ced -ldflags "-X github.com/pulumi/pulumi-ced/provider/pkg/version.Version=0.0.1" . cp /Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/bin/pulumi-resource-ced /Users/ringods/Projects/golang/bin Time: 0h:00m:06s ``` -------------------------------- ### Defining AWS Lambda and API Gateway with Pulumi TypeScript Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md This TypeScript code defines an AWS Lambda function, an IAM role for the Lambda, and a complete API Gateway setup including a REST API, resource, method, integration, and deployment. It configures the API Gateway to proxy requests to the Lambda function, making it accessible via a public URL. ```TypeScript const lambda = new aws.lambda.Function("mylambda", { name: "my-first-pulumi-lambda", imageUri: image.repoDigest, packageType: "Image", role: new aws.iam.Role("mylambda-role", { assumeRolePolicy: JSON.stringify({ Version: "2012-10-17", Statement: [{ Action: "sts:AssumeRole", Effect: "Allow", Principal: { Service: "lambda.amazonaws.com", }, }], }), }).arn, timeout: 300, memorySize: 128, architectures: ["arm64"], }); const lambdaPermission = new aws.lambda.Permission("mylambda-permission", { action: "lambda:InvokeFunction", statementId: "AllowAPIGatewayInvoke", function: lambda, principal: "apigateway.amazonaws.com", }); const apiGatewayRestApi = new aws.apigateway.RestApi("myapi", { name: "my-first-pulumi-api", }) const apiGatewayResource = new aws.apigateway.Resource("myapiresource", { parentId: apiGatewayRestApi.rootResourceId, pathPart: "dad-joke", restApi: apiGatewayRestApi.id, }); const apiGatewayMethod = new aws.apigateway.Method("myapimethod", { restApi: apiGatewayRestApi.id, resourceId: apiGatewayResource.id, httpMethod: "GET", authorization: "NONE", }); const apiGatewayIntegration = new aws.apigateway.Integration("myapiintegration", { restApi: apiGatewayRestApi.id, resourceId: apiGatewayResource.id, httpMethod: apiGatewayMethod.httpMethod, integrationHttpMethod: "POST", type: "AWS_PROXY", uri: lambda.invokeArn, }); const apiGatewayDeployment = new aws.apigateway.Deployment("myapideployment", { restApi: apiGatewayRestApi.id, stageName: "v1", triggers: { "repoDigest": image.repoDigest, } }, { dependsOn: [ apiGatewayIntegration ] }); export const url = pulumi.interpolate`${apiGatewayDeployment.invokeUrl}/${apiGatewayResource.pathPart}`; ``` -------------------------------- ### GitHub Actions Job for Pulumi Stack Destruction Source: https://github.com/pulumi/workshops/blob/main/github-aws-cicd-getting-started/README.md This YAML snippet outlines a GitHub Actions job designed to destroy a Pulumi stack. It sets up Node.js, installs project dependencies, and then uses the `pulumi/actions` GitHub Action. The `command` and `stack-name` parameters are left as placeholders, indicating where the specific Pulumi destroy command and target stack name would be configured. ```YAML jobs: pulumi-destroy: name: pulumi-destroy runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Set up Node.js 18 uses: actions/setup-node@v4 with: node-version: 18 - name: Install Dependencies working-directory: ./infra run: npm install - uses: pulumi/actions@v5 with: command: ????????? stack-name: ?????????? work-dir: ./infra env: PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} ``` -------------------------------- ### Initial Pulumi Application Setup with Docker Images (Java) Source: https://github.com/pulumi/workshops/blob/main/fundamentals/java/lab-3/README.md This comprehensive Java code block outlines the foundational structure of a Pulumi application. It includes the main entry point, the stack definition, retrieval of required port configurations, and the creation of `RemoteImage` resources for backend, frontend, and MongoDB Docker images. ```java package my_first_app; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.docker.RemoteImage; import com.pulumi.docker.RemoteImageArgs; import java.util.List; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } private static void stack(Context ctx) { var config = ctx.config(); var frontendPort = config.requireInteger("frontendPort"); var backendPort = config.requireInteger("backendPort"); var mongoPort = config.requireInteger("mongoPort"); final var stackName = ctx.stackName(); // Create our images final String backendImageName = "backend"; var backendImage = new RemoteImage( backendImageName, RemoteImageArgs.builder() .name(String.format("pulumi/tutorial-pulumi-fundamentals-%s:latest",backendImageName)) .build() ); final String frontendImageName = "frontend"; var frontendImage = new RemoteImage( frontendImageName, RemoteImageArgs.builder() .name(String.format("pulumi/tutorial-pulumi-fundamentals-%s:latest",frontendImageName)) .build() ); var mongoImage = new RemoteImage( "mongoImage", RemoteImageArgs.builder() .name("pulumi/tutorial-pulumi-fundamentals-database-local:latest") .build() ); ``` -------------------------------- ### Installing Python Dependencies for Pulumi Workshop (Shell) Source: https://github.com/pulumi/workshops/blob/main/building-reusable-abstractions/2-component-resources/python/README.md This shell script activates a Python virtual environment and installs required dependencies from `requirements.txt` using `pip`. This is a common setup step for Python-based Pulumi projects. ```shell source ./venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Verifying Pulumi Provider Installation Output - Bash Source: https://github.com/pulumi/workshops/blob/main/packages/go-gcp/lab2/README.md This output confirms the successful build and installation of the Pulumi provider plugin. It shows the removal of previous builds, Go generation, Go build command with version flags, and the final copying of the executable to the Go binary path, along with the total time taken. ```bash rm -rf /Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/bin/pulumi-resource-ced cd provider/cmd/pulumi-resource-ced && VERSION=0.0.1 SCHEMA=/Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/schema.yaml go generate main.go cd provider/cmd/pulumi-resource-ced && go build -o /Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/bin/pulumi-resource-ced -ldflags "-X github.com/pulumi/pulumi-ced/provider/pkg/version.Version=0.0.1" . cp /Users/ringods/Projects/pulumi/workshops/packages/go-gcp/lab1/bin/pulumi-resource-ced /Users/ringods/Projects/golang/bin Time: 0h:00m:06s ``` -------------------------------- ### Setting Up Node.js Application Directory (Bash) Source: https://github.com/pulumi/workshops/blob/main/serverless-architecture-on-aws/lab-2/README.md This command sequence sets up a new Node.js application directory for the Lambda function code. It creates an `app` directory, changes into it, initializes a new npm project, and installs any necessary dependencies. This prepares the environment for writing the Lambda function. ```bash mkdir app && cd app && npm init && npm i ``` -------------------------------- ### Testing API Gateway Endpoint with cURL Source: https://github.com/pulumi/workshops/blob/main/aws-getting-started-lambda-ts/README.md This Bash command uses `curl` to send a GET request to the deployed API Gateway endpoint, retrieving the URL dynamically from Pulumi stack outputs. The `jq` command is used to pretty-print the JSON response. ```Bash curl -s $(pulumi stack output url) | jq . ``` -------------------------------- ### Building and Installing Pulumi Provider Plugin (Bash) Source: https://github.com/pulumi/workshops/blob/main/packages/go-gcp/lab2/README.md This Bash command builds and installs the Pulumi provider plugin binary. The `make install_provider` target compiles the Go code and copies the resulting binary to `$GOPATH/bin`, making it available for consumption by Pulumi programs. It's crucial for the plugin to be in the system's `PATH`. ```Bash # Build and install the provider (plugin copied to $GOPATH/bin) make install_provider ``` -------------------------------- ### HTML for Serverless Example Index Page (HTML) Source: https://github.com/pulumi/workshops/blob/main/serverless-templates-gcp-application-python/lab-2/README.md This HTML code defines the main `index.html` page for the serverless example. It includes JavaScript to fetch configuration from `config.json` and make an asynchronous call to a serverless API endpoint to display the current time. ```html Serverless Example

⌚ What time is it?

Deployed with 💜 by Pulumi.

``` -------------------------------- ### API Server Startup Output - Bash Source: https://github.com/pulumi/workshops/blob/main/embedding-pulumi/5-putting-it-together/README.md This snippet displays the console output when the Python-based API server is successfully initiated. It confirms that the server is running and listening for requests on port 8000, indicating readiness for interaction. ```bash Serving on port 8000... ``` -------------------------------- ### Testing Serverless Endpoint with cURL (Bash) Source: https://github.com/pulumi/workshops/blob/main/serverless-architecture-on-aws/lab-1/README.md This command uses 'curl' to make an HTTP GET request to the '/date' endpoint of the deployed serverless application. It dynamically constructs the URL by embedding the output from 'pulumi stack output url', allowing for direct testing of the application's functionality. ```Bash curl $(pulumi stack output url)/date ``` -------------------------------- ### Deploying Pulumi Infrastructure (Shell) Source: https://github.com/pulumi/workshops/blob/main/deploy-cloud-functions-on-gcp-with-pulumi/README.md This shell command initiates the deployment of the defined Pulumi infrastructure. It prompts the user for confirmation before provisioning or updating resources in the target cloud environment. ```shell pulumi up ``` -------------------------------- ### Initializing Pulumi Project with Docker Build Cloud Template (Bash) Source: https://github.com/pulumi/workshops/blob/main/docker-pulumi/solutions/hello-dbc-done/README.md This snippet initializes a new Pulumi project using a predefined template for Docker Build Cloud (DBC) and then installs its dependencies. It sets up the project structure and prepares it for deployment. ```bash pulumi new https://github.com/pulumi/examples/tree/master/dockerbuild-ts-dbc npm install ``` -------------------------------- ### Removing Pulumi Stack Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md Deletes the specified Pulumi stack, including its history and configuration, after all associated resources have been destroyed. This command is typically used for complete cleanup. ```shell pulumi stack rm dev ``` -------------------------------- ### Setting Default Azure Subscription Source: https://github.com/pulumi/workshops/blob/main/az-getting-started-aks-yaml/README.md This command sets the default Azure subscription for subsequent Azure CLI and Pulumi operations, ensuring resources are deployed to the desired subscription. ```shell az account set --subscription= ``` -------------------------------- ### Destroying Pulumi Resources (Bash) Source: https://github.com/pulumi/workshops/blob/main/serverless-architecture-on-aws/lab-1/README.md This command de-provisions and removes all cloud resources managed by the current Pulumi stack. It is used for cleaning up deployed infrastructure and will prompt for confirmation before proceeding with the destruction. ```Bash pulumi destroy ``` -------------------------------- ### Pre-installing Pulumi Resource Plugins in Bash Source: https://github.com/pulumi/workshops/blob/main/in-person/2024-07-08-aws-pinecone-scaling-ai-apps.md These commands pre-install essential Pulumi resource providers (AWS, AWSX, Pinecone) to reduce download times during the workshop. Installing them beforehand ensures a smoother experience by having the necessary plugins readily available when provisioning infrastructure. ```bash pulumi plugin install resource aws pulumi plugin install resource awsx pulumi plugin install resource pinecone ```