Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

IaC Packer — Multi-Cloud Base Images

Packer templates to build MERN stack base images for AWS and Azure from Ubuntu 22.04, provisioned with Ansible.

Overview

This repo uses HashiCorp Packer to:

  • AWS: Build an EBS-backed AMI (mern-base-image-{{timestamp}}) in us-east-1 from Canonical Ubuntu 22.04.
  • Azure: Build a Managed Image (mern-base-image-{{timestamp}}) in resource group mern-app-rg from Canonical Ubuntu 22.04.

Both images are provisioned by the same Ansible playbook (ansible/deploy.yml), so you get consistent base images across clouds.

Prerequisites

  • Packer (v1.7+)
  • Ansible
  • AWS: AWS CLI configured (e.g. aws configure) or env vars; VPC and subnet IDs set in build.pkr.hcl
  • Azure: Azure CLI installed and logged in (az login)

Project Structure

IaC_Packer/
├── build.pkr.hcl      # Packer config: AWS + Azure sources, Ansible provisioner
├── ansible/
│   ├── deploy.yml     # Playbook run during image build
│   └── nginx.conf     # Nginx config (if used by playbook)
└── README.md

Usage

1. Install Packer plugins

From the repo root:

packer init .

2. Validate

packer validate build.pkr.hcl

3. Build (both AWS and Azure)

packer build build.pkr.hcl

To build only one provider:

# AWS only
packer build -only=amazon-ebs.ubuntu_base build.pkr.hcl

# Azure only
packer build -only=azure-arm.ubuntu_base build.pkr.hcl

Configuration

  • AWS (build.pkr.hcl): vpc_id, subnet_id, region, and ami_name can be adjusted for your account.
  • Azure: build_resource_group_name, managed_image_resource_group_name, and managed_image_name can be changed; auth uses az login (use_azure_cli_auth = true).

Output

  • AWS: New AMI ID in us-east-1 with name mern-base-image-<timestamp>.
  • Azure: New image in mern-app-rg with name mern-base-image-<timestamp>.

Use these images when launching EC2 instances or Azure VMs for the MERN/pizza app.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages