README.md in kumo_keisei-5.0.0 vs README.md in kumo_keisei-5.1.0
- old
+ new
@@ -2,12 +2,10 @@
A collection of utilities wrapping the libraries for dealing with AWS Cloud Formation.
## Installation
-This gem is automatically installed in the rbdevtools container, so any `apply-env` or `deploy` scripts have access to it.
-
Add this line to your application's Gemfile:
```ruby
gem 'kumo_keisei'
```
@@ -22,11 +20,11 @@
## Usage
### Basic Usage
-The basic usage will give you a CloudFormation stack named `{application}-{environment}`. The default type is `nodes`
+The basic usage will give you a CloudFormation stack named `{application}-{environment}`.
```ruby
application_name = "myapp"
environment_name = "production"
my_stack = KumoKeisei::Stack.new(application_name, environment_name)
@@ -39,16 +37,12 @@
my_stack.apply! stack_config
```
### Stack Naming
-We are using APPNAME-ENVNAME (e.g `redbubble-staging`) as our naming convention. There are some legacy stacks in AWS which have the old naming convention which is APPNAME-TYPE-ENVNAME (e.g `redbubble-nodes-staging`). If you want to ensure that you keep your existing stack (so you don't accidently build an extra stack):
+We are using APPNAME-ENVNAME (e.g `redbubble-staging`) as our naming convention for cloudformation stacks.
-0. Login into the AWS console and find out what your stack is named.
-0. Update your app name (see Basic Usage above) in the apply-env script to match your existing stack name's app name part (which is everything before the environment name, e.g `redbubble-nodes` in `redbubble-nodes-staging`)
-
-
### Timeouts
You can tune each of the timeouts by passing options to the Stack constructor:
```ruby
stack_options = {
@@ -94,96 +88,34 @@
}
}
stack.apply!(stack_config)
```
-### Getting the configuration and secrets without an `apply!`
-
-If you need to inspect the configuration without applying a stack, call `config`:
-```ruby
-stack_config = {
- config_path: File.join('/app', 'env', 'config'),
- template_path: File.join('/app', 'env', 'cloudformation', 'myapp.json'),
- injected_config: {
- 'Seed' => random_seed,
- }
-}
-marshalled_config = stack.config(stack_config)
-marshalled_secrets = stack.plain_text_secrets(stack_config)
-
-if marshalled_config['DB_HOST'].start_with? '192.' then
- passwd = marshalled_secrets['DB_PASS']
- ...
-end
-```
-
## Upgrading from `KumoKeisei::CloudFormationStack` to `KumoKeisei::Stack`
-`KumoKeisei::CloudFormationStack` is deprecated and should be replaced with a `KumoKeisei::Stack` which encompasses an environment object (`KumoConfig::EnvironmentConfig`).
+`KumoKeisei::CloudFormationStack` is deprecated and should be replaced with a `KumoKeisei::Stack` which has an environment object (`KumoConfig::EnvironmentConfig`).
-Previously you would have to construct your own `EnvironmentConfig` which would marshal its configuration, then instantiate a `CloudFormationStack` and conduct operations on it.
+Previously you would pass through cloudformation template and json parameter files directly.
-E.g. `apply-env`:
+E.g.:
```ruby
-require_relative '../env/cloudformation_stack'
-
-environment_name = ARGV.fetch(0) rescue raise("Error! No environment name given!")
-
-stack = CloudFormationStack.new(environment_name)
-stack.apply
+ app_name = "foo"
+ environment_name = "staging"
+ stack = KumoKeisei::CloudFormationStack.new("#{app_name}-#{environment_name}", "./cloudformation/#{app_name}.json", "./cloudformation/#{environment_name}.json")
+ stack.apply!
```
-and `cloudformation_stack.rb`:
-```ruby
-require 'kumo_keisei'
-class CloudFormationStack
-
- APP_NAME = "fooapp"
-
- attr_reader :env_name
-
- def initialize(env_name)
- @stacks = {}
- @env_name = env_name
- end
-
- def env_vars
- {}
- end
-
- def apply
- # Inject the VPC and Subnets into the application's environment config
- foo_config = KumoKeisei::EnvironmentConfig.new(
- env_name: env_name,
- config_dir_path: File.expand_path(File.join("..", "..", "env", "config"), __FILE__)
- )
-
- foo_stack = create_stack(:foo, foo_config)
- foo_stack.apply!
- end
- ...
- def create_stack(stack_name, environment_config)
- raise "Stack '#{ stack_name }' already exists!" if @stacks[stack_name]
- params_template_erb = params_template(stack_name)
- stack_values = cf_params_json(get_stack_params(params_template_erb, environment_config))
- write_stack_params_file(stack_values, stack_name)
- @stacks[stack_name] = KumoKeisei::CloudFormationStack.new(stack_names[stack_name], "./env/cloudformation/#{stack_name}.json", stack_file_params_file_path(stack_name))
- end
- ...
-```
-
-With the new `Stack` object, all you need to do is pass in the location of the template and config as in the above section. New `apply-env`:
+With the new `Stack` object, you need to pass in the location of the template and config:
```ruby
-require 'kumo_keisei'
+app_name = "foo"
+environment_name = "staging"
-environment_name = ARGV.fetch(0) rescue raise("Error! No environment name given!")
-
stack_config = {
config_path: File.join('/app', 'env', 'config'),
- template_path: File.join('/app', 'env', 'cloudformation', 'fooapp.json'),
+ template_path: File.join('/app', 'env', 'cloudformation', '#{app_name}.json'),
}
-stack = KumoKeisei::Stack.new('fooapp', environment_name)
+stack = KumoKeisei::Stack.new(app_name, environment_name)
stack.apply!(stack_config)
```