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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fda3f7f377b0a4e9ee10986452ef45a2a29dc5fccc83cead2b72d3cf4905deb7
4
- data.tar.gz: 99ad6240a85bc7e2286e36295c0838dc6abd739acd6a23a047a5865fe54d9488
3
+ metadata.gz: 83de34bc40509c9a8425856cbc70eac67efb38eeb7441e6710fd2490abc70779
4
+ data.tar.gz: f8f01c6a27922524362b59aef01d05841d3247c46874caf8cfa2c944ee7441e9
5
5
  SHA512:
6
- metadata.gz: fa76e06abe1e03750ff2f6b4e9a95bfc7c39694a5670dbe417f7f7ffb516366a27bbc8ed0f6eeae0e92d7e1dae323205c428c3646a90cb009ab541f309478cb1
7
- data.tar.gz: b4f1ff39ff403c951bee540644035189f908b9a1c65a398576b87f388fc24c7c96a4c4d3e270608f639b1e80206911ede557e9184c1274d1e3570004402430ac
6
+ metadata.gz: 7082ea8b1a3f7b3a23406898614fd08c5af073889c13b1101a5b2580e9025881443f91ce5ceb81141508a06bf943ec3c1c4ed9ab754c51a56fd324fc6c659106
7
+ data.tar.gz: c735c3327552fbfea5417ab18442dc2829a7fc05d94a4687af942a8f70ba2e0e5b94d7da66f2b27ebdac278d430da54b606b328706ae215c6cc114b33d0122e1
data/CHANGELOG.md CHANGED
@@ -2,7 +2,28 @@
2
2
  All notable changes to Rubycfn will be documented in this file.
3
3
  This project uses [Semantic Versioning](http://semver.org/).
4
4
 
5
- ## 0.4.11 (Next Release)
5
+ ## 0.5.4 (Next Release)
6
+
7
+ ## 0.5.3
8
+
9
+ * Improved code quality in templated files -- [@dennisvink][@dennisvink]
10
+
11
+ ## 0.5.2
12
+
13
+ * Fixed bug in lib/core/dependencies.rb that incorrectly raised error -- [@dennisvink][@dennisvink]
14
+
15
+ ## 0.5.1
16
+
17
+ * Added descriptive error messages for common errors -- [@dennisvink][@dennisvink]
18
+ * Allow `rake compile` to succeed with mock .env.dependency.rspec values -- [@dennisvink][@dennisvink]
19
+ * Added `rake update` command -- [@dennisvink][@dennisvink]
20
+ * Removed a stray unused variable in template code -- [@dennisvink][@dennisvink]
21
+ * Update README.md -- [@dennisvink][@dennisvink]
22
+
23
+ ## 0.5.0
24
+
25
+ * Restructuring project -- [@dennisvink][@dennisvink]
26
+ * Disabled scaffolding -- [@dennisvink][@dennisvink]
6
27
 
7
28
  ## 0.4.10
8
29
 
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubycfn (0.4.10)
4
+ rubycfn (0.5.3)
5
5
  activesupport (~> 5.1.5)
6
6
  dotenv (~> 2.4.0)
7
- json (~> 2.1.0)
7
+ json (~> 2.3.0)
8
8
  neatjson (~> 0.8.4)
9
9
  tty-prompt (~> 0.16.0)
10
10
 
@@ -16,20 +16,20 @@ GEM
16
16
  i18n (>= 0.7, < 2)
17
17
  minitest (~> 5.1)
18
18
  tzinfo (~> 1.1)
19
- addressable (2.7.0)
19
+ addressable (2.8.0)
20
20
  public_suffix (>= 2.0.2, < 5.0)
21
- awesome_print (1.8.0)
22
- coderay (1.1.2)
23
- concurrent-ruby (1.1.6)
24
- diff-lcs (1.3)
25
- docile (1.3.2)
21
+ awesome_print (1.9.2)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.9)
24
+ diff-lcs (1.4.4)
25
+ docile (1.4.0)
26
26
  dotenv (2.4.0)
27
- equatable (0.6.1)
28
- ffi (1.12.2)
29
- formatador (0.2.5)
30
- given_core (3.8.0)
27
+ equatable (0.7.0)
28
+ ffi (1.15.3)
29
+ formatador (0.3.0)
30
+ given_core (3.8.2)
31
31
  sorcerer (>= 0.3.7)
32
- guard (2.16.1)
32
+ guard (2.17.0)
33
33
  formatador (>= 0.2.4)
34
34
  listen (>= 2.7, < 4.0)
35
35
  lumberjack (>= 1.0.12, < 2.0)
@@ -43,65 +43,67 @@ GEM
43
43
  guard (~> 2.1)
44
44
  guard-compat (~> 1.1)
45
45
  rspec (>= 2.99.0, < 4.0)
46
- i18n (1.8.2)
46
+ i18n (1.8.10)
47
47
  concurrent-ruby (~> 1.0)
48
- json (2.1.0)
48
+ json (2.3.1)
49
49
  launchy (2.5.0)
50
50
  addressable (~> 2.7)
51
- listen (3.2.1)
51
+ listen (3.5.1)
52
52
  rb-fsevent (~> 0.10, >= 0.10.3)
53
53
  rb-inotify (~> 0.9, >= 0.9.10)
54
- lumberjack (1.2.4)
55
- method_source (0.9.2)
56
- minitest (5.14.0)
54
+ lumberjack (1.2.8)
55
+ method_source (1.0.0)
56
+ minitest (5.14.4)
57
57
  neatjson (0.8.4)
58
58
  necromancer (0.4.0)
59
59
  nenv (0.3.0)
60
60
  notiffany (0.1.3)
61
61
  nenv (~> 0.1)
62
62
  shellany (~> 0.0)
63
- pastel (0.7.3)
63
+ pastel (0.7.4)
64
64
  equatable (~> 0.6)
65
65
  tty-color (~> 0.5)
66
- pry (0.12.2)
67
- coderay (~> 1.1.0)
68
- method_source (~> 0.9.0)
69
- public_suffix (4.0.3)
70
- rake (13.0.1)
71
- rb-fsevent (0.10.3)
66
+ pry (0.14.1)
67
+ coderay (~> 1.1)
68
+ method_source (~> 1.0)
69
+ public_suffix (4.0.6)
70
+ rake (13.0.4)
71
+ rb-fsevent (0.11.0)
72
72
  rb-inotify (0.10.1)
73
73
  ffi (~> 1.0)
74
- rspec (3.9.0)
75
- rspec-core (~> 3.9.0)
76
- rspec-expectations (~> 3.9.0)
77
- rspec-mocks (~> 3.9.0)
78
- rspec-core (3.9.1)
79
- rspec-support (~> 3.9.1)
80
- rspec-expectations (3.9.0)
74
+ rspec (3.10.0)
75
+ rspec-core (~> 3.10.0)
76
+ rspec-expectations (~> 3.10.0)
77
+ rspec-mocks (~> 3.10.0)
78
+ rspec-core (3.10.1)
79
+ rspec-support (~> 3.10.0)
80
+ rspec-expectations (3.10.1)
81
81
  diff-lcs (>= 1.2.0, < 2.0)
82
- rspec-support (~> 3.9.0)
83
- rspec-given (3.8.0)
84
- given_core (= 3.8.0)
82
+ rspec-support (~> 3.10.0)
83
+ rspec-given (3.8.2)
84
+ given_core (= 3.8.2)
85
85
  rspec (>= 2.14.0)
86
86
  rspec-its (1.3.0)
87
87
  rspec-core (>= 3.0.0)
88
88
  rspec-expectations (>= 3.0.0)
89
- rspec-mocks (3.9.1)
89
+ rspec-mocks (3.10.2)
90
90
  diff-lcs (>= 1.2.0, < 2.0)
91
- rspec-support (~> 3.9.0)
92
- rspec-support (3.9.2)
91
+ rspec-support (~> 3.10.0)
92
+ rspec-support (3.10.2)
93
93
  rspec_junit_formatter (0.4.1)
94
94
  rspec-core (>= 2, < 4, != 2.12.0)
95
95
  shellany (0.0.1)
96
- simplecov (0.18.5)
96
+ simplecov (0.21.2)
97
97
  docile (~> 1.1)
98
98
  simplecov-html (~> 0.11)
99
- simplecov-html (0.12.2)
99
+ simplecov_json_formatter (~> 0.1)
100
+ simplecov-html (0.12.3)
101
+ simplecov_json_formatter (0.1.3)
100
102
  sorcerer (2.0.1)
101
- thor (1.0.1)
103
+ thor (1.1.0)
102
104
  thread_safe (0.3.6)
103
- timers (4.3.0)
104
- tty-color (0.5.1)
105
+ timers (4.3.3)
106
+ tty-color (0.6.0)
105
107
  tty-cursor (0.5.0)
106
108
  tty-prompt (0.16.1)
107
109
  necromancer (~> 0.4.0)
@@ -114,7 +116,7 @@ GEM
114
116
  tty-screen (~> 0.6.4)
115
117
  wisper (~> 2.0.0)
116
118
  tty-screen (0.6.5)
117
- tzinfo (1.2.6)
119
+ tzinfo (1.2.9)
118
120
  thread_safe (~> 0.1)
119
121
  wisper (2.0.1)
120
122
 
@@ -137,4 +139,4 @@ DEPENDENCIES
137
139
  simplecov (~> 0.9)
138
140
 
139
141
  BUNDLED WITH
140
- 2.1.4
142
+ 2.2.22
data/README.md CHANGED
@@ -61,7 +61,7 @@ __________ ____ __________________.___._________ _____________________
61
61
  | _/ | /| | _// | |/ \ \/ | __) | | _/
62
62
  | | \ | / | | \\____ |\ \____| \ | | \
63
63
  |____|_ /______/ |______ // ______| \______ /\___ / |______ /
64
- \/ \/ \/ \/ \/ \/ [v0.4.10]
64
+ \/ \/ \/ \/ \/ \/ [v0.5.3]
65
65
  Project name? example
66
66
  Account ID? 1234567890
67
67
  Select region EU (Frankfurt)
@@ -75,6 +75,9 @@ Installing project dependencies:
75
75
  Updating project dependencies:
76
76
  `bundle update`
77
77
 
78
+ Deploying dependency stack to AWS:
79
+ `rake init`
80
+
78
81
  Compiling Rubycfn project:
79
82
  `rake compile`
80
83
 
@@ -87,9 +90,6 @@ Running tests and compiling:
87
90
  Uploading built stacks to s3:
88
91
  `rake upload`
89
92
 
90
- Checking difference between local and remote stack:
91
- `rake diff`
92
-
93
93
  Deploying stack to AWS:
94
94
  `rake apply`
95
95
 
@@ -98,21 +98,23 @@ Deploying stack to AWS:
98
98
  A new Rubycfn project has the following structure:
99
99
 
100
100
  ```
101
- total 112
102
- drwxr-xr-x 14 dennis staff 448 Jul 15 20:43 .
103
- drwxr-xr-x 17 dennis staff 544 Jul 15 20:43 ..
104
- -rw-r--r-- 1 dennis staff 92 Jul 15 20:43 .env
105
- -rw-r--r-- 1 dennis staff 325 Jul 15 20:43 .env.production
106
- -rw-r--r-- 1 dennis staff 207 Jul 15 20:43 .env.rspec
107
- -rw-r--r-- 1 dennis staff 298 Jul 15 20:43 .env.test
108
- drwxr-xr-x 10 dennis staff 320 Jul 15 20:43 .git
109
- -rw-r--r-- 1 dennis staff 1344 Jul 15 20:43 .rubocop.yml
110
- -rw-r--r-- 1 dennis staff 502 Jul 15 20:43 Gemfile
111
- -rw-r--r-- 1 dennis staff 27158 Jul 15 20:43 Gemfile.lock
112
- -rw-r--r-- 1 dennis staff 998 Jul 15 20:43 Rakefile
113
- drwxr-xr-x 2 dennis staff 64 Jul 15 20:43 build
114
- drwxr-xr-x 7 dennis staff 224 Jul 15 20:43 lib
115
- drwxr-xr-x 4 dennis staff 128 Jul 15 20:43 spec
101
+ drwxr-xr-x 3 dennis staff 96 Mar 4 02:43 bootstrap
102
+ drwxr-xr-x 7 dennis staff 224 Mar 4 02:43 lib
103
+ drwxr-xr-x 4 dennis staff 128 Mar 4 02:43 spec
104
+ -rw-r--r-- 1 dennis staff 49 Mar 4 02:43 .env
105
+ -rw-r--r-- 1 dennis staff 31 Mar 4 02:43 .env.acceptance
106
+ -rw-r--r-- 1 dennis staff 279 Mar 4 02:43 .env.dependencies.rspec
107
+ -rw-r--r-- 1 dennis staff 32 Mar 4 02:43 .env.development
108
+ -rw-r--r-- 1 dennis staff 31 Mar 4 02:43 .env.production
109
+ -rw-r--r-- 1 dennis staff 33 Mar 4 02:43 .env.rspec
110
+ -rw-r--r-- 1 dennis staff 25 Mar 4 02:43 .env.test
111
+ -rw-r--r-- 1 dennis staff 1110 Mar 4 02:43 .gitignore
112
+ -rw-r--r-- 1 dennis staff 1524 Mar 4 02:43 .rubocop.yml
113
+ -rw-r--r-- 1 dennis staff 477 Mar 4 02:43 Gemfile
114
+ -rw-r--r-- 1 dennis staff 31603 Mar 4 02:43 Gemfile.lock
115
+ -rw-r--r-- 1 dennis staff 292 Mar 4 02:43 README.md
116
+ -rw-r--r-- 1 dennis staff 1267 Mar 4 02:43 Rakefile
117
+ -rw-r--r-- 1 dennis staff 1337 Mar 4 02:43 config.yaml
116
118
  ```
117
119
 
118
120
  Lets first discuss the files in the root folder.
@@ -134,15 +136,13 @@ The `.env` file contains environment variables that are available, regardless of
134
136
  the environment you're building for. For example:
135
137
 
136
138
  ```
137
- AWS_ACCOUNT_ID="1234567890"
138
139
  AWS_REGION="eu-west-1"
139
- ENVIRONMENT="rspec"
140
- PROJECT_NAME="sample"
140
+ ENVIRONMENT="development"
141
141
  ```
142
142
 
143
143
  #### .env.production and .env.test
144
144
 
145
- The `.env.production` and `.env.test` files contain environment variables that
145
+ The `.env.production` and `.env.x` files contain environment variables that
146
146
  are specific to production or test respectively. For example `.env.test` can
147
147
  contain something like this:
148
148
 
@@ -150,20 +150,6 @@ contain something like this:
150
150
  # ENV vars for test environment
151
151
  CLOUD_TRAIL_MONITOR_SNS_RECIPIENTS="changeme@example.com,changemetoo@example.com"
152
152
  ROOT_MONITOR_SNS_RECIPIENTS="changeme@example.com,changemetoo@example.com"
153
- VPC_CIDR_BLOCK="10.100.0.0/16"
154
- ARTIFACT_BUCKET="my-awesome-cloudformation-artifact-bucket"
155
- STACK_NAME="test"
156
- ```
157
-
158
- While .env.production can look something like this:
159
-
160
- ```
161
- # ENV vars for production environment
162
- CLOUD_TRAIL_MONITOR_SNS_RECIPIENTS="changeme@example.com,changemetoo@example.com"
163
- ROOT_MONITOR_SNS_RECIPIENTS="changeme@example.com,changemetoo@example.com"
164
- VPC_CIDR_BLOCK="10.200.0.0/16"
165
- ARTIFACT_BUCKET="my-awesome-cloudformation-artifact-bucket-for-production"
166
- STACK_NAME="production"
167
153
  ```
168
154
 
169
155
  You can reuse these environment variables in your project code.
@@ -173,12 +159,11 @@ You can reuse these environment variables in your project code.
173
159
  The `.env.rspec` is used when running unit tests. It contains mock variables
174
160
  so that you can test the resulting CloudFormation templates properly.
175
161
 
176
- #### The missing .env.private file
162
+ #### The .env.private file
177
163
 
178
- There is one file that is not generated by default but does need mentioning:
179
- the `.env.private` file. This is a special file that allows you to override
180
- environment variables. An environment variable set in .env.private always takes
181
- precedence over environment variables set in other .env* files.
164
+ This is a special file that allows you to override environment variables.
165
+ An environment variable set in .env.private always takes precedence over
166
+ environment variables set in other .env files.
182
167
 
183
168
  #### .rubocop.yml
184
169
 
@@ -188,12 +173,12 @@ violations.
188
173
 
189
174
  ### Rubycfn project directories
190
175
 
191
- As shown before, a Rubycfn project contains three directories:
176
+ As shown before, a Rubycfn project contains four directories:
192
177
 
193
178
  ```
194
- drwxr-xr-x 2 dennis staff 64 Jul 15 20:43 build
195
- drwxr-xr-x 7 dennis staff 224 Jul 15 20:43 lib
196
- drwxr-xr-x 4 dennis staff 128 Jul 15 20:43 spec
179
+ drwxr-xr-x 3 dennis staff 96 Mar 4 02:43 bootstrap
180
+ drwxr-xr-x 7 dennis staff 224 Mar 4 02:43 lib
181
+ drwxr-xr-x 4 dennis staff 128 Mar 4 02:43 spec
197
182
  ```
198
183
 
199
184
  #### build
@@ -247,39 +232,33 @@ that you want to reuse cross stacks, create a shared concern.
247
232
  The `stacks` folder, by default, contains the following:
248
233
 
249
234
  ```
250
- total 24
251
- drwxr-xr-x 8 dennis staff 256 Jul 15 20:43 .
252
- drwxr-xr-x 7 dennis staff 224 Jul 15 20:43 ..
253
- drwxr-xr-x 3 dennis staff 96 Jul 15 20:43 ecs_stack
254
- -rw-r--r-- 1 dennis staff 254 Jul 15 20:43 ecs_stack.rb
255
- drwxr-xr-x 3 dennis staff 96 Jul 15 20:43 parent_stack
256
- -rw-r--r-- 1 dennis staff 259 Jul 15 20:43 parent_stack.rb
257
- drwxr-xr-x 4 dennis staff 128 Jul 15 20:43 vpc_stack
258
- -rw-r--r-- 1 dennis staff 248 Jul 15 20:43 vpc_stack.rb
235
+ drwxr-xr-x 4 dennis staff 128 Mar 4 02:43 acm_stack
236
+ drwxr-xr-x 6 dennis staff 192 Mar 4 02:43 ecs_stack
237
+ drwxr-xr-x 4 dennis staff 128 Mar 4 02:43 parent_stack
238
+ drwxr-xr-x 4 dennis staff 128 Mar 4 02:43 vpc_stack
259
239
  ```
260
240
 
261
- The default project creates three CloudFormation templates: a VPC stack, an
262
- ECS stack and a parent stack. The parent stack is a CloudFormation stack that
263
- contains all other stacks. When you deploy a Rubycfn project these other stacks
264
- show up as `nested stacks`. The parent stack acts not only as a container for
241
+ The default project creates four CloudFormation templates: a VPC stack, an
242
+ ECS stack, an ACM stack and a parent stack. The parent stack is a CloudFormation
243
+ stack that contains all other stacks. When you deploy a Rubycfn project these other
244
+ stacks show up as `nested stacks`. The parent stack acts not only as a container for
265
245
  all other stacks, but is also responsible for passing outputs from stacks as
266
246
  parameters to another. For example: The VPC Id that is created in the VPC stack
267
247
  can easily be passed to the ECS stack as a parameter. This nested stack approach
268
248
  has an additional benefit: A change of output in stack X can trigger an update
269
249
  in stack Y.
270
250
 
271
- The .rb files you see in the lib/stacks/ directory are the parent stack files.
272
- Lets have a look at `vpc_stack.rb`:
251
+ The lib/stacks/vpc_stack/ directory contains a `main.rb` file and a `vpc.rb` file.
252
+ Lets have a look at the vpc_stack/main.rb file:
273
253
 
274
254
  ```ruby
275
255
  module VpcStack
276
256
  extend ActiveSupport::Concern
277
257
  include Rubycfn
278
-
279
258
  included do
280
259
  include Concerns::GlobalVariables
281
260
  include Concerns::SharedMethods
282
- include VpcStack::Main
261
+ include VpcStack::InfraVpc
283
262
 
284
263
  description generate_stack_description("VpcStack")
285
264
  end
@@ -291,14 +270,14 @@ name ends with 'Stack' to make the compiler magic work. The code between
291
270
  `include do` and `end` loads in two of the shared concerns, and includes the
292
271
  VpcStack::Main module. Finally the description of the stack is set.
293
272
 
294
- The `lib/stacks/vpc_stack/` directory contains a `vpc.rb` file, which is the
295
- implementation of the VpcStack::Main module:
273
+ The `lib/stacks/vpc_stack/vpc.rb` file contains the implementation of the
274
+ VpcStack::InfraVpc module:
296
275
 
297
276
  ```ruby
298
277
  require_relative "subnets"
299
278
 
300
279
  module VpcStack
301
- module Main
280
+ module InfraVpc
302
281
  extend ActiveSupport::Concern
303
282
 
304
283
  included do
@@ -310,13 +289,9 @@ end
310
289
 
311
290
  The first line is identical to the parent stack file and defines this module is
312
291
  part of `VpcStack`. The second line defines the name of the module, in this case
313
- `Main`. The code beteen `included do` and `end` is the implementation of this
292
+ `InfraVpc`. The code beteen `included do` and `end` is the implementation of this
314
293
  module.
315
294
 
316
- Adding a new stack is trivial: Go to the root folder of the project and type
317
- `rubycfn stack`. This will prompt you for a stack name (do not include the 'stack' keyword)
318
- and it will generate the stack for you.
319
-
320
295
  ## AWS Intrinsic functions
321
296
 
322
297
  You can Ref by postpending the .ref method to any string or hash, e.g. :foobar.ref
data/bin/rubycfn CHANGED
@@ -13,7 +13,7 @@ if ARGV.first || (ARGF.filename != "-" or (not STDIN.tty? and not STDIN.closed?)
13
13
  if ARGV.class == Array && ARGV.first == "stack"
14
14
  case ARGV.first
15
15
  when "stack"
16
- scaffold_stack
16
+ puts "Scaffolding will be reintroduced later."
17
17
  end
18
18
  else
19
19
  require "rubycfn"
@@ -61,85 +61,29 @@ region = prompt.select(
61
61
  )
62
62
 
63
63
  render_args = {
64
- project_name: project_name,
65
64
  account_id: account_id,
66
- region: region
65
+ project_name: project_name,
66
+ region: region,
67
+ version: Rubycfn::VERSION
67
68
  }
68
69
 
69
- dotenv = render(".env", render_args, path)
70
- aws_sdk = render("aws_sdk.rb", {}, path)
71
- compiler = render("compiler.rb", {}, path)
72
- core_deploy = render("core_deploy.rb", { name: project_name }, path)
73
- core_upload = render("core_upload.rb", {}, path)
74
- core_compile = render("core_compile.rb", {}, path)
75
- core_diff = render("core_diff.rb", {}, path)
76
- dependencies = render("dependencies.rb", {}, path)
77
- deploy = render("deploy.rb", {}, path)
78
- dotenv_test = render(".env.test", { name: project_name }, path)
79
- dotenv_production = render(".env.production", { name: project_name }, path)
80
- dotenv_rspec = render(".env.rspec", { name: project_name }, path)
81
- ecs_stack = render("ecs_stack.rb", {}, path)
82
- ecs_stack_concern = render("ecs_stack_concern.rb", { name: project_name }, path)
83
- gemfile = render("Gemfile", { version: Rubycfn::VERSION }, path)
84
- gitignore = render(".gitignore", {}, path)
85
- global_variables = render("global_variables.rb", { name: project_name.downcase }, path)
86
- helpers = render("helpers.rb", {}, path)
87
- helper_methods = render("helper_methods.rb", {}, path)
88
- main = render("main.rb", {}, path)
89
- main_aws_helper = render("main_aws_helper.rb", {}, path)
90
- parent_spec = render("parent_stack_spec.rb", { name: project_name.capitalize }, path)
91
- project_concern = render("project_concern.rb", { name: project_name.capitalize }, path)
92
- project_stack = render("project_stack.rb", { name: project_name.capitalize }, path)
93
- rakefile = render("Rakefile", {}, path)
94
- rubocop = render(".rubocop.yml", {}, path)
95
- shared_methods = render("shared_methods.rb", {}, path)
96
- spec_helper = render("spec_helper.rb", {}, path)
97
- subnets = render("subnets.rb", { name: project_name }, path)
98
- upload_stack = render("upload_stack.rb", {}, path)
99
- vpc_stack = render("vpc_stack.rb", { name: project_name }, path)
100
- vpc_concern = render("vpc_concerns.rb", { name: project_name }, path)
101
- vpc_spec = render("vpc_spec.rb", { name: project_name.capitalize }, path)
70
+ FileUtils.mkdir_p project_path
102
71
 
103
- # Create directory structure
104
- rubycfn_structure(project_path).each do |dir|
105
- FileUtils.mkdir_p dir
72
+ Dir.glob("#{path}/templates/**/*", File::FNM_DOTMATCH).each do |f|
73
+ if File.directory?(f)
74
+ dir = f.gsub("#{path}/templates/","")
75
+ FileUtils.mkdir_p "#{project_path}/#{dir}"
76
+ end
106
77
  end
107
78
 
108
- File.open("#{project_path}/lib/aws_helper/aws_sdk.rb", "w") { |file| file.write(aws_sdk) }
109
- File.open("#{project_path}/lib/aws_helper/compiler.rb", "w") { |file| file.write(compiler) }
110
- File.open("#{project_path}/lib/aws_helper/dependencies.rb", "w") { |file| file.write(dependencies) }
111
- File.open("#{project_path}/lib/aws_helper/deploy.rb", "w") { |file| file.write(deploy) }
112
- File.open("#{project_path}/lib/core/deploy.rb", "w") { |file| file.write(core_deploy) }
113
- File.open("#{project_path}/lib/core/compile.rb", "w") { |file| file.write(core_compile) }
114
- File.open("#{project_path}/lib/core/diff.rb", "w") { |file| file.write(core_diff) }
115
- File.open("#{project_path}/lib/core/upload.rb", "w") { |file| file.write(core_upload) }
116
- File.open("#{project_path}/.env", "w") { |file| file.write(dotenv) }
117
- File.open("#{project_path}/.env.test", "w") { |file| file.write(dotenv_test) }
118
- File.open("#{project_path}/.env.production", "w") { |file| file.write(dotenv_production) }
119
- File.open("#{project_path}/.env.rspec", "w") { |file| file.write(dotenv_rspec) }
120
- File.open("#{project_path}/lib/stacks/ecs_stack.rb", "w") { |file| file.write(ecs_stack) }
121
- File.open("#{project_path}/lib/stacks/ecs_stack/ecs_cluster.rb", "w") { |file| file.write(ecs_stack_concern) }
122
- File.open("#{project_path}/Gemfile", "w") { |file| file.write(gemfile) }
123
- File.open("#{project_path}/.gitignore", "w") { |file| file.write(gitignore) }
124
- File.open("#{project_path}/lib/shared_concerns/global_variables.rb", "w") { |file| file.write(global_variables) }
125
- File.open("#{project_path}/lib/aws_helper/helpers.rb", "w") { |file| file.write(helpers) }
126
- File.open("#{project_path}/lib/shared_concerns/helper_methods.rb", "w") { |file| file.write(helper_methods) }
127
- File.open("#{project_path}/lib/main.rb", "w") { |file| file.write(main) }
128
- File.open("#{project_path}/lib/aws_helper/main.rb", "w") { |file| file.write(main_aws_helper) }
129
- File.open("#{project_path}/spec/lib/parent_spec.rb", "w") { |file| file.write(parent_spec) }
130
- File.open("#{project_path}/lib/stacks/parent_stack.rb", "w") { |file| file.write(project_stack) }
131
- File.open("#{project_path}/lib/stacks/parent_stack/parent.rb", "w") { |file| file.write(project_concern) }
132
- File.open("#{project_path}/Rakefile", "w") { |file| file.write(rakefile) }
133
- File.open("#{project_path}/.rubocop.yml", "w") { |file| file.write(rubocop) }
134
- File.open("#{project_path}/lib/shared_concerns/shared_methods.rb", "w") { |file| file.write(shared_methods) }
135
- File.open("#{project_path}/spec/spec_helper.rb", "w") { |file| file.write(spec_helper) }
136
- File.open("#{project_path}/lib/stacks/vpc_stack/subnets.rb", "w") { |file| file.write(subnets) }
137
- File.open("#{project_path}/lib/aws_helper/upload_stack.rb", "w") { |file| file.write(upload_stack) }
138
- File.open("#{project_path}/spec/lib/vpc_spec.rb", "w") { |file| file.write(vpc_spec) }
139
- File.open("#{project_path}/lib/stacks/vpc_stack.rb", "w") { |file| file.write(vpc_stack) }
140
- File.open("#{project_path}/lib/stacks/vpc_stack/vpc.rb", "w") { |file| file.write(vpc_concern) }
79
+ Dir.glob("#{path}/templates/**/*", File::FNM_DOTMATCH).each do |f|
80
+ unless File.directory?(f)
81
+ file = f.gsub("#{path}/templates/","")
82
+ contents = render(f, render_args)
83
+ File.open("#{project_path}/#{file}", "w") { |file| file.write(contents) }
84
+ end
85
+ end
141
86
 
142
87
  puts "Setting up Rubycfn #{project_name} project..."
143
88
  `cd #{project_name}-rubycfn && git init && bundle`
144
- `bundle`
145
89
  puts "Done!"