stackit 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +88 -1
- data/lib/stackit/cli.rb +7 -7
- data/lib/stackit/stack/managed_stack.rb +1 -1
- data/lib/stackit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56031c1ebaca58621ce162ca4fb35b7a0bc29b10
|
4
|
+
data.tar.gz: 323a83ffc79f320216b599be24f81f541fe57c32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b57f90da98d269b8055d399beb6a74620bd3ab57dcdedee83e790972435f872434035fcd36302067a2cc802256d5547588e39d9adebbd1e252097f5721287c05
|
7
|
+
data.tar.gz: 07a4248f7239c20a68637b38ae0a892cca8b95d8229ab87ea5dd52c3e8fafbe36969b75fb4578f7a96e8d479ec29b52f69b13c2b8ebc4974d3595f87786f3c21
|
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
Simple, elegant CloudFormation dependency management.
|
4
4
|
|
5
|
+
[CloudFormation parameters](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html) can become cumbersome to manage as your infrastructure scales. At some point, you realize there has to be a better way than specifying parameters on the command line or putting them into files and shell scripts.
|
6
|
+
|
7
|
+
StackIT makes it easier to manage the lifecycle of your stacks by allowing you to map values from existing stacks. For example, we can have a VPC stack that defines networking resources that a separate remote access VPN stack references when launched. StackIT will automatically map VPC resource, output and/or parameter values to parameters defined in the VPN template.
|
8
|
+
|
9
|
+
StackIT can also work with parameter files and user defined parameters in conjunction with CloudFormation stacks. This is quite useful if you want to override parameters.
|
10
|
+
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
@@ -18,9 +24,90 @@ Or install it yourself as:
|
|
18
24
|
|
19
25
|
$ gem install stackit
|
20
26
|
|
27
|
+
## Parameters
|
28
|
+
|
29
|
+
Let's take a look at each of the ways to get parameter values into your template.
|
30
|
+
|
31
|
+
StackIT uses the following order of precedence when determining which parameter value to pass into your template.
|
32
|
+
|
33
|
+
1. File Parameters
|
34
|
+
2. Existing CloudFormation Stacks
|
35
|
+
3. User Defined Parameters
|
36
|
+
|
37
|
+
##### File Parameters
|
38
|
+
|
39
|
+
File parameters work just like the default AWS CLI parameters file. Simply specify the path to your JSON parameter file using the `--parameter-file` option.
|
40
|
+
|
41
|
+
stackit create-stack --stack-name mystack --template mytemplate.json --parameter-file mytemplate.parameters
|
42
|
+
|
43
|
+
##### Existing CloudFormation Stacks
|
44
|
+
|
45
|
+
Your stack can `--depend` on existing stacks. Any resource, output, or parameter whose ID matches a parameter key in the template will automatically have it's value passed into the stack during management.
|
46
|
+
|
47
|
+
> Parameter values mapped using `--depends` override parameters defined in the parameter file.
|
48
|
+
|
49
|
+
stackit create-stack --stack-name mystack --template my-template --parameter-file mytemplate.parameters --depends myvpc
|
50
|
+
|
51
|
+
##### User Defined Parameters
|
52
|
+
|
53
|
+
User defined parameters allow you to define the parameters yourself using the `--parameters` option.
|
54
|
+
|
55
|
+
> User defined parameters override file parameters.
|
56
|
+
|
21
57
|
## Usage
|
22
58
|
|
23
|
-
|
59
|
+
### CLI
|
60
|
+
|
61
|
+
StackIT ships with [Thor](http://whatisthor.com/) to provide a command line interface to stack management. Run the `help` command for details.
|
62
|
+
|
63
|
+
# show top level commands
|
64
|
+
stackit help
|
65
|
+
|
66
|
+
# show options for create command
|
67
|
+
stackit help create
|
68
|
+
|
69
|
+
##### Create a stack using a parameter file
|
70
|
+
|
71
|
+
stackit create-stack --stack-name mystack --template mytemplate.json --parameter-file mytemplate.parameters
|
72
|
+
|
73
|
+
##### Create a stack using `--depends` to reference resource, output and parameter values in the "myvpc" stack
|
74
|
+
|
75
|
+
stackit create-stack --stack-name mystack --template mytemplate.json --depends myvpc
|
76
|
+
|
77
|
+
##### Create a stack using user defined parameters
|
78
|
+
|
79
|
+
stackit create-stack --stack-name mystack --template mytemplate.json --parameters param1:value1 param2:value2
|
80
|
+
|
81
|
+
##### Create a stack using a parameter file, overriding parameters found in the "myvpc" resource, output or parameters.
|
82
|
+
|
83
|
+
stackit create-stack --stack-name mystack --template mytemplate.json --parameter-file mytemplate.parameters --depends myvpc
|
84
|
+
|
85
|
+
##### Create a stack using a parameter file, overriding those parameters with mapped parameters in the "myvpc" stack, and override both of those with user defined parameters.
|
86
|
+
|
87
|
+
stackit create-stack --stack-name mystack --template mytemplate.json --parameter-file mytemplate.parameters --depends myvpc --parameters param1:final_value
|
88
|
+
|
89
|
+
##### Mapping Parameters
|
90
|
+
|
91
|
+
You may optionally map parameters that don't have matching keys. For example, let's map the value for the "Vpc" resource into the "VpcId" parameter in our VPN stack using the `--parameter-map` option.
|
92
|
+
|
93
|
+
# Maps the "Vpc" resource value in the "myvpc" stack to the "VpcId" parameter in the VPN stack.
|
94
|
+
stackit create-stack --stack-name myvpn --template vpn.json --parameter-file vpn.parameters --depends myvpc --parameter-map VpcId:Vpc
|
95
|
+
|
96
|
+
### Library
|
97
|
+
|
98
|
+
StackIT can be used as library in your own automation tools.
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
ManagedStack.new({
|
102
|
+
template: '/path/to/template.json',
|
103
|
+
stack_name: 'mystack',
|
104
|
+
depends: 'otherstack',
|
105
|
+
user_defined_parameters: {
|
106
|
+
:param1 => 'myvalue',
|
107
|
+
:param2 => 'something else'
|
108
|
+
}
|
109
|
+
}).create!
|
110
|
+
```
|
24
111
|
|
25
112
|
## Development
|
26
113
|
|
data/lib/stackit/cli.rb
CHANGED
@@ -25,7 +25,7 @@ module Stackit
|
|
25
25
|
self.name.gsub(%r{.*::}, '').gsub(%r{^[A-Z]}) { |match| match[0].downcase }.gsub(%r{[A-Z]}) { |match| "-#{match[0].downcase}" }
|
26
26
|
end
|
27
27
|
|
28
|
-
desc 'create', 'Creates a new CloudFormation stack'
|
28
|
+
desc 'create-stack', 'Creates a new CloudFormation stack'
|
29
29
|
method_option :template, aliases: '-t', desc: 'The cloudformation template', :required => true
|
30
30
|
method_option :stack_name, aliases: '-n', desc: 'The stack name. Defaults to the camelized template file name', :required => true
|
31
31
|
method_option :stack_policy, :aliases => '-p', :desc => 'A local file system or S3 (HTTPS) path to the stack policy'
|
@@ -36,7 +36,7 @@ module Stackit
|
|
36
36
|
method_option :wait, :aliases => '-w', type: :boolean, default: false, desc: 'Wait for the stack to enter STATUS_COMPLETE before returning or raise an exception if it times out'
|
37
37
|
method_option :force, :desc => 'Force a stack update on unchanged templates'
|
38
38
|
method_option :dry_run, :type => :boolean, :default => false, :desc => 'Run all code except AWS API calls'
|
39
|
-
def
|
39
|
+
def create_stack
|
40
40
|
ManagedStack.new({
|
41
41
|
template: options[:template],
|
42
42
|
stack_name: options[:stack_name],
|
@@ -52,7 +52,7 @@ module Stackit
|
|
52
52
|
}).create!
|
53
53
|
end
|
54
54
|
|
55
|
-
desc 'update', 'Updates an existing CloudFormation stack'
|
55
|
+
desc 'update-stack', 'Updates an existing CloudFormation stack'
|
56
56
|
method_option :template, aliases: '-t', desc: 'The cloudformation template', :required => true
|
57
57
|
method_option :stack_name, aliases: '-n', desc: 'The stack name. Defaults to the camelized template file name', :required => true
|
58
58
|
method_option :stack_policy, :aliases => '-p', :desc => 'A local file system or S3 (HTTPS) path to the stack policy'
|
@@ -64,7 +64,7 @@ module Stackit
|
|
64
64
|
method_option :wait, :aliases => '-w', type: :boolean, default: false, desc: 'Wait for the stack to enter STATUS_COMPLETE before returning or raise an exception if it times out'
|
65
65
|
method_option :force, :desc => 'Force a stack update on unchanged templates'
|
66
66
|
method_option :dry_run, :type => :boolean, :default => false, :desc => 'Run all code except AWS API calls'
|
67
|
-
def
|
67
|
+
def update_stack
|
68
68
|
ManagedStack.new({
|
69
69
|
template: options[:template],
|
70
70
|
stack_name: options[:stack_name],
|
@@ -81,12 +81,12 @@ module Stackit
|
|
81
81
|
}).update!
|
82
82
|
end
|
83
83
|
|
84
|
-
desc 'delete', 'Deletes a CloudFormation stack'
|
84
|
+
desc 'delete-stack', 'Deletes a CloudFormation stack'
|
85
85
|
method_option :stack_name, aliases: '-n', desc: 'The stack name. Defaults to the camelized template file name', :required => true
|
86
86
|
method_option :retain_resources, :aliases => '-r', :type => :array, :desc => 'Space delimited list of logical resource ids to retain after the stack is deleted'
|
87
87
|
method_option :wait, :aliases => '-w', type: :boolean, default: false, desc: 'Wait for the stack to enter STATUS_COMPLETE before returning or raise an exception if it times out'
|
88
88
|
method_option :dry_run, :type => :boolean, :default => false, :desc => 'Run all code except AWS API calls'
|
89
|
-
def
|
89
|
+
def delete_stack
|
90
90
|
ManagedStack.new({
|
91
91
|
stack_name: options[:stack_name],
|
92
92
|
wait: options[:wait],
|
@@ -95,7 +95,7 @@ module Stackit
|
|
95
95
|
}).delete!
|
96
96
|
end
|
97
97
|
|
98
|
-
desc 'create-keypair', 'Creates a new EC2 keypair'
|
98
|
+
desc 'create-keypair', 'Creates a new EC2 keypair and returns it\'s corresponding private key'
|
99
99
|
method_option :name, desc: 'The name of the keypair', :required => true
|
100
100
|
def create_keypair
|
101
101
|
puts Stackit.aws.ec2.create_key_pair({
|
data/lib/stackit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Hahn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|