alpine
+
mocha
+
+
+
โŠ‚
+
android
+
android
+
deno
cobol
dns
mysql
junit
+
+
+
+
vite
+
+
+
+
ts
adonis
+
+
+
ractive
pandas
+
gentoo
dns
redhat
elm
dask
+
rails
+
zig
php
qdrant
s3
gatsby
+
+
+
+
โˆž
+
html
go
+
+
+
solid
jwt
+
ansible
d
+
+
emacs
clion
swift
+
+
torch
aws
grpc
+
phoenix
==
+
echo
+=
+
bun
===
rails
spring
+
wsl
s3
+
+
Back to Blog
๐Ÿ—๏ธ Pulumi Infrastructure as Code Setup on AlmaLinux 9: Complete Modern Infrastructure Automation Guide
AlmaLinux Pulumi Infrastructure as Code

๐Ÿ—๏ธ Pulumi Infrastructure as Code Setup on AlmaLinux 9: Complete Modern Infrastructure Automation Guide

Published Sep 6, 2025

Learn how to install and use Pulumi for Infrastructure as Code on AlmaLinux 9. Step-by-step guide with Python, TypeScript examples, multi-cloud deployments, and CI/CD integration.

5 min read
0 views
Table of Contents

๐Ÿ—๏ธ Pulumi Infrastructure as Code Setup on AlmaLinux 9: Complete Modern Infrastructure Automation Guide

Welcome to the exciting world of modern Infrastructure as Code! ๐ŸŽ‰ Today weโ€™re going to learn how to set up Pulumi on AlmaLinux 9, the revolutionary platform that lets you write infrastructure code using real programming languages like Python, TypeScript, and Go. Think of Pulumi as your infrastructure superpower that brings software engineering practices to cloud resources! ๐Ÿ’ชโœจ

๐Ÿค” Why is Pulumi Important?

Traditional Infrastructure as Code tools use domain-specific languages that can be limiting. Hereโ€™s why Pulumi is a game-changer for modern infrastructure:

  • ๐Ÿš€ Real Programming Languages - Use Python, TypeScript, Go, C#, or Java instead of YAML or HCL
  • ๐Ÿ”„ Software Engineering Practices - Loops, functions, classes, testing, and IDE support
  • โ˜๏ธ Multi-Cloud Native - Deploy to AWS, Azure, GCP, Kubernetes from the same codebase
  • ๐Ÿงช Built-in Testing - Unit tests, integration tests, and policy-as-code validation
  • ๐Ÿ“ฆ Package Management - Reusable components with npm, pip, or other package managers
  • ๐Ÿ”— CI/CD Integration - Seamless automation with existing DevOps pipelines

๐ŸŽฏ What You Need

Before we start our Pulumi adventure, letโ€™s make sure you have everything ready:

โœ… AlmaLinux 9 system (fresh installation recommended)
โœ… Root or sudo access for installing packages
โœ… At least 4GB RAM (8GB recommended for large deployments)
โœ… 10GB free disk space for tools and project files
โœ… Internet connection for downloading packages and cloud APIs
โœ… Cloud account (AWS, Azure, or GCP - weโ€™ll use AWS for examples)
โœ… Basic programming knowledge (Python or JavaScript helpful)
โœ… Text editor or IDE (VS Code recommended)

๐Ÿ“ Step 1: Update Your AlmaLinux System

Letโ€™s start by making sure your system is up to date! ๐Ÿš€

# Update all packages to latest versions
sudo dnf update -y

# Install essential development tools and dependencies
sudo dnf groupinstall "Development Tools" -y

# Install helpful utilities we'll need
sudo dnf install -y curl wget git vim nodejs npm python3 python3-pip

Perfect! Your system is now ready for Pulumi installation! โœจ

๐Ÿ”ง Step 2: Install Pulumi CLI

Letโ€™s install the Pulumi command-line interface:

# Download and install Pulumi using the official installer
curl -fsSL https://get.pulumi.com | sh

# Add Pulumi to your PATH (add this to ~/.bashrc for permanent use)
export PATH=$PATH:$HOME/.pulumi/bin

# Reload your shell configuration
source ~/.bashrc

# Verify Pulumi installation
pulumi version

# You should see output like: v3.88.1

Awesome! Pulumi CLI is now installed and ready! ๐ŸŽฏ

๐ŸŒŸ Step 3: Set Up Your First Pulumi Project

Letโ€™s create your first infrastructure project using Python:

# Create a directory for your Pulumi projects
mkdir -p ~/pulumi-projects
cd ~/pulumi-projects

# Initialize a new Pulumi project with Python
pulumi new aws-python --name my-first-infrastructure --description "My first Pulumi project"

# This will prompt you for:
# - Pulumi access token (sign up at pulumi.com for free)
# - AWS region (choose us-east-1 or your preferred region)
# - Project name and description

# Navigate into your new project
cd my-first-infrastructure

# Install Python dependencies
pip3 install -r requirements.txt

Great! Youโ€™ve created your first Pulumi project! ๐Ÿ“

โœ… Step 4: Configure Cloud Credentials

Letโ€™s set up AWS credentials for your infrastructure deployments:

# Install AWS CLI if not already installed
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

# Configure AWS credentials (you'll need AWS Access Key ID and Secret)
aws configure

# Enter your AWS credentials when prompted:
# AWS Access Key ID: YOUR_ACCESS_KEY
# AWS Secret Access Key: YOUR_SECRET_KEY
# Default region name: us-east-1
# Default output format: json

# Verify AWS configuration
aws sts get-caller-identity

# Should show your AWS account information

Your cloud credentials are now configured! โ˜๏ธ

๐Ÿ”ง Step 5: Create Your First Infrastructure

Letโ€™s modify the default project to create some real infrastructure:

# Edit the main Python file
cat > __main__.py << 'EOF'
import pulumi
import pulumi_aws as aws

# Create a VPC
vpc = aws.ec2.Vpc("my-vpc",
    cidr_block="10.0.0.0/16",
    enable_dns_hostnames=True,
    enable_dns_support=True,
    tags={
        "Name": "My Pulumi VPC",
        "Environment": "Development"
    }
)

# Create an Internet Gateway
igw = aws.ec2.InternetGateway("my-igw",
    vpc_id=vpc.id,
    tags={
        "Name": "My Pulumi IGW"
    }
)

# Create a public subnet
public_subnet = aws.ec2.Subnet("public-subnet",
    vpc_id=vpc.id,
    cidr_block="10.0.1.0/24",
    availability_zone="us-east-1a",
    map_public_ip_on_launch=True,
    tags={
        "Name": "Public Subnet"
    }
)

# Create a route table for the public subnet
public_route_table = aws.ec2.RouteTable("public-route-table",
    vpc_id=vpc.id,
    routes=[{
        "cidr_block": "0.0.0.0/0",
        "gateway_id": igw.id,
    }],
    tags={
        "Name": "Public Route Table"
    }
)

# Associate the public subnet with the route table
route_table_association = aws.ec2.RouteTableAssociation("public-route-table-association",
    subnet_id=public_subnet.id,
    route_table_id=public_route_table.id
)

# Create a security group
security_group = aws.ec2.SecurityGroup("web-security-group",
    name="web-sg",
    description="Allow HTTP and SSH traffic",
    vpc_id=vpc.id,
    ingress=[
        {
            "protocol": "tcp",
            "from_port": 80,
            "to_port": 80,
            "cidr_blocks": ["0.0.0.0/0"],
        },
        {
            "protocol": "tcp",
            "from_port": 22,
            "to_port": 22,
            "cidr_blocks": ["0.0.0.0/0"],
        },
    ],
    egress=[{
        "protocol": "-1",
        "from_port": 0,
        "to_port": 0,
        "cidr_blocks": ["0.0.0.0/0"],
    }],
    tags={
        "Name": "Web Security Group"
    }
)

# Export some values so we can use them elsewhere
pulumi.export("vpc_id", vpc.id)
pulumi.export("public_subnet_id", public_subnet.id)
pulumi.export("security_group_id", security_group.id)
EOF

# Deploy your infrastructure!
pulumi up

# Review the preview and type 'yes' to confirm deployment

Amazing! You just deployed your first infrastructure with code! ๐Ÿ—๏ธ

๐ŸŽฎ Quick Examples

Letโ€™s try some practical examples to see Pulumiโ€™s power! ๐Ÿš€

Example 1: Web Server with Load Balancer

# Create a new project for web infrastructure
cd ~/pulumi-projects
pulumi new aws-python --name web-app --description "Web application with load balancer"
cd web-app

# Create a more complex infrastructure
cat > __main__.py << 'EOF'
import pulumi
import pulumi_aws as aws

# Get the latest Amazon Linux AMI
ami = aws.ec2.get_ami(
    most_recent=True,
    owners=["amazon"],
    filters=[{"name": "name", "values": ["amzn2-ami-hvm-*"]}]
)

# Create a launch template
launch_template = aws.ec2.LaunchTemplate("web-launch-template",
    name="web-servers",
    image_id=ami.id,
    instance_type="t3.micro",
    user_data="""#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Hello from Pulumi! Server: $(hostname)</h1>" > /var/www/html/index.html
""",
    tag_specifications=[{
        "resource_type": "instance",
        "tags": {
            "Name": "Web Server",
            "Environment": "Production"
        }
    }]
)

# Create an Auto Scaling Group
auto_scaling_group = aws.autoscaling.Group("web-asg",
    desired_capacity=2,
    max_size=4,
    min_size=1,
    launch_template={
        "id": launch_template.id,
        "version": "$Latest"
    },
    vpc_zone_identifiers=[public_subnet.id],  # Reuse from previous example
    tags=[{
        "key": "Name",
        "value": "Web ASG",
        "propagate_at_launch": True
    }]
)

# Create an Application Load Balancer
load_balancer = aws.lb.LoadBalancer("web-lb",
    internal=False,
    load_balancer_type="application",
    security_groups=[security_group.id],
    subnets=[public_subnet.id],
    tags={
        "Name": "Web Load Balancer"
    }
)

# Export the load balancer DNS name
pulumi.export("load_balancer_dns", load_balancer.dns_name)
EOF

# Deploy the web application
pulumi up

Now you have a scalable web application with load balancing! โš–๏ธ

Example 2: Multi-Environment Setup with Stacks

# Create different environments (dev, staging, prod)
pulumi stack init dev
pulumi stack init staging  
pulumi stack init prod

# Configure different settings for each environment
pulumi config set aws:region us-east-1 --stack dev
pulumi config set instanceType t3.micro --stack dev

pulumi config set aws:region us-west-2 --stack staging
pulumi config set instanceType t3.small --stack staging

pulumi config set aws:region eu-west-1 --stack prod
pulumi config set instanceType t3.medium --stack prod

# Deploy to development environment
pulumi stack select dev
pulumi up

# Deploy to production environment
pulumi stack select prod
pulumi up

You can now manage multiple environments easily! ๐ŸŒ

Example 3: TypeScript Infrastructure

# Create a TypeScript project for variety
cd ~/pulumi-projects
pulumi new aws-typescript --name ts-infrastructure --description "TypeScript infrastructure"
cd ts-infrastructure

# Install dependencies
npm install

# Create TypeScript infrastructure
cat > index.ts << 'EOF'
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// Create an S3 bucket for static website hosting
const bucket = new aws.s3.Bucket("my-website-bucket", {
    website: {
        indexDocument: "index.html",
        errorDocument: "error.html"
    },
    tags: {
        Environment: "Development",
        Project: "Pulumi Demo"
    }
});

// Create bucket policy for public access
const bucketPolicy = new aws.s3.BucketPolicy("bucket-policy", {
    bucket: bucket.id,
    policy: bucket.arn.apply(arn => JSON.stringify({
        Version: "2012-10-17",
        Statement: [{
            Effect: "Allow",
            Principal: "*",
            Action: "s3:GetObject",
            Resource: `${arn}/*`
        }]
    }))
});

// Upload a simple HTML file
const indexHtml = new aws.s3.BucketObject("index.html", {
    bucket: bucket.id,
    content: `
        <html>
            <head><title>My Pulumi Website</title></head>
            <body>
                <h1>๐Ÿš€ Welcome to my Pulumi-powered website!</h1>
                <p>This static site was deployed using Infrastructure as Code with TypeScript!</p>
            </body>
        </html>
    `,
    contentType: "text/html",
    key: "index.html"
});

// Export the website URL
export const websiteUrl = bucket.websiteEndpoint;
EOF

# Build and deploy
npm run build
pulumi up

You now have a static website deployed with TypeScript! ๐ŸŒ

๐Ÿšจ Fix Common Problems

Here are solutions to the most common Pulumi issues you might encounter:

Problem 1: Authentication Errors โš ๏ธ

Symptoms: โ€œNo valid credential sources foundโ€ or AWS authentication failures

Solutions:

# Check AWS credentials are configured
aws configure list

# Verify credentials work
aws sts get-caller-identity

# If using temporary credentials, export them
export AWS_ACCESS_KEY_ID=your-key-id
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_SESSION_TOKEN=your-session-token

# Check Pulumi is using correct AWS profile
pulumi config set aws:profile your-profile-name

Problem 2: State File Conflicts ๐Ÿ“Š

Symptoms: โ€œThe stack is currently locked byโ€ or concurrent update errors

Solutions:

# Cancel any ongoing operations
pulumi cancel

# If truly stuck, force unlock (use with caution!)
pulumi stack export > backup.json  # Create backup first
pulumi cancel --force

# Import state if needed
pulumi stack import --file backup.json

Problem 3: Resource Dependencies Failed ๐Ÿ”—

Symptoms: Resources created in wrong order or dependency errors

Solutions:

# Check your resource dependencies in code
# Make sure you're using resource outputs properly

# Example of correct dependency:
# subnet_id=vpc.id  โ† This creates implicit dependency

# Refresh state from actual infrastructure
pulumi refresh

# Force resource recreation if needed
pulumi up --replace "aws:ec2/instance:Instance::my-instance"

Problem 4: High Memory Usage During Deployment ๐Ÿ’พ

Symptoms: System running out of memory during large deployments

Solutions:

# Increase virtual memory
sudo dd if=/dev/zero of=/swapfile bs=1024 count=2097152  # 2GB swap
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

# Deploy in smaller batches
pulumi up --target-dependents "aws:ec2/vpc:Vpc::my-vpc"

# Use parallel deployment settings
pulumi config set pulumi:parallel 5  # Reduce from default 10

๐Ÿ“‹ Simple Commands Summary

Hereโ€™s your quick reference guide for Pulumi commands:

TaskCommandDescription
Create projectpulumi new aws-pythonInitialize new Python project
Deploy changespulumi upPreview and deploy infrastructure
View current statepulumi stackShow current stack information
List stackspulumi stack lsShow all available stacks
Switch stackspulumi stack select devChange to different environment
Set configpulumi config set key valueConfigure stack settings
View outputspulumi stack outputShow exported values
Destroy infrastructurepulumi destroyRemove all resources
Preview changespulumi previewShow what would change
Refresh statepulumi refreshSync state with actual resources

๐Ÿ’ก Tips for Success

Here are some pro tips to master Pulumi Infrastructure as Code! ๐ŸŒŸ

๐ŸŽฏ Use Strong Typing: Take advantage of your languageโ€™s type system - it catches errors at compile time, not deployment time!

โšก Leverage Pulumi Packages: Use community packages like @pulumi/awsx for higher-level abstractions and best practices.

๐Ÿ“Š Organize with Components: Create reusable components for common patterns like โ€œweb appโ€ or โ€œdatabase clusterโ€ that can be shared across projects.

๐Ÿ” Test Your Infrastructure: Write unit tests for your infrastructure code using your languageโ€™s testing framework (pytest, Jest, etc.).

๐Ÿ’พ Use Remote State Backend: Store your state in Pulumi Cloud or S3 backend instead of local files for team collaboration.

๐Ÿš€ Automate with CI/CD: Integrate Pulumi into your CI/CD pipeline with GitHub Actions, GitLab CI, or Jenkins for automated deployments.

๐Ÿ”— Export Useful Outputs: Export important values like URLs, IDs, and connection strings so other stacks can reference them.

๐Ÿ›ก๏ธ Implement Policy as Code: Use Pulumi CrossGuard to enforce security and compliance rules across all deployments.

๐Ÿ† What You Learned

Congratulations! Youโ€™ve successfully mastered Pulumi Infrastructure as Code! ๐ŸŽ‰ Hereโ€™s everything you accomplished:

โœ… Installed Pulumi CLI and configured your development environment
โœ… Created multiple projects using Python and TypeScript
โœ… Deployed real AWS infrastructure including VPCs, subnets, and load balancers
โœ… Managed multiple environments with stack configurations
โœ… Built reusable components and followed infrastructure best practices
โœ… Integrated with CI/CD pipelines for automated deployments
โœ… Troubleshot common issues and optimized deployment performance
โœ… Learned testing strategies for infrastructure code
โœ… Mastered state management and team collaboration workflows

๐ŸŽฏ Why This Matters

Pulumi transforms infrastructure management from configuration files to real software engineering! ๐Ÿš€ You can now:

๐Ÿ—๏ธ Write Infrastructure Like Software: Use familiar programming languages, IDEs, debugging tools, and testing frameworks
โšก Increase Productivity: Leverage loops, functions, classes, and package management for more efficient infrastructure code
๐Ÿ”„ Enable True DevOps: Seamlessly integrate infrastructure changes into your software development lifecycle
๐Ÿงช Test Before Deploy: Write unit tests, integration tests, and use static analysis to catch errors early
๐ŸŒ Deploy Anywhere: Use the same code to deploy to multiple clouds or on-premises environments
๐Ÿ“ฆ Build Reusable Components: Create and share infrastructure components like software libraries

You now possess cutting-edge Infrastructure as Code skills that make you invaluable for modern DevOps, Cloud Engineering, and Site Reliability Engineering roles. The ability to treat infrastructure as software is the future of cloud operations! โญ

Keep coding your infrastructure, keep automating, and remember - with Pulumi, your infrastructure is just another application! ๐Ÿ™Œโœจ