Unleash Infrastructure Lifecycle Management with Python and Upbound

April 1, 2025

Read time: 6 mins

Markus Schweig

Share:

Managing the infrastructure lifecycle for modern applications, whether for Artificial Intelligence and Machine Learning (AI/ML) or any other demanding workload, is complex and time-consuming. Imagine juggling Kubernetes clusters, virtual machines, databases, networks, security groups, and more, all while trying to focus on building innovative solutions. What if you could streamline this entire process by leveraging the power and flexibility of code?


Enter Upbound's Python DevEx for AI Lab. This hands-on guide demonstrates how to build a self-service infrastructure platform on AWS powered by infrastructure-as-code principles and embedded functions. While this specific lab showcases an AI playground use case, the underlying principles and Upbound tooling apply to managing any infrastructure's lifecycle. This isn't just about deploying resources; it's about orchestrating the entire lifecycle of your infrastructure with code you understand and control.


The upbound/labs GitHub repository is a fantastic resource for anyone looking to:

  • Automate infrastructure deployment: Say goodbye to manual configuration and hello to repeatable, code-driven infrastructure for any application.
  • Embrace Infrastructure as Code (IaC): Define and manage your cloud resources or any resource with a Crossplane provider using familiar programming paradigms within the Upbound platform.
  • Build a self-service platform: Empower your teams with on-demand access to pre-configured environments tailored to their specific needs e.g. AI, web applications, databases, and more.
  • Master Upbound DevEx: Dive into Upbound's powerful tooling and discover how embedded functions in languages like Python, Go, and KCL can supercharge your infrastructure compositions. This lab uses Python as a demonstration, but the concepts apply equally to Go and KCL. It uses an AWS target account for resource creation, but Upbound also supports Google Cloud Platform (GCP), Microsoft Azure, and any service with a Crossplane provider – many of which are available in the Upbound Marketplace.


What Will You Learn in the Lab?

The Python DevEx for AI lab is structured as a comprehensive curriculum and guides you through the essential steps to build your infrastructure platform. Here’s a glimpse into the key learnings broadly applicable beyond just AI.

  • Crafting a Crossplane Configuration Package: You'll start by building the foundation – a reusable configuration package that encapsulates your platform definition for any type of infrastructure.
  • Defining Platform APIs with Composite Resource Definitions (XRDs): Learn how to create clear and user-friendly APIs for your resources, making them easily consumable by your teams.
  • Composing Infrastructure with Function Pipelines: Discover the magic of Crossplane compositions and function pipelines. You'll use embedded Python functions (alternatively Go or KCL) to orchestrate the creation of various cloud resources in a modular and manageable way.
  • Leveraging Crossplane Providers: The lab demonstrates how to integrate with Crossplane providers (specifically, the AWS provider) to manage real-world cloud resources. 
  • Provider Authentication with OIDC and Static Credentials: Learn secure and practical methods for your Upbound control plane to authenticate with your cloud provider account to enable resource management,
  • Developing Embedded Crossplane Python Functions: This is where the DevEx magic happens! You'll write Python code directly within your Upbound configuration package project to define the logic for resource composition and lifecycle management. 
  • Importing and Using Provider Models: Seamlessly interact with AWS resources by importing and utilizing provider models within your chosen language functions that also help editors with Language Server Protocol (LSP) support to provide real-time syntax and auto-completion.
  • Dynamic Resource Management and Patching: Explore advanced techniques to dynamically update external resources and provide insightful status updates back to your users through composite resources.
  • Referencing Managed and External Resources: Learn how to connect different parts of your infrastructure by referencing and utilizing managed resources through selectors.
  • Exploring a HuggingFace AI Playground (as an example): The lab culminates in deploying an AI Upbox pre-configured with Hugging Face Neuron Deep Learning examples, showcasing a tangible application of the infrastructure you've built. This AI playground serves as a compelling example of a self-service platform, and the same principles can be applied to build platforms for various other use cases.


Building Blocks of the Infrastructure Platform

The lab focuses on creating two core composite resource types in AWS, e.g., Networks and AI Upboxes (Virtual Machines). These are used to demonstrate the principles and can be generalized to represent any infrastructure components:

  • Networks (AWS Example): The lab guides you in creating network infrastructure on AWS, including:
    • VPCs (Virtual Private Clouds): Isolated network environments
    • Subnets: Dividing your VPC into manageable network segments
    • Internet Gateway: Enabling internet connectivity
    • Route Tables and Security Groups: Controlling network traffic and security policies
  • Compute (AI Upboxes - AWS EC2 Example): The lab focuses on deploying virtual machines on AWS EC2 as an example of compute resources:
    • Instances (EC2): AWS virtual machines pre-configured for Hugging Face Neuron Deep Learning (in this AI example)
    • Key Pairs: Managing SSH access


The design emphasizes flexibility, allowing you to create multiple isolated environments and deploy numerous resources within each, catering to different teams or projects. This "Upbox" pattern, as highlighted in the lab, is ideal for creating turn-key, secure, and isolated environments for various purposes, not just AI training and experimentation.


Programming Language-Powered Development Workflow

The lab champions a modern development workflow, leveraging the up CLI in conjunction with an Upbound account. This combination unlocks a high-velocity development experience for embedded function programming, whether you choose Python, Go, or KCL. The lab walks you through the essential steps, which are consistent regardless of the chosen language.

  1. Project Initialization: Use up project init to bootstrap your configuration project.
  2. Resource Claim Examples: Generate example resource claims using up example generate to define the desired state of your infrastructure components.
  3. Composite Resource Definitions (XRDs): Create XRDs from your examples using up xrd generate to define the API for your platform.
  4. Compositions and Function Generation: Utilize up composition generate and up function generate to create compositions and scaffold functions (in Python, Go, or KCL) for resource orchestration.
  5. Dependency Management: Easily add provider dependencies for the AWS EC2 provider (or GCP and Azure providers) using up dep add.
  6. Building and Running the Configuration: Deploy your configuration to your Upbound control plane with up project run.
  7. Claim and Validate: Apply your resource claims using kubectl apply and verify successful deployment using crossplane beta trace.


Dive Into the Infrastructure Platform (Using the AI Playground Example)

Once your infrastructure is deployed, the lab shows you how to connect to your AI Upbox via SSH and you can start exploring pre-loaded Hugging Face examples. You can run language translators, sentence completion predictions, and delve into the rich ecosystem of Hugging Face models and notebooks. This is just one demonstration of what you can build. The same principles apply to deploying web applications, databases, and any other infrastructure.


Ready To Get Started?

The Upbound Python DevEx for AI Lab is your gateway to unlocking powerful infrastructure lifecycle management. It's a practical, step-by-step guide that empowers you to build self-service platforms and streamline your workflows for any type of application. While this lab uses Python and AWS as examples, remember that Upbound's tooling and approach are versatile and support multiple languages (Python, Go, KCL) and cloud providers (AWS, GCP, Azure, and more via Crossplane providers).


Head over to the upbound/labs GitHub repository today and start building your code-driven infrastructure platform using Python, Go, or KCL and targeting AWS, GCP, Azure, or any other supported provider!


This lab is a testament to the power of Upbound's DevEx approach, combining the declarative nature of infrastructure-as-code with the expressive capabilities of languages like Python, Go, and KCL. It's time to move beyond manual infrastructure management and embrace the future of infrastructure automation with Upbound for AI and beyond.
 

Subscribe to the Upbound Newsletter