Spacelift
PrivacyT&Cs
  • 👋Hello, Spacelift!
  • 🚀Getting Started
  • 🌠Main concepts
    • Stack
      • Creating a stack
      • Stack settings
      • Organizing stacks
      • Stack locking
      • Drift detection
    • Configuration
      • Environment
      • Context
      • Runtime configuration
        • YAML reference
    • Run
      • Task
      • Proposed run (preview)
      • Tracked run (deployment)
      • Module test case
      • User-Provided Metadata
      • Run Promotion
      • Pull Request Comments
    • Policy
      • Login policy
      • Access policy
      • Approval policy
      • Initialization policy
      • Plan policy
      • Push policy
      • Task policy
      • Trigger policy
    • Resources
    • Worker pools
    • VCS Agent Pools
  • 🛰️Platforms
    • Terraform
      • Module registry
      • External modules
      • Provider
      • State management
      • Terragrunt
      • Version management
      • Handling .tfvars
      • CLI Configuration
      • Cost Estimation
      • Resource Sanitization
      • Storing Complex Variables
      • Debugging Guide
    • Pulumi
      • Getting started
        • C#
        • Go
        • JavaScript
        • Python
      • State management
      • Version management
    • CloudFormation
      • Getting Started
      • Reference
      • Integrating with SAM
      • Integrating with the serverless framework
    • Kubernetes
      • Getting Started
      • Authenticating
      • Custom Resources
      • Helm
      • Kustomize
  • ⚙️Integrations
    • Audit trail
    • Cloud Integrations
      • Amazon Web Services (AWS)
      • Microsoft Azure
      • Google Cloud Platform (GCP)
    • Source Control
      • GitHub
      • GitLab
      • Azure DevOps
      • Bitbucket Cloud
      • Bitbucket Datacenter/Server
    • Docker
    • GraphQL API
    • Single sign-on
      • GitLab OIDC Setup Guide
      • Okta OIDC Setup Guide
      • OneLogin OIDC Setup Guide
      • Azure AD OIDC Setup Guide
      • AWS IAM Identity SAML 2.0 Setup Guide
    • Slack
    • Webhooks
  • 📖Product
    • Privacy
    • Security
    • Support
      • Statement of Support
    • Disaster Continuity
    • Billing
      • Stripe
      • AWS Marketplace
    • Terms and conditions
    • Refund Policy
  • Cookie Policy
Powered by GitBook
On this page

Was this helpful?

  1. Platforms
  2. Pulumi
  3. Getting started

Python

From this article you can learn how to setup a Pulumi JavaScript Stack in Spacelift

PreviousJavaScriptNextState management

Last updated 2 years ago

Was this helpful?

In order to follow along with this article, you'll need an AWS account.

Start with forking the , we'll be setting up an example directory from there, namely .

In the root of the repository (not the aws-py-webserver directory), add a new file:

.spacelift/config.yml
version: "1"

stack_defaults:
  before_apply:
    - pip install -r requirements.txt

before_apply is not yet exposed through the interface like before_init, so you have to set it through the config file.

Now let's open Spacelift and create a new Stack, choose the examples repo you just forked. In the second step you'll have to change multiple default values:

  • Set the project root to aws-py-webserver, as we want to run Pulumi in this subdirectory only.

  • Add one before init script: pip install -r requirements.txt, which will install all necessary dependencies, before initializing Pulumi itself. This will need to run both when and before .

  • Set the runner image to public.ecr.aws/spacelift/runner-pulumi-python:latest

    • Pinning to a specific Pulumi version is possible too, using a tag like v2.15.4 - you can see the available versions .

In the third step, choose Pulumi as your Infrastructure as Code vendor. You'll have to choose:

  • A state backend, aka login URL. This can be a cloud storage bucket, like s3://pulumi-state-bucket, but it can also be a Pulumi Service endpoint.

  • A stack name, which is how the state for this stack will be namespaced in the state backend. Best to write something close to your stack name, like my-python-pulumi-spacelift-stack.

You can use https://api.pulumi.com as the Login URL to use the official Pulumi state backend. You'll also need to provide your Pulumi access token through the PULUMI_ACCESS_TOKEN environment variable.

You can now trigger the Run manually in the Stack view, after the planning phase is over, you can check the log to see the planned changes.

Confirm the run to let it apply the changes, after applying it should look like this:

We can see the public_dns stack output. If we try to curl it, lo and behold:

~> curl ec2-3-125-48-55.eu-central-1.compute.amazonaws.com
Hello, World!

Which will destroy all created resources.

You'll now have to set up the AWS integration for the Stack, as is described in .

Go into the tab in your screen, add an AWS_REGION environment variable and set it to your region of choice, i.e. eu-central-1.

In order to clean up, open the tab, and perform pulumi destroy --non-interactive --yes there.

🛰️
AWS
Environment
Tasks
Pulumi examples repo
aws-py-webserver
initializing
applying
here
Define behavior.
Configure backend.
Configure enviornment.
Pending confirmation.
Applied
Performing cleanup task.
Destruction complete.