A packer project that builds an AWS AMI with the the webcounter application installed as service.
- Install Packer.
- Ruby version ~> 2.5.1 for running KitchenCI test.
Set AWS credentials according to AWS documentation.
The packer template is in template.json
file. In the variables
section you can set parameters to customize the build. Help on setting, overriding variables in packer can be found here.
aws_base_ami_id
- the base AMI to use. It needs to be accessible with the provided AWS credential.wc_ver
- the version of thewebcounter
app to use for the build.
Run packer validate template.json
- to make basic template validation.
Run packer build -var 'wc_ver=0.6.1' template.json
- to build the AWS AMI with packer.
The project includes a KitchenCI configuration to run basic tests against the box outputted from packer.
To run it you need to install the gems specified in the Gemfile
. Its recommended to use ruby bundler
.
gem install bundler
bundle install
Kitchen will need AWS access to manage an EC2 instance life cycle. Credentials need to be set according to the AWS documentation for Ruby SDK.
Note: that the AWS region must be set as environment variable export AWS_REGION=my-region
or added as key driver.region
in .kitchen.yml
. Using the ~/.aws/config
to set the region will not work.
The ami owner and name search pattern are defined in .kitchen.yml
. Currently the test will check the latest AMI with the defined owner and name that matches slav-webcounter-*-*
. In case a different AMI needs to be tested modify the key driver.image_search.name
and/or driver.image_search.owner
under platform ubuntu-webcounter
in .kitchen.yml
bundle exec kitchen converge
- will build the test environment.bundle exec kitchen verify
- will run the tests.bundle exec kitchen destroy
- will destroy the test environment.bundle exec kitchen test
- will perform the above steps with a single command.