rubycfn 0.4.10 → 0.5.4

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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -1
  3. data/Gemfile.lock +48 -46
  4. data/README.md +46 -71
  5. data/bin/rubycfn +17 -73
  6. data/lib/cli_methods.rb +2 -2
  7. data/lib/rubycfn/version.rb +1 -1
  8. data/rubycfn.gemspec +1 -1
  9. data/templates/.env +2 -0
  10. data/templates/.env.acceptance +1 -0
  11. data/templates/.env.dependencies.rspec +6 -0
  12. data/templates/.env.development +1 -0
  13. data/templates/.env.production +1 -0
  14. data/templates/.env.rspec +1 -0
  15. data/templates/.env.test +1 -0
  16. data/templates/{.gitignore.erb → .gitignore} +7 -0
  17. data/templates/{.rubocop.yml.erb → .rubocop.yml} +17 -1
  18. data/templates/{Gemfile.erb → Gemfile} +0 -1
  19. data/templates/README.md +58 -0
  20. data/templates/{Rakefile.erb → Rakefile} +15 -8
  21. data/templates/config.yaml +68 -0
  22. data/templates/lib/aws_helper/aws_sdk.rb +30 -0
  23. data/templates/{compiler.rb.erb → lib/aws_helper/compiler.rb} +15 -9
  24. data/templates/lib/aws_helper/dependencies.rb +35 -0
  25. data/templates/{deploy.rb.erb → lib/aws_helper/deploy.rb} +5 -4
  26. data/templates/lib/aws_helper/helpers.rb +3 -0
  27. data/templates/{main_aws_helper.rb.erb → lib/aws_helper/main.rb} +0 -0
  28. data/templates/{upload_stack.rb.erb → lib/aws_helper/upload_stack.rb} +8 -6
  29. data/templates/lib/core/applications.rb +625 -0
  30. data/templates/lib/core/assume_role.rb +40 -0
  31. data/templates/lib/core/classes.rb +25 -0
  32. data/templates/{core_compile.rb.erb → lib/core/compile.rb} +1 -0
  33. data/templates/lib/core/dependencies.rb +29 -0
  34. data/templates/{core_deploy.rb.erb → lib/core/deploy.rb} +20 -10
  35. data/templates/lib/core/git.rb +15 -0
  36. data/templates/lib/core/init.rb +221 -0
  37. data/templates/{core_upload.rb.erb → lib/core/upload.rb} +0 -0
  38. data/templates/{main.rb.erb → lib/main.rb} +8 -6
  39. data/templates/lib/shared_concerns/global_variables.rb +56 -0
  40. data/templates/{helper_methods.rb.erb → lib/shared_concerns/helper_functions.rb} +0 -0
  41. data/templates/lib/shared_concerns/helper_methods.rb +3 -0
  42. data/templates/{shared_methods.rb.erb → lib/shared_concerns/shared_methods.rb} +11 -0
  43. data/templates/lib/stacks/acm_stack/certificate_manager.rb +79 -0
  44. data/templates/{new_stack.rb.erb → lib/stacks/acm_stack/main.rb} +3 -4
  45. data/templates/lib/stacks/ecs_stack/ecs_cluster.rb +344 -0
  46. data/templates/lib/stacks/ecs_stack/lifecycle_hook.rb +190 -0
  47. data/templates/lib/stacks/ecs_stack/load_balancer.rb +70 -0
  48. data/templates/{ecs_stack.rb.erb → lib/stacks/ecs_stack/main.rb} +3 -0
  49. data/templates/lib/stacks/ecs_stack/rollback.rb +77 -0
  50. data/templates/{project_stack.rb.erb → lib/stacks/parent_stack/main.rb} +2 -2
  51. data/templates/lib/stacks/parent_stack/parent.rb +18 -0
  52. data/templates/lib/stacks/vpc_stack/infra_vpc.rb +193 -0
  53. data/templates/{vpc_stack.rb.erb → lib/stacks/vpc_stack/main.rb} +1 -2
  54. data/templates/{parent_stack_spec.rb.erb → spec/lib/parent_spec.rb} +2 -5
  55. data/templates/{spec_helper.rb.erb → spec/spec_helper.rb} +2 -2
  56. metadata +61 -51
  57. data/format.vim +0 -3
  58. data/templates/.env.erb +0 -4
  59. data/templates/.env.production.erb +0 -6
  60. data/templates/.env.rspec.erb +0 -6
  61. data/templates/.env.test.erb +0 -6
  62. data/templates/.gitlab-ci.yml.erb +0 -75
  63. data/templates/aws_sdk.rb.erb +0 -18
  64. data/templates/core_diff.rb.erb +0 -59
  65. data/templates/dependencies.rb.erb +0 -23
  66. data/templates/ecs_stack_concern.rb.erb +0 -20
  67. data/templates/global_variables.rb.erb +0 -16
  68. data/templates/helpers.rb.erb +0 -7
  69. data/templates/new_concern.rb.erb +0 -10
  70. data/templates/project_concern.rb.erb +0 -26
  71. data/templates/subnets.rb.erb +0 -18
  72. data/templates/vpc_concerns.rb.erb +0 -87
  73. data/templates/vpc_spec.rb.erb +0 -39
data/lib/cli_methods.rb CHANGED
@@ -1,5 +1,5 @@
1
- def render(file, vars, path)
2
- template = File.read("#{path}/templates/#{file}.erb")
1
+ def render(file, vars)
2
+ template = File.read(file)
3
3
  ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
4
4
  end
5
5
 
@@ -1,4 +1,4 @@
1
1
  # Rubycfn version
2
2
  module Rubycfn
3
- VERSION = "0.4.10".freeze
3
+ VERSION = "0.5.4".freeze
4
4
  end
data/rubycfn.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "neatjson", "~> 0.8.4"
22
- spec.add_runtime_dependency "json", "~> 2.1.0"
22
+ spec.add_runtime_dependency "json", "~> 2.3.0"
23
23
  spec.add_runtime_dependency "activesupport", "~> 5.1.5"
24
24
  spec.add_runtime_dependency "tty-prompt", "~> 0.16.0"
25
25
  spec.add_runtime_dependency "dotenv", "~> 2.4.0"
data/templates/.env ADDED
@@ -0,0 +1,2 @@
1
+ AWS_REGION="<%= region %>"
2
+ ENVIRONMENT="development"
@@ -0,0 +1 @@
1
+ # Acceptance-specific ENV vars
@@ -0,0 +1,6 @@
1
+ ARTIFACTBUCKET=rspec-artifactbucket-m0ck
2
+ HOSTEDZONENAME=rspec.example.com
3
+ HOSTEDZONEID=13117756P2M0CK
4
+ LOGGINGBUCKET=rspec-dependencystack-loggingbucket-mock
5
+ CLOUDFORMATIONBUCKET=rspec-dependencystack-cloudformationbucket-mock
6
+ LAMBDABUCKET=rspec-dependencystack-lambdabucket-mock
@@ -0,0 +1 @@
1
+ # Development-specific ENV vars
@@ -0,0 +1 @@
1
+ # Production-specific ENV vars
@@ -0,0 +1 @@
1
+ # ENV vars for rspec environment
@@ -0,0 +1 @@
1
+ # Test-specific ENV vars
@@ -82,3 +82,10 @@ temp/
82
82
  attic/
83
83
  /venv
84
84
  /Gemfile.lock
85
+ .env.dependencies
86
+ .env.dependencies.development
87
+ .env.dependencies.test
88
+ .env.dependencies.acceptance
89
+ .env.dependencies.production
90
+ CloudFormationResourceSpecification.json
91
+ config.json
@@ -11,6 +11,7 @@ AllCops:
11
11
  Exclude:
12
12
  - "test/**/*.rb"
13
13
  - "spec/**/*.rb"
14
+ - "attic/**/*"
14
15
 
15
16
  Metrics/AbcSize:
16
17
  Max: 500
@@ -34,7 +35,7 @@ Style/Documentation:
34
35
  Enabled: false
35
36
 
36
37
  Metrics/LineLength:
37
- Max: 500
38
+ Max: 700
38
39
  Exclude:
39
40
  - "test/**/*"
40
41
  - "spec/**/*"
@@ -87,5 +88,20 @@ Style/IfUnlessModifier:
87
88
  Style/DateTime:
88
89
  Enabled: false
89
90
 
91
+ Style/RedundantSelf:
92
+ Enabled: false
93
+
90
94
  Layout/SpaceInsideHashLiteralBraces:
91
95
  EnforcedStyle: space
96
+
97
+ Metrics/MethodLength:
98
+ Enabled: false
99
+
100
+ Metrics/PerceivedComplexity:
101
+ Max: 20
102
+
103
+ Style/EvalWithLocation:
104
+ Enabled: false
105
+
106
+ Style/PerlBackrefs:
107
+ Enabled: false
@@ -2,7 +2,6 @@ source "https://rubygems.org" do
2
2
  gem "aws-sdk", "~> 3.0.1"
3
3
  gem "aws-sdk-s3", "~> 1.36.0"
4
4
  gem "colorize", "~> 0.8.1"
5
- gem "diffy", "~> 3.3.0"
6
5
  gem "git-revision", "~> 0.0.2"
7
6
  gem "launchy", "~> 2.4.3"
8
7
  gem "rspec", "~> 3.8"
@@ -0,0 +1,58 @@
1
+ # Infrastructure for <%= project_name %>
2
+
3
+ ```
4
+ __________ ____ __________________.___._________ _____________________
5
+ \______ \ | \______ \__ | |\_ ___ \\_ _____/\______ \
6
+ | _/ | /| | _// | |/ \ \/ | __) | | _/
7
+ | | \ | / | | \\____ |\ \____| \ | | \
8
+ |____|_ /______/ |______ // ______| \______ /\___ / |______ /
9
+ \/ \/ \/ \/ \/ \/ [<%= version %>]
10
+ ```
11
+
12
+ ## Prerequisites
13
+
14
+ - Edit .env.private and configure your AWS credentials, or export your AWS credentials.
15
+ - Type `rake init` to create the DependencyStack in your AWS account
16
+
17
+ ## Rake commands
18
+
19
+ `rake` - Retrieve required outputs from DependencyStack, Compile the code into CloudFormation templates and run unit tests
20
+ `rake init` - Deploy the DependencyStack in the AWS account
21
+ `rake compile` - Compile the code into CloudFormation templates
22
+ `rake spec` - Run unit tests
23
+ `rake upload` - Upload the CloudFormation templates to s3
24
+ `rake update` - Save required outputs from DependencyStack to .env.dependencies.<ENVIRONMENT>
25
+ `rake apply` - Deploy the CloudFormation templates
26
+
27
+ ## Stack configuration
28
+
29
+ The `config.yaml` file in the root directory of this project contains most of the configuration. It contains the networking configuration for each environment, subnet configuration, DNS and ECS (Docker) containers that are deployed.
30
+
31
+ ## Adding your own resources
32
+
33
+ The lib/stacks/ directory contains all nested stacks for this project. Every nested stack has a
34
+ directory under lib/stacks/. You can add resources to any of these stacks, or create a new stack altogether. See [https://github.com/dennisvink/rubycfn/blob/master/README.md](https://github.com/dennisvink/rubycfn/blob/master/README.md) for documentation.
35
+
36
+ ## About
37
+
38
+ The code generated by Rubycfn is copyrighted by Dennis Vink (https://drvink.com/),
39
+ except for modifications made to the <%= project_name %> project after the initial
40
+ `git init` command.
41
+
42
+ For the generated code permission is hereby granted, free of charge, to any
43
+ person obtaining a copy of the generated software and associated documentation
44
+ files (the "Software"), to deal in the Software without restriction, including
45
+ without limitation the rights to use, copy, modify, merge, publish, distribute,
46
+ sublicense, and/or sell copies of the Software, and to permit persons to whom
47
+ the Software is furnished to do so, subject to the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be included in all
50
+ copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
55
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58
+ THE SOFTWARE.
@@ -12,17 +12,22 @@ RSpec::Core::RakeTask.new do |t|
12
12
  end
13
13
 
14
14
  desc "Apply CloudFormation template"
15
- task :apply do
15
+ task :apply_stack do
16
16
  require_relative "lib/main"
17
17
  require_relative "lib/core/deploy"
18
18
  end
19
19
 
20
20
  desc "Upload stacks to s3"
21
- task :upload do
21
+ task :upload_stack do
22
22
  require_relative "lib/main"
23
23
  require_relative "lib/core/upload"
24
24
  end
25
25
 
26
+ desc "Initialize AWS Account"
27
+ task :init do
28
+ require_relative "lib/core/init"
29
+ end
30
+
26
31
  desc "Clean build directory"
27
32
  task :clean do
28
33
  Dir.foreach("build/") do |f|
@@ -31,14 +36,13 @@ task :clean do
31
36
  end
32
37
  end
33
38
 
34
- desc "Diff CloudFormation template"
35
- task :diff do
36
- require_relative "lib/main"
37
- require_relative "lib/core/diff"
39
+ desc "Store dependencies of DependencyStack in .env.dependencies.<ENVIRONMENT>"
40
+ task :dependencies do
41
+ require_relative "lib/core/dependencies.rb"
38
42
  end
39
43
 
40
44
  desc "Compile CloudFormation"
41
- task :compile do
45
+ task :compile_stack do
42
46
  require_relative "lib/main"
43
47
  require_relative "lib/core/compile"
44
48
  end
@@ -47,4 +51,7 @@ RuboCop::RakeTask.new(:rubocop) do |t|
47
51
  t.options = ["--display-cop-names"]
48
52
  end
49
53
 
50
- task default: %i(spec compile)
54
+ task default: %i(dependencies compile_stack spec)
55
+ task compile: %i(dependencies compile_stack)
56
+ task upload: %i(dependencies upload_stack)
57
+ task apply: %i(dependencies apply_stack)
@@ -0,0 +1,68 @@
1
+ environments:
2
+ rspec:
3
+ vpc_cidr: 192.168.0.0/16
4
+ stack_name: rspec-devops
5
+ domain_name: "rspec.io"
6
+ no_subdomain: true
7
+ development:
8
+ vpc_cidr: 10.10.0.0/16
9
+ stack_name: development-devops
10
+ test:
11
+ vpc_cidr: 10.20.0.0/16
12
+ stack_name: test-devops
13
+ acceptance:
14
+ vpc_cidr: 10.30.0.0/16
15
+ stack_name: acceptance-devops
16
+ production:
17
+ vpc_cidr: 10.40.0.0/16
18
+ stack_name: production-devops
19
+ subnets:
20
+ - ec2_public:
21
+ owner: infra
22
+ public: true
23
+ offset: 1
24
+ deploy_nat: true
25
+ output_cidr: false
26
+ - ec2_private:
27
+ owner: infra
28
+ public: false
29
+ offset: 2
30
+ deploy_nat: false
31
+ output_cidr: false
32
+ - backend_rds_public:
33
+ owner: infra
34
+ public: true
35
+ offset: 3
36
+ deploy_nat: false
37
+ output_cidr: false
38
+ - backend_rds_private:
39
+ owner: infra
40
+ public: false
41
+ offset: 4
42
+ deploy_nat: false
43
+ output_cidr: false
44
+ applications:
45
+ hello-world:
46
+ image: nginxdemos/hello
47
+ container_port: 80
48
+ priority: 2
49
+ min: 2
50
+ max: 8
51
+ mem: 128
52
+ env:
53
+ SOME_ENV_VAR: Exposed
54
+ SOME_OTHER_VAR: desopxE
55
+ # SOME_REFFED_VAR: :foobar.ef
56
+ # SOME_OTHER_STACK_VAR: :vpc_stack.ref("Outputs.VpcId")
57
+ # SOME_ENV_VAR: ${MY_ENV_VAR}
58
+ hello-world2:
59
+ image: tutum/hello-world
60
+ container_port: 80
61
+ priority: 3
62
+ min: 2
63
+ max: 8
64
+ mem: 128
65
+ env:
66
+ SOME_ENV_VAR: Exposed
67
+ SOME_OTHER_VAR: desopxE
68
+ domain_name: "example.com"
@@ -0,0 +1,30 @@
1
+ def create_bucket_if_not_exists(aws_region, artifact_bucket)
2
+ s3 = Aws::S3::Resource.new(region: aws_region)
3
+ begin
4
+ s3.create_bucket(bucket: artifact_bucket)
5
+ rescue => exception
6
+ raise exception unless exception.class == Aws::S3::Errors::BucketAlreadyOwnedByYou
7
+ end
8
+ s3
9
+ end
10
+
11
+ def set_aws_credentials(region, access_key_id, secret_access_key)
12
+ if access_key_id.nil? == false && secret_access_key.nil? == false
13
+ aws_session_token = ENV["AWS_SESSION_TOKEN"]
14
+ if aws_session_token.nil?
15
+ Aws.config.update(
16
+ region: region,
17
+ credentials: Aws::Credentials.new(access_key_id, secret_access_key)
18
+ )
19
+ else
20
+ Aws.config.update(
21
+ region: region,
22
+ credentials: Aws::Credentials.new(access_key_id, secret_access_key, aws_session_token)
23
+ )
24
+ end
25
+ else
26
+ Aws.config.update(
27
+ region: region
28
+ )
29
+ end
30
+ end
@@ -1,12 +1,14 @@
1
1
  require "git-revision"
2
2
 
3
- def update_references(contents, environment, artifact_bucket)
3
+ def update_references(contents, environment, _artifact_bucket)
4
+ Dotenv.load(".env.private")
5
+ Dotenv.load(".env.dependencies.#{ENV["ENVIRONMENT"]}")
4
6
  contents["Resources"].map do |resource|
5
7
  resource_name = resource.shift
6
8
  resource_values = resource.shift
7
9
  if resource_values["Type"] == "AWS::CloudFormation::Stack"
8
10
  template_hash = @stack_hashes[resource_name.to_sym]
9
- s3_url = "https://s3.amazonaws.com/#{artifact_bucket}/#{environment}-" \
11
+ s3_url = "https://s3.amazonaws.com/#{ENV["CLOUDFORMATIONBUCKET"]}/#{environment}-" \
10
12
  "#{resource_name.downcase}-#{template_hash}.json"
11
13
  resource_values["Properties"]["TemplateURL"] = s3_url
12
14
  end
@@ -30,17 +32,21 @@ end
30
32
  def compile_stacks(skip_creation = false)
31
33
  stacks = {}
32
34
  FileUtils.mkdir_p "build" unless skip_creation
33
- Module.constants.select do |mod|
34
- if mod =~ /Stack$/
35
- send("include", Object.const_get("SharedConcerns"))
36
- stacks[mod.to_sym] = send("include", Object.const_get(mod)).render_template("AWS")
35
+ # Iterate twice to support dynamically generated modules
36
+ 2.times do
37
+ Module.constants.select do |mod|
38
+ if mod =~ /Stack$/
39
+ next unless stacks[mod.to_sym].nil?
40
+ send("include", Object.const_get("SharedConcerns"))
41
+ stacks[mod.to_sym] = send("include", Object.const_get(mod)).render_template("AWS")
42
+ end
37
43
  end
38
44
  end
39
45
 
40
46
  stacks.each do |stack_name, stack|
41
47
  stack = inject_dummy_resource(stack)
42
48
  next if JSON.parse(stack)["Resources"].nil?
43
- stack_to_md5(stack_name, stack)
49
+ stack_to_hash(stack_name)
44
50
  unless skip_creation
45
51
  puts "- Saved #{stack_name} to build/#{ENV["ENVIRONMENT"]}-#{stack_name.downcase}.json"
46
52
  File.open("build/#{ENV["ENVIRONMENT"]}-#{stack_name.downcase}.json", "w") { |f| f.write(JSON.pretty_generate(JSON.parse(stack))) }
@@ -50,9 +56,9 @@ def compile_stacks(skip_creation = false)
50
56
  stacks.each do |stack_name, stack|
51
57
  stack = inject_dummy_resource(stack)
52
58
  next if JSON.parse(stack)["Resources"].nil?
53
- stack = update_references(JSON.parse(stack), ENV["ENVIRONMENT"], ENV["ARTIFACT_BUCKET"])
59
+ stack = update_references(JSON.parse(stack), ENV["ENVIRONMENT"], ENV["CLOUDFORMATIONBUCKET"])
54
60
  stacks[stack_name] = stack
55
- stack_to_md5(stack_name, stack)
61
+ stack_to_hash(stack_name)
56
62
  unless skip_creation
57
63
  File.open("build/#{ENV["ENVIRONMENT"]}-#{stack_name.downcase}.json", "w") { |f| f.write(JSON.pretty_generate(JSON.parse(stack))) }
58
64
  end
@@ -0,0 +1,35 @@
1
+ def infra_config
2
+ config = YAML.safe_load(File.read("config.yaml"), [Symbol])
3
+ config["applications"] ||= {}
4
+ config["environments"] ||= {}
5
+ config["subnets"] ||= {}
6
+ config
7
+ end
8
+
9
+ def load_env_vars
10
+ Dotenv.load(".env.private")
11
+ Dotenv.load(".env.dependencies.#{ENV["ENVIRONMENT"]}")
12
+ Dotenv.load(".env")
13
+ Dotenv.load(".env.#{ENV["ENVIRONMENT"]}")
14
+
15
+ check_dependencies
16
+ {
17
+ artifact_bucket: ENV["ARTIFACTBUCKET"],
18
+ aws_region: ENV["AWS_REGION"],
19
+ aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
20
+ aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
21
+ cloudformation_bucket: ENV["CLOUDFORMATIONBUCKET"],
22
+ environment: ENV["ENVIRONMENT"],
23
+ stack_name: infra_config["environments"][ENV["ENVIRONMENT"]]["stack_name"]
24
+ }
25
+ end
26
+
27
+ def check_dependencies
28
+ ENV["AWS_REGION"] ||= ENV["AWS_DEFAULT_REGION"]
29
+ raise "AWS_REGION not set." unless ENV["AWS_REGION"]
30
+ raise "CLOUDFORMATIONBUCKET not set. Run `rake init` and `rake update` first!" unless ENV["CLOUDFORMATIONBUCKET"]
31
+ raise "ARTIFACTBUCKET not set. Run `rake init` and `rake update` first!" unless ENV["ARTIFACTBUCKET"]
32
+ raise "ENVIRONMENT not set." unless ENV["ENVIRONMENT"]
33
+ raise "`stack_name` not configured in config.yaml" unless infra_config["environments"][ENV["ENVIRONMENT"]]["stack_name"]
34
+ raise "AWS CREDENTIALS NOT SET" unless ENV["AWS_ACCESS_KEY_ID"] && ENV["AWS_SECRET_ACCESS_KEY"]
35
+ end
@@ -3,7 +3,7 @@ WAITING_STATES = %w(
3
3
  UPDATE_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_IN_PROGRESS
4
4
  UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_IN_PROGRESS
5
5
  ).freeze
6
- SUCCESS_STATES = %w(CREATE_COMPLETE UPDATE_COMPLETE).freeze
6
+ SUCCESS_STATES = %w(IMPORT_COMPLETE CREATE_COMPLETE UPDATE_COMPLETE).freeze
7
7
  FAILURE_STATES = %w(
8
8
  CREATE_FAILED DELETE_FAILED UPDATE_ROLLBACK_FAILED
9
9
  ROLLBACK_FAILED ROLLBACK_COMPLETE ROLLBACK_FAILED
@@ -11,7 +11,7 @@ FAILURE_STATES = %w(
11
11
  ).freeze
12
12
  END_STATES = SUCCESS_STATES + FAILURE_STATES
13
13
  DEPLOYABLE_STATES = %w(
14
- CREATE_COMPLETE UPDATE_COMPLETE ROLLBACK_COMPLETE
14
+ IMPORT_COMPLETE CREATE_COMPLETE UPDATE_COMPLETE ROLLBACK_COMPLETE
15
15
  UPDATE_ROLLBACK_COMPLETE
16
16
  ).freeze
17
17
 
@@ -38,16 +38,17 @@ end
38
38
  def get_parent_stack_s3_location(bucket, environment)
39
39
  stacks = compile_stacks(true)
40
40
  parent_stack = nil
41
+ file_hash = nil
41
42
 
42
43
  stacks.each do |stack_name, stack|
43
44
  next if JSON.parse(stack)["Resources"].nil?
44
45
  JSON.parse(stack)["Resources"].each do |_resource, payload|
45
46
  if payload["Type"] == "AWS::CloudFormation::Stack"
46
47
  parent_stack = stack_name
48
+ file_hash = git_revision
47
49
  break
48
50
  end
49
51
  end
50
52
  end
51
-
52
- "https://s3.amazonaws.com/#{bucket}/#{environment}-#{parent_stack.downcase}-#{@stack_hashes[parent_stack.to_sym]}.json"
53
+ "https://s3.amazonaws.com/#{bucket}/#{environment}-#{parent_stack.downcase}-#{file_hash}.json"
53
54
  end