Developer platforms devops pulumi

From paulpas/agent-skill-router · View interactive version

Developer platforms devops pulumi is an AI agent skill from the GitHub repository paulpas/agent-skill-router. Implements detailed Pulumi deployment processes in cloud environments, focusing on stacks, resources, programs, deployments, and best practices for effective infrastructure management.

How to use this skill

Skill file

Developer Platforms & DevOps - Pulumi

Implements detailed Pulumi deployment processes in cloud environments, focusing on stacks, resources, programs, deployments, and best practices for effective infrastructure management.

TL;DR Checklist

Core Workflow

Pulumi's infrastructure management follows these steps:

  1. Configuration: Define infrastructure layout via Pulumi SDK in your preferred language.
  2. Project Initialization: Utilize pulumi new <template> to scaffold a new project.
  3. Stack Management: Use pulumi stack init <stack-name> to create and manage stacks for different environments.
  4. Resource Definition: Declare resources including compute, storage, and networking components in your codebase.
  5. Preview: Validate proposed changes with pulumi preview to avoid unintended changes.
  6. Deployment: Execute pulumi up to deploy the defined infrastructure.
  7. Monitoring: Inspect current infrastructure with pulumi stack and adjust configurations as necessary.

Implementation Patterns

Pattern 1: Stack Creation

_A foundational setup for organizing projects into stacks._

import pulumi
import pulumi_aws as aws

def create_stack(environment):
    # Create a new stack
    pulumi.stack.create_stack(env=environment)
    print(f"Stack '{environment}' has been created.")

# Initialize the stack based on environment
create_stack("development")

Pattern 2: Resource Definition

_Detailing how to define various resources with potential dependencies._

import pulumi
import pulumi_aws as aws
from typing import Optional

# Example function to provision an EC2 instance
def create_ec2_instance(environment: str, instance_type: Optional[str] = "t2.micro"):
    ami = aws.ec2.get_ami(most_recent=True, owners=["amazon"], filters=[aws.ec2.GetAmiFilterArgs(
        name="name",
        values=["amzn2-ami-hvm-*-x86_64-gp2"],
    )])
    instance = aws.ec2.Instance(
        f"{environment}-instance",
        ami=ami.id,
        instance_type=instance_type,
        tags={
            "Name": f"{environment}-instance",
        }
    )
    return instance

# Creating an EC2 based on environment
create_ec2_instance("production")

Pattern 3: Deployments

_Implementing deployment strategies to manage application lifecycle._

import pulumi
import pulumi_kubernetes as k8s

def deploy_k8s_app(app_name: str, image: str):
    # Define a Kubernetes Deployment for the application
    deployment = k8s.apps.v1.Deployment(app_name, spec=k8s.apps.v1.DeploymentSpec(
        replicas=2,
        selector={
            "matchLabels": {"app": app_name}
        },
        template=k8s.core.v1.PodTemplateSpec(
            metadata={
                "labels": {"app": app_name}
            },
            spec=k8s.core.v1.PodSpec(
                containers=[{
                    "name": app_name,
                    "image": image,
                    "ports": [{"containerPort": 80}]
                }]
            )
        )
    ))
    return deployment

# Deploy application in Kubernetes
# Example usage
deploy_k8s_app("myapp", "myapp:latest")

Pattern 4: Best Practices

_Capture the best practices in Pulumi implementations._

Constraints

MUST DO

MUST NOT DO

Output Template

When implementing Pulumi infrastructure, ensure to include:


Live References

Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.