Created
October 11, 2016 22:09
-
-
Save adam-phillipps/d97cae686df80fa990d98f3d25376816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get or create an EC2 client and cache that client so that a Context is more well tied together | |
| # === @params: opts [Hash] | |
| # * stub_responses: defaulted to false but it can be overriden with the desired responses for local testing | |
| # * region: defaulted to use the `#region()` method | |
| # * AWS::Credentials object, which will also scour the context and environment for your keys | |
| # === @returns: AWS::EC2 client | |
| # === Sample Usage | |
| # ``` | |
| # config = stub_responses: { | |
| # run_instances: { | |
| # instances: [ | |
| # { instance_id: 'asd-1234', launch_time: Time.now, state: { name: 'running' } | |
| # ] } | |
| # describe_instances: { | |
| # reservations: [ | |
| # { instances: [ | |
| # { instance_id: 'asd-1234', state: { code: 200, name: 'running' } }, | |
| # ] }] }, | |
| # describe_images: { | |
| # images: [ | |
| # { image_id: 'asdf', state: 'available' } | |
| # ] } | |
| # } | |
| # | |
| # ec2(config) # sets and gets an EC2 client | |
| # | |
| # images = ec2.describe_images | |
| # images.first[:image_id] | |
| # # => 'asdf' | |
| # ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment