CI/CD: Automate server builds with Packer and CodeBuild

What is a Golden Image?

So, how do you create Golden Images?

{
"builders": [
{
"type": "amazon-ebs",
"region": "ap-southeast-2",
"source_ami": "ami-02a599eb01e3b3c5b",
"instance_type": "t3.large",
"communicator": "ssh",
"ssh_username": "ubuntu",
"ami_name": "Medium_Example_Linux_{{timestamp}}"
}
],
"provisioners": [
{
"type": "shell",
"inline": ["sudo apt update",
"sudo apt install -y apache2",
"sudo rm -r /var/www/html/*",
"sudo echo 'ServerName example.com' >> /etc/apache2/sites-available/000-default.conf"]
},
{
"type": "file",
"source": "index.html",
"destination": "/var/www/html/index.html"
}
]
}
version: 0.2
phases:
install:
commands:
- curl -qL -o packer.zip https://releases.hashicorp.com/packer/1.5.5/packer_1.5.5_linux_amd64.zip
- unzip packer.zip
build:
commands:
- ./packer build webserver.json

--

--

--

Cloud & DevOps Specialist | Occasional blogger

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AAD B2B Collaboration Users

Device driver — File Operations structure

How to handle AWS SES bounces and complaints

P-Comp Switch Project

How to Enable TLS/SSL on Mlab MongoDB

When is the Definition of Done created?

Production Kubernetes on-premises and GDPR… Does it ring a bell? — Series I

Dynamic Programming

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Moha Alsouli

Moha Alsouli

Cloud & DevOps Specialist | Occasional blogger

More from Medium

Docker and AWS ECR on macOS

Deploy AWS ECS based Applications without DownTime Using Rollback Methodology

Setup TKG 1.5.1 Management cluster on AWS cloud

Google Cloud Platform Guide