lono-cfn 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lono_cfn/base.rb +19 -4
- data/lib/lono_cfn/cli.rb +1 -0
- data/lib/lono_cfn/create.rb +0 -6
- data/lib/lono_cfn/update.rb +5 -0
- data/lib/lono_cfn/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c6dad389b3fefe174cc4e2b1e5e2f400e1cfe7a
|
4
|
+
data.tar.gz: 551b23221bb7208f57ace0517a7b4b1e01e02b4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62cc0595fac727b77bc1152aaab946899b5d057fad75d314d16d4440c9425193d172a47c12c3aaa325071a3796f27e009e00c53766ea5c29504ad8a24514c023
|
7
|
+
data.tar.gz: 6d776ab590dbc1aad9bc5ca6419726c434daffcf58ba53133a7d20ba51c2aa6d24eb960651c2e5974075268a4d6636ff388484336964f59c6687f9076c58c847
|
data/lib/lono_cfn/base.rb
CHANGED
@@ -15,8 +15,6 @@ module LonoCfn
|
|
15
15
|
@params_path = get_source_path(params_name, :params)
|
16
16
|
puts "Using template: #{@template_path}"
|
17
17
|
puts "Using parameters: #{@params_path}"
|
18
|
-
|
19
|
-
@region = options[:region] || 'us-east-1'
|
20
18
|
end
|
21
19
|
|
22
20
|
def run
|
@@ -37,13 +35,13 @@ module LonoCfn
|
|
37
35
|
generator = LonoParams::Generator.new(@stack_name,
|
38
36
|
project_root: @project_root,
|
39
37
|
path: @params_path,
|
40
|
-
allow_no_file:
|
38
|
+
allow_no_file: false)
|
41
39
|
generator.generate # Writes the json file in CamelCase keys format
|
42
40
|
generator.params # Returns Array in underscore keys format
|
43
41
|
end
|
44
42
|
|
45
43
|
def cfn
|
46
|
-
@cfn ||= Aws::CloudFormation::Client.new
|
44
|
+
@cfn ||= Aws::CloudFormation::Client.new
|
47
45
|
end
|
48
46
|
|
49
47
|
def check_for_errors
|
@@ -66,6 +64,23 @@ module LonoCfn
|
|
66
64
|
errors
|
67
65
|
end
|
68
66
|
|
67
|
+
def stack_exists?
|
68
|
+
return if @options[:noop]
|
69
|
+
|
70
|
+
exist = true
|
71
|
+
begin
|
72
|
+
# When the stack does not exist an exception is raised. Example:
|
73
|
+
# Aws::CloudFormation::Errors::ValidationError: Stack with id blah does not exist
|
74
|
+
response = cfn.describe_stacks(stack_name: @stack_name)
|
75
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
76
|
+
e.message
|
77
|
+
if e.message =~ /Stack with/ || e.message =~ /does not exist/
|
78
|
+
exist = false
|
79
|
+
end
|
80
|
+
end
|
81
|
+
exist
|
82
|
+
end
|
83
|
+
|
69
84
|
# if existing in params path then use that
|
70
85
|
# if it doesnt assume it is a full path and check that
|
71
86
|
# else fall back to convention, which also eventually gets checked in check_for_errors
|
data/lib/lono_cfn/cli.rb
CHANGED
@@ -7,6 +7,7 @@ module LonoCfn
|
|
7
7
|
class_option :verbose, type: :boolean
|
8
8
|
class_option :noop, type: :boolean
|
9
9
|
class_option :project_root, desc: "Project folder. Defaults to current directory", default: '.'
|
10
|
+
class_option :region, desc: "AWS region"
|
10
11
|
|
11
12
|
# common to create and update
|
12
13
|
class_option :template, desc: 'override convention and specify the template file to use'
|
data/lib/lono_cfn/create.rb
CHANGED
data/lib/lono_cfn/update.rb
CHANGED
@@ -7,6 +7,11 @@ module LonoCfn
|
|
7
7
|
|
8
8
|
# aws cloudformation update-stack --stack-name prod-hi-123456789 --parameters file://output/params/prod-hi-123456789.json --template-body file://output/prod-hi.json
|
9
9
|
def update_stack(params)
|
10
|
+
unless stack_exists?
|
11
|
+
puts "Cannot update a stack because the #{@stack_name} does not exists."
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
10
15
|
template_body = IO.read(@template_path)
|
11
16
|
message = "#{@stack_name} stack updating."
|
12
17
|
if @options[:noop]
|
data/lib/lono_cfn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lono-cfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
requirements: []
|
219
219
|
rubyforge_project:
|
220
|
-
rubygems_version: 2.6.
|
220
|
+
rubygems_version: 2.6.8
|
221
221
|
signing_key:
|
222
222
|
specification_version: 4
|
223
223
|
summary: Wrapper cfn tool to quickly create CloudFormation stacks from lono templates
|