0.0
No commit activity in last 3 years
No release in over 3 years
After deployed, create the instance's AMI and delete old AMI versions. If you spefied 'keep_amis', it's keep number of AMIs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0
~> 2.0

Runtime

 Project Readme

Capistrano AMI

build status MIT License Gem Version

This plugin that create AMI (Amazon Machine Image) and manage generations tasks into capistrano script. capistrano-ami tasks are able to run when deploy target servers exists in AWS (http://aws.amazon.com/).

Installation

Add this line to your application's Gemfile:

gem 'capistrano-ami'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capistrano-ami

Usage

Load capistrano-ami into your capistrano configuration file Capfile:

require 'capistrano/ami'

And set config values in deploy script config/deploy.rb:

set :aws_region, 'ap-northeast-1'  # deploy servers region name
set :base_ami_name, 'web-role'     # name: "#{base_ami_name}_#{instance_id}_#{deploy_timestamp}" default is capistrano-ami
set :keep_amis, 3                  # keeps number of AMIs. default is 5

If you do not specify, base_ami_name and keep_amis uses default value.

Credentials

capistrano-ami supports various credential providers. As of the following priority:

  • Specified shared credentials
  • Key values
  • Environment values
  • Default shared credentials
  • IAM role

Key values

You can set credentials in deploy script config/deploy.rb:

set :aws_access_key_id, 'YOUR_AWS_ACCESS_KEY'
set :aws_secret_access_key, 'YOUR_AWS_SECRET_KEY'

Environment values

capistrano-ami looks AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, AWS_REGION environemt values.

$ export AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY
$ export AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_KEY

If you do not want to fix region in deploy script. use AWS_REGION environment values and other credential providers.

Shared credentials

Shared credentials are credentials file in local machine. default location is ~/.aws/credentials. More infomation. If you want to use default, do not specify key values in delopy script. But if you want to use other profile, you should specify following:

set :aws_credentials_profile_name, 'profile_name'

IAM role

IAM role is most secure credential provider. If you can, should use this. More infomation. This provider used in no credentials configuration. Because you should not specify key values.

Versions

We check working this plugin following platform versions.

  • Ruby
    • 2.3.0
  • Capistrano
    • 3.5.0

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/wata727/capistrano-ami. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.