aws_as_code 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.hound.yml +3 -0
- data/.rspec +4 -0
- data/.rubocop.yml +16 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +5 -0
- data/Guardfile +100 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +6 -0
- data/aws-as-code.gemspec +41 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/circle.yml +13 -0
- data/exe/aws-as-code +64 -0
- data/lib/aws_as_code.rb +9 -0
- data/lib/aws_as_code/concerns/aws_task_helpers.rb +28 -0
- data/lib/aws_as_code/stack_state_semaphore.rb +57 -0
- data/lib/aws_as_code/task/base.rb +16 -0
- data/lib/aws_as_code/task/compile.rb +39 -0
- data/lib/aws_as_code/task/create.rb +16 -0
- data/lib/aws_as_code/task/update.rb +17 -0
- data/lib/aws_as_code/task/upload.rb +41 -0
- data/lib/aws_as_code/version.rb +4 -0
- metadata +254 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eade5597ca3f105f6391f9d610d8f221fb206e67
|
4
|
+
data.tar.gz: 0416d1eae2493a8bf05d8d3a35cbf900b598f0f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94799f73045ee7899ed3301c9f6308a5322d9baeb3382817fdb70bd939a4cb5a9d36cf4c7747c58170653a1d2583f0867af8508c07b6ce4c8f1cb59ffc1785af
|
7
|
+
data.tar.gz: bc3ea12b89769e178244729d96066e415527eeb966677eced702e61c7be314185a0880b662accac95d2ce9ee5996838d0acee70ec3639d0e6657b883fd5682e4
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
Include:
|
4
|
+
- "**/*.gemspec"
|
5
|
+
- "**/Gemfile"
|
6
|
+
Exclude:
|
7
|
+
- "vendor/**/*"
|
8
|
+
- "spec/**/*"
|
9
|
+
- "features/**/*"
|
10
|
+
- "db/schema.rb"
|
11
|
+
|
12
|
+
Style/StringLiterals:
|
13
|
+
EnforcedStyle: double_quotes
|
14
|
+
|
15
|
+
Style/Documentation:
|
16
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at kbourn@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Rails files
|
44
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
45
|
+
dsl.watch_spec_files_for(rails.app_files)
|
46
|
+
dsl.watch_spec_files_for(rails.views)
|
47
|
+
|
48
|
+
watch(rails.controllers) do |m|
|
49
|
+
[
|
50
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
51
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
52
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Rails config changes
|
57
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
58
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
59
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
60
|
+
|
61
|
+
# Capybara features specs
|
62
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
63
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
64
|
+
|
65
|
+
# Turnip features and steps
|
66
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
67
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
68
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
guard :rubocop do
|
73
|
+
watch(%r{.+\.rb$})
|
74
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
75
|
+
end
|
76
|
+
|
77
|
+
cucumber_options = {
|
78
|
+
# Below are examples overriding defaults
|
79
|
+
|
80
|
+
# cmd: 'bin/cucumber',
|
81
|
+
# cmd_additional_args: '--profile guard',
|
82
|
+
|
83
|
+
# all_after_pass: false,
|
84
|
+
# all_on_start: false,
|
85
|
+
# keep_failed: false,
|
86
|
+
# feature_sets: ['features/frontend', 'features/experimental'],
|
87
|
+
|
88
|
+
# run_all: { cmd_additional_args: '--profile guard_all' },
|
89
|
+
# focus_on: { 'wip' }, # @wip
|
90
|
+
# notification: false
|
91
|
+
}
|
92
|
+
|
93
|
+
guard "cucumber", cucumber_options do
|
94
|
+
watch(%r{^features/.+\.feature$})
|
95
|
+
watch(%r{^features/support/.+$}) { "features" }
|
96
|
+
|
97
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
|
98
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "features"
|
99
|
+
end
|
100
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Konstantin Burnaev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Aws::As::Code
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aws/as/code`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'aws_as_code'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install aws_as_code
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```
|
26
|
+
bundle exec aws-as-code create \
|
27
|
+
--ruby-dir=cfn \
|
28
|
+
--json-dir=cfn-compiled \
|
29
|
+
--bucket=my-cfn-bucket \
|
30
|
+
--template=environment \
|
31
|
+
--stack=master
|
32
|
+
```
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
37
|
+
|
38
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aws_as_code. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
43
|
+
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/aws-as-code.gemspec
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "aws_as_code/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "aws_as_code"
|
9
|
+
spec.version = AwsAsCode::VERSION
|
10
|
+
spec.authors = ["Konstantin Burnaev"]
|
11
|
+
spec.email = ["kbourn@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = <<EOF
|
14
|
+
Provides a way to track your AWS infrastructure as a code in your version control system.
|
15
|
+
EOF
|
16
|
+
|
17
|
+
spec.homepage = "https://github.com/bkon/aws-as-code"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`
|
21
|
+
.split("\x0")
|
22
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_dependency "cfndsl", "~> 0.9"
|
28
|
+
spec.add_dependency "thor", "~> 0.19"
|
29
|
+
spec.add_dependency "term-ansicolor", "~> 1.3.2"
|
30
|
+
spec.add_dependency "aws-sdk", "~> 2.5.11"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_development_dependency "cucumber", "~> 2.4"
|
36
|
+
spec.add_development_dependency "rubocop", "~> 0.41"
|
37
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
38
|
+
spec.add_development_dependency "guard-rubocop", "~> 1.2"
|
39
|
+
spec.add_development_dependency "guard-cucumber", "~> 2.1"
|
40
|
+
spec.add_development_dependency "codecov"
|
41
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "aws_as_code"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start
|
data/bin/setup
ADDED
data/circle.yml
ADDED
data/exe/aws-as-code
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "aws_as_code"
|
6
|
+
require "thor"
|
7
|
+
require "cfndsl"
|
8
|
+
require "ostruct"
|
9
|
+
|
10
|
+
DEFAULT_RUBY_DIR = "cfn".freeze
|
11
|
+
DEFAULT_JSON_DIR = "cfn-compiled".freeze
|
12
|
+
DEFAULT_STACK = "master".freeze
|
13
|
+
DEFAULT_TEMPLATE = "environment".freeze
|
14
|
+
|
15
|
+
# Main CLI application for aws-as-code gem
|
16
|
+
class AwsAsCodeCli < Thor
|
17
|
+
class_option :ruby_dir, default: DEFAULT_RUBY_DIR
|
18
|
+
class_option :json_dir, default: DEFAULT_JSON_DIR
|
19
|
+
class_option :bucket, required: true
|
20
|
+
class_option :template, default: DEFAULT_TEMPLATE
|
21
|
+
class_option :stack, default: DEFAULT_STACK
|
22
|
+
|
23
|
+
desc "compile", "compile cfndsl to CF JSON"
|
24
|
+
def compile
|
25
|
+
AwsAsCode::Task::Compile.new(config).execute
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "upload", "upload compiled data to S3 bucket"
|
29
|
+
def upload
|
30
|
+
AwsAsCode::Task::Upload.new(config).execute
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "do-create", "create a new stack"
|
34
|
+
def do_create
|
35
|
+
AwsAsCode::Task::Create.new(config).execute
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "do-update", "update existing stack"
|
39
|
+
def do_update
|
40
|
+
AwsAsCode::Task::Update.new(config).execute
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "create", "create a new stack"
|
44
|
+
def create
|
45
|
+
invoke :compile
|
46
|
+
invoke :upload
|
47
|
+
invoke :do_create
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "update", "update existing stack"
|
51
|
+
def update
|
52
|
+
invoke :compile
|
53
|
+
invoke :upload
|
54
|
+
invoke :do_update
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def config
|
60
|
+
@config ||= OpenStruct.new options
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
AwsAsCodeCli.start(ARGV)
|
data/lib/aws_as_code.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "aws_as_code/version"
|
3
|
+
require "aws_as_code/stack_state_semaphore"
|
4
|
+
require "aws_as_code/concerns/aws_task_helpers"
|
5
|
+
require "aws_as_code/task/base"
|
6
|
+
require "aws_as_code/task/compile"
|
7
|
+
require "aws_as_code/task/upload"
|
8
|
+
require "aws_as_code/task/create"
|
9
|
+
require "aws_as_code/task/update"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module AwsAsCode
|
2
|
+
module Concerns
|
3
|
+
module AwsTaskHelpers
|
4
|
+
private
|
5
|
+
|
6
|
+
def semaphore
|
7
|
+
StackStateSemaphore.new logger: logger
|
8
|
+
end
|
9
|
+
|
10
|
+
def cloud_formation
|
11
|
+
@cloud_formation ||= Aws::CloudFormation::Client.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def s3
|
15
|
+
@s3 ||= Aws::S3::Resource.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def stack
|
19
|
+
@stack ||= Aws::CloudFormation::Stack.new config.stack
|
20
|
+
end
|
21
|
+
|
22
|
+
def template_object
|
23
|
+
bucket = s3.bucket config.bucket
|
24
|
+
bucket.object "#{config.stack}/#{config.template}.json"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "term/ansicolor"
|
2
|
+
|
3
|
+
module AwsAsCode
|
4
|
+
class StackStateSemaphore
|
5
|
+
include Term::ANSIColor
|
6
|
+
|
7
|
+
def initialize(logger:)
|
8
|
+
@logger = logger
|
9
|
+
end
|
10
|
+
|
11
|
+
def wait(stack)
|
12
|
+
wait_for_stack_availability stack
|
13
|
+
yield
|
14
|
+
wait_for_stack_availability stack
|
15
|
+
end
|
16
|
+
|
17
|
+
def wait_for_stack_availability(stack)
|
18
|
+
stack.wait_until(max_attempts: 360, delay: 10) do |s|
|
19
|
+
if in_progress? s
|
20
|
+
log_waiting s
|
21
|
+
false
|
22
|
+
else
|
23
|
+
log_proceeding s
|
24
|
+
true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :logger
|
32
|
+
|
33
|
+
def log_waiting(stack)
|
34
|
+
message = format(
|
35
|
+
"Stack %s is in %s state, waiting...",
|
36
|
+
white(stack.name),
|
37
|
+
white(stack.stack_status)
|
38
|
+
)
|
39
|
+
|
40
|
+
logger.info message
|
41
|
+
end
|
42
|
+
|
43
|
+
def log_proceeding(stack)
|
44
|
+
message = format(
|
45
|
+
"Stack %s is in %s state, proceeding",
|
46
|
+
white(stack.name),
|
47
|
+
white(stack.stack_status)
|
48
|
+
)
|
49
|
+
|
50
|
+
logger.info message
|
51
|
+
end
|
52
|
+
|
53
|
+
def in_progress?(stack)
|
54
|
+
stack.stack_status =~ /IN_PROGRESS/
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "cfndsl"
|
2
|
+
|
3
|
+
# frozen_string_literal: true
|
4
|
+
module AwsAsCode
|
5
|
+
module Task
|
6
|
+
# Compiles all input templates and puts
|
7
|
+
# JSON to the output directory
|
8
|
+
class Compile
|
9
|
+
attr_reader :config
|
10
|
+
|
11
|
+
def initialize(config)
|
12
|
+
@config = config
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
input_files.each { |filename| compile_single_file filename }
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def compile_single_file(filename)
|
22
|
+
output_filename = File.basename(filename, ".rb") + ".json"
|
23
|
+
output_pathname = File.join config.json_dir, output_filename
|
24
|
+
|
25
|
+
cfn = CfnDsl.eval_file_with_extras(
|
26
|
+
filename,
|
27
|
+
[],
|
28
|
+
STDERR
|
29
|
+
)
|
30
|
+
|
31
|
+
File.open(output_pathname, "w") { |f| f.write cfn.to_json }
|
32
|
+
end
|
33
|
+
|
34
|
+
def input_files
|
35
|
+
Dir.glob(File.join(config.ruby_dir, "**/*.rb"))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module AwsAsCode
|
3
|
+
module Task
|
4
|
+
class Create < Base
|
5
|
+
include AwsAsCode::Concerns::AwsTaskHelpers
|
6
|
+
|
7
|
+
def execute
|
8
|
+
cloud_formation
|
9
|
+
.create_stack stack_name: config.stack,
|
10
|
+
template_url: template_object.public_url,
|
11
|
+
parameters: []
|
12
|
+
semaphore.wait_for_stack_availability stack
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module AwsAsCode
|
3
|
+
module Task
|
4
|
+
class Update < Base
|
5
|
+
include AwsAsCode::Concerns::AwsTaskHelpers
|
6
|
+
|
7
|
+
def execute
|
8
|
+
semaphore.wait(stack) do
|
9
|
+
cloud_formation
|
10
|
+
.update_stack stack_name: config.stack,
|
11
|
+
template_url: template_object.public_url,
|
12
|
+
parameters: []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
require "pathname"
|
3
|
+
|
4
|
+
# frozen_string_literal: true
|
5
|
+
module AwsAsCode
|
6
|
+
module Task
|
7
|
+
class Upload < Base
|
8
|
+
def execute
|
9
|
+
input_files.each { |filename| upload_single_file filename }
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def upload_single_file(filename)
|
15
|
+
bucket
|
16
|
+
.object(s3_object_name(filename))
|
17
|
+
.upload_file filename
|
18
|
+
end
|
19
|
+
|
20
|
+
def bucket
|
21
|
+
s3 = Aws::S3::Resource.new
|
22
|
+
s3.bucket config.bucket
|
23
|
+
end
|
24
|
+
|
25
|
+
def s3_object_name(filename)
|
26
|
+
template_path = Pathname.new filename
|
27
|
+
config_path = Pathname.new config.json_dir
|
28
|
+
|
29
|
+
key = template_path
|
30
|
+
.relative_path_from(config_path)
|
31
|
+
.to_s
|
32
|
+
|
33
|
+
[config.stack, key].join("/")
|
34
|
+
end
|
35
|
+
|
36
|
+
def input_files
|
37
|
+
Dir.glob File.join(config.json_dir, "**/*.json")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,254 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aws_as_code
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konstantin Burnaev
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cfndsl
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.19'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.19'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: term-ansicolor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.5.11
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.5.11
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: cucumber
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.4'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.4'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.41'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.41'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '4.7'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '4.7'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: guard-rubocop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.2'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.2'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: guard-cucumber
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2.1'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2.1'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: codecov
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
description:
|
196
|
+
email:
|
197
|
+
- kbourn@gmail.com
|
198
|
+
executables:
|
199
|
+
- aws-as-code
|
200
|
+
extensions: []
|
201
|
+
extra_rdoc_files: []
|
202
|
+
files:
|
203
|
+
- ".gitignore"
|
204
|
+
- ".hound.yml"
|
205
|
+
- ".rspec"
|
206
|
+
- ".rubocop.yml"
|
207
|
+
- ".ruby-version"
|
208
|
+
- ".travis.yml"
|
209
|
+
- CODE_OF_CONDUCT.md
|
210
|
+
- Gemfile
|
211
|
+
- Guardfile
|
212
|
+
- LICENSE.txt
|
213
|
+
- README.md
|
214
|
+
- Rakefile
|
215
|
+
- aws-as-code.gemspec
|
216
|
+
- bin/console
|
217
|
+
- bin/setup
|
218
|
+
- circle.yml
|
219
|
+
- exe/aws-as-code
|
220
|
+
- lib/aws_as_code.rb
|
221
|
+
- lib/aws_as_code/concerns/aws_task_helpers.rb
|
222
|
+
- lib/aws_as_code/stack_state_semaphore.rb
|
223
|
+
- lib/aws_as_code/task/base.rb
|
224
|
+
- lib/aws_as_code/task/compile.rb
|
225
|
+
- lib/aws_as_code/task/create.rb
|
226
|
+
- lib/aws_as_code/task/update.rb
|
227
|
+
- lib/aws_as_code/task/upload.rb
|
228
|
+
- lib/aws_as_code/version.rb
|
229
|
+
homepage: https://github.com/bkon/aws-as-code
|
230
|
+
licenses:
|
231
|
+
- MIT
|
232
|
+
metadata: {}
|
233
|
+
post_install_message:
|
234
|
+
rdoc_options: []
|
235
|
+
require_paths:
|
236
|
+
- lib
|
237
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - ">="
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: '0'
|
242
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - ">="
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '0'
|
247
|
+
requirements: []
|
248
|
+
rubyforge_project:
|
249
|
+
rubygems_version: 2.5.1
|
250
|
+
signing_key:
|
251
|
+
specification_version: 4
|
252
|
+
summary: Provides a way to track your AWS infrastructure as a code in your version
|
253
|
+
control system.
|
254
|
+
test_files: []
|