Skip to content

Creates a new EBS encrypted Windows Base AMI via Packer using the latest Amazon Base image

License

Notifications You must be signed in to change notification settings

RobBiddle/PackerBaseAMI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PackerBaseAMI

Synopsis

PackerBaseAMI is a PowerShell module which automates the process of creating a Windows Base AMI for use with AWS EC2.

Description

PackerBaseAMI is a PowerShell module which automates the process of creating a Windows Base AMI for use with AWS EC2.

There are a few problems associated with utilizing the Amazon provided Base Windows AMI images:

  1. The Amazon provided Base Windows AMI images are frequently deprecated and deregistered.

    • This causes problems if you are using those AMIs in CloudFormation stacks, as you may not be able to update the stack after the AMI is deregistered. This problem is resolved by creating an new AMI based on the Amazon provided image.
    • The AMI produced by this module will remain in your account until you choose to remove it.
  2. The Amazon provided Base Windows AMI images cannot be directly copied via the AWS API (cli / Powershell)

    • The Amazon recommended process is a manual one utilizing the web console via a browser, which is highly inefficient and not well suited to automation
  3. The Amazon provided Base Windows AMI images are not encrypted. They can't be encrypted as they are based on snapshots owned by Amazon, which means that Amazon would have to share their private encryption keys in order for customer to use their encrypted images, which would render the encryption useless.

    • The AMI produced by this module will encrypt the snapshot for the new AMI by default, using the master key associated with your AWS account.

Upon importing the module, a single PowerShell cmdlet named New-PackerBaseAMI is exported which makes use of AWSPowerShell

Table of Contents

Install

  • Install PowerShell

    I suggest using the latest verison of PowerShell if possible so that you can use PowerShellGet cmdlets Download the latest PowerShell here: https://aka.ms/wmf5latest

  • Install Packer

    You have two options:

    1. Install Packer from the main site: https://packer.io
    2. Or use Chocolatey to install Packer:
  • Install PackerBaseAMI & Requirements:

    (Assumes you have PowerShellGet and access to PowerShellGallery.com)

    • AWSPowerShell PowerShell Module
      # If you want the old monolithic module:
      Install-Module AWSPowerShell
      # Otherwise, if you want the new modularized modules with only the necessary cmdlets (recommended):
      Install-Module AWS.Tools.Common,AWS.Tools.EC2
    • PackerBaseAMI PowerShell Module
      Install-Module PackerBaseAMI
  • Import the PackerBaseAMI module
    Import-Module PackerBaseAMI

Example

New-PackerBaseAMI -AccountNumber '111111111111' -Alias ExampleAlias -BaseOS 'Windows_Server-2019-English-Full-Base' -IamRole 'ExampleRoleName' -Region 'us-east-1' -OutputDirectoryPath 'c:\example\directory'

Maintainer(s)

Robert D. Biddle - https://github.com/RobBiddle

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Credits

  • Upic Solutions for sponsoring my time to develop this project. This code is being used as part of our mission to help United Ways be the best community solution leaders, in an increasingly competitive environment, by providing state of the art business and technology solutions
  • Hashicorp for creating Packer and other fantastic open source projects
  • The AWSPowerShell Devs for supporting all of us PowerShell users

License

GNU General Public License v3.0 https://github.com/RobBiddle/PackerBaseAMI/LICENSE.txt

Support
  • Please ⭐Star this repo if you found some of this code useful!
  • If you're an unbelievably nice person and want to show your appreciation, I like beer ;-)
    • Send me 🍺 money via LTC: MHJj5jaWFU2VeqEZXnLC4xaZdQ1Nu9NC48
    • Send me 🍺 money via BTC: 38ieXk9rn2LJEsfimFWiyycUZZv5ABJPqM
    • Send me 🍺 money via USD: https://paypal.me/RobertBiddle

About

Creates a new EBS encrypted Windows Base AMI via Packer using the latest Amazon Base image

Resources

License

Stars

Watchers

Forks

Packages

No packages published