cloudformation_wrapper 0.3.0 → 0.4.0
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/lib/cloudformation_wrapper/stack_manager.rb +42 -10
 - data/lib/cloudformation_wrapper/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 69da516d911165b1f15e8bc976d8ba8c87b8222bec9e50de64a9386940ea9139
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4b215fe82fbf88140a605a9083bab5b45b11a2a7c78455c5ae32140e1dd07045
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 32b702ed3dd113524616e22cf1c441a250bef49fdde36c48a4a800b657e50bf8de5b3c7e2561777df1e39f9822f14b54335719388b9b66539c007233a125669d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: beb32bc92fa6fcdf34454e68aed2473c5ed2db64e8c0298ff42f772d8fe0e96d059be1fa099c5d5712436f4865e4ff45ea7c8cb31f12d64af17f1cc74dbbae43
         
     | 
| 
         @@ -19,13 +19,13 @@ module CloudFormationWrapper 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                  verified_options = verify_options(options)
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                  if verified_options.key?('client')
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
                  cf_client = if verified_options.key?('client')
         
     | 
| 
      
 23 
     | 
    
         
            +
                                verified_options[:client]
         
     | 
| 
      
 24 
     | 
    
         
            +
                              elsif verified_options.key?(:client)
         
     | 
| 
      
 25 
     | 
    
         
            +
                                verified_options[:client]
         
     | 
| 
      
 26 
     | 
    
         
            +
                              else
         
     | 
| 
      
 27 
     | 
    
         
            +
                                Aws::CloudFormation::Client.new(credentials: credentials, region: region)
         
     | 
| 
      
 28 
     | 
    
         
            +
                              end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                  ensure_template_file_exists(verified_options[:template_path], cf_client)
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
         @@ -33,13 +33,44 @@ module CloudFormationWrapper 
     | 
|
| 
       33 
33 
     | 
    
         
             
                    verified_options[:parameters],
         
     | 
| 
       34 
34 
     | 
    
         
             
                    verified_options[:name],
         
     | 
| 
       35 
35 
     | 
    
         
             
                    verified_options[:template_path],
         
     | 
| 
      
 36 
     | 
    
         
            +
                    verified_options[:capabilities],
         
     | 
| 
       36 
37 
     | 
    
         
             
                    cf_client
         
     | 
| 
       37 
38 
     | 
    
         
             
                  )
         
     | 
| 
       38 
39 
     | 
    
         
             
                end
         
     | 
| 
       39 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
                def self.validate_template(options)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  unless options[:client]
         
     | 
| 
      
 43 
     | 
    
         
            +
                    access_key_id = options[:access_key_id] || ENV['AWS_ACCESS_KEY_ID'] || ENV['ACCESS_KEY'] ||
         
     | 
| 
      
 44 
     | 
    
         
            +
                                    raise(ArgumentError, 'Cannot find AWS Access Key ID.')
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    secret_access_key = options[:secret_access_key] || ENV['AWS_SECRET_ACCESS_KEY'] || ENV['SECRET_KEY'] ||
         
     | 
| 
      
 47 
     | 
    
         
            +
                                        raise(ArgumentError, 'Cannot find AWS Secret Key.')
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    credentials = Aws::Credentials.new(access_key_id, secret_access_key)
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  region = options[:region] || ENV['AWS_REGION'] || ENV['AMAZON_REGION'] || ENV['AWS_DEFAULT_REGION'] ||
         
     | 
| 
      
 53 
     | 
    
         
            +
                           raise(ArgumentError, 'Cannot find AWS Region.')
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  unless options[:template_path] && (options[:template_path].is_a? String)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    raise ArgumentError, 'template_path must be provided (String)'
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  cf_client = if options.key?('client')
         
     | 
| 
      
 60 
     | 
    
         
            +
                                options[:client]
         
     | 
| 
      
 61 
     | 
    
         
            +
                              elsif options.key?(:client)
         
     | 
| 
      
 62 
     | 
    
         
            +
                                options[:client]
         
     | 
| 
      
 63 
     | 
    
         
            +
                              else
         
     | 
| 
      
 64 
     | 
    
         
            +
                                Aws::CloudFormation::Client.new(credentials: credentials, region: region)
         
     | 
| 
      
 65 
     | 
    
         
            +
                              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                  cf_client.validate_template(template_body: File.read(options[:template_path]))
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
       40 
70 
     | 
    
         
             
                def self.verify_options(options)
         
     | 
| 
       41 
71 
     | 
    
         
             
                  defaults = {
         
     | 
| 
       42 
     | 
    
         
            -
                    description: 'Deployed with CloudFormation Wrapper.', parameters: {}, wait_for_stack: true
         
     | 
| 
      
 72 
     | 
    
         
            +
                    description: 'Deployed with CloudFormation Wrapper.', parameters: {}, wait_for_stack: true,
         
     | 
| 
      
 73 
     | 
    
         
            +
                    capabilities: []
         
     | 
| 
       43 
74 
     | 
    
         
             
                  }
         
     | 
| 
       44 
75 
     | 
    
         | 
| 
       45 
76 
     | 
    
         
             
                  options_with_defaults = options.reverse_merge(defaults)
         
     | 
| 
         @@ -62,7 +93,7 @@ module CloudFormationWrapper 
     | 
|
| 
       62 
93 
     | 
    
         
             
                  puts 'Valid Template File.'
         
     | 
| 
       63 
94 
     | 
    
         
             
                end
         
     | 
| 
       64 
95 
     | 
    
         | 
| 
       65 
     | 
    
         
            -
                def self.deploy_stack(parameters, stack_name, template_path, cf_client)
         
     | 
| 
      
 96 
     | 
    
         
            +
                def self.deploy_stack(parameters, stack_name, template_path, capabilities, cf_client)
         
     | 
| 
       66 
97 
     | 
    
         
             
                  template_parameters = construct_template_parameters(parameters)
         
     | 
| 
       67 
98 
     | 
    
         
             
                  client_token = ENV.fetch('BUILD_NUMBER', SecureRandom.uuid.delete('-'))
         
     | 
| 
       68 
99 
     | 
    
         
             
                  old_stack = describe_stack(stack_name, cf_client)
         
     | 
| 
         @@ -75,7 +106,8 @@ module CloudFormationWrapper 
     | 
|
| 
       75 
106 
     | 
    
         
             
                    change_set_name: "ChangeSet-#{client_token}",
         
     | 
| 
       76 
107 
     | 
    
         
             
                    client_token: client_token,
         
     | 
| 
       77 
108 
     | 
    
         
             
                    description: ENV.fetch('BUILD_TAG', 'Stack Updates.'),
         
     | 
| 
       78 
     | 
    
         
            -
                    change_set_type: change_set_type
         
     | 
| 
      
 109 
     | 
    
         
            +
                    change_set_type: change_set_type,
         
     | 
| 
      
 110 
     | 
    
         
            +
                    capabilities: capabilities
         
     | 
| 
       79 
111 
     | 
    
         
             
                  }
         
     | 
| 
       80 
112 
     | 
    
         | 
| 
       81 
113 
     | 
    
         
             
                  change_set_id = cf_client.create_change_set(create_change_set_params).id
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: cloudformation_wrapper
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Ted Armstrong
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018-01- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-01-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     |