cfndk 0.1.1.2 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +1 -1
  3. data/.gitignore +1 -0
  4. data/.rspec +2 -0
  5. data/Gemfile.lock +9 -5
  6. data/README.md +124 -10
  7. data/cfndk.gemspec +3 -0
  8. data/docker/Dockerfile +8 -0
  9. data/docker/build.sh +3 -0
  10. data/docker/cfndk.sh +14 -0
  11. data/lib/cfndk.rb +9 -0
  12. data/lib/cfndk/change_set_command.rb +14 -8
  13. data/lib/cfndk/command.rb +14 -6
  14. data/lib/cfndk/credential_provider_chain.rb +12 -42
  15. data/lib/cfndk/credential_resolvable.rb +10 -0
  16. data/lib/cfndk/diff.rb +38 -0
  17. data/lib/cfndk/global_config.rb +32 -2
  18. data/lib/cfndk/key_pair.rb +33 -1
  19. data/lib/cfndk/key_pair_command.rb +10 -3
  20. data/lib/cfndk/key_pairs.rb +12 -0
  21. data/lib/cfndk/stack.rb +58 -59
  22. data/lib/cfndk/stack_command.rb +26 -8
  23. data/lib/cfndk/stacks.rb +16 -0
  24. data/lib/cfndk/template_packager.rb +210 -0
  25. data/lib/cfndk/uuid.rb +10 -0
  26. data/lib/cfndk/version.rb +1 -1
  27. data/spec/cfndk_spec.rb +1 -1
  28. data/spec/cfndk_stack_create_spec.rb +365 -5
  29. data/spec/cfndk_stack_destroy_spec.rb +64 -0
  30. data/spec/cfndk_stack_update_spec.rb +86 -0
  31. data/spec/fixtures/big_vpc.yaml +533 -0
  32. data/spec/fixtures/lambda_function/index.js +4 -0
  33. data/spec/fixtures/lambda_function/lambda_function.json +4 -0
  34. data/spec/fixtures/lambda_function/lambda_function.yaml +28 -0
  35. data/spec/fixtures/nested_stack.json +35 -0
  36. data/spec/fixtures/nested_stack.yaml +20 -0
  37. data/spec/fixtures/serverless_function/index.js +4 -0
  38. data/spec/fixtures/serverless_function/serverless_function.json +4 -0
  39. data/spec/fixtures/serverless_function/serverless_function.yaml +21 -0
  40. data/spec/fixtures/stack.json +8 -0
  41. data/spec/fixtures/stack.template.json +39 -0
  42. data/spec/fixtures/stack.yaml +22 -0
  43. data/spec/fixtures/vpc.template.json +40 -0
  44. data/vagrant/Vagrantfile +89 -0
  45. metadata +80 -4
@@ -0,0 +1,4 @@
1
+
2
+ exports.handler = function(event, context) {
3
+ console.log('test');
4
+ };
@@ -0,0 +1,4 @@
1
+ {
2
+ "Parameters": [
3
+ ]
4
+ }
@@ -0,0 +1,28 @@
1
+ AWSTemplateFormatVersion: '2010-09-09'
2
+ Description: Lambda function Stack
3
+ Resources:
4
+ LambdaRole:
5
+ Type: AWS::IAM::Role
6
+ Properties:
7
+ AssumeRolePolicyDocument:
8
+ Statement:
9
+ -
10
+ Effect: "Allow"
11
+ Principal:
12
+ Service:
13
+ - "lambda.amazonaws.com"
14
+ Action:
15
+ - "sts:AssumeRole"
16
+ Path: "/"
17
+ ManagedPolicyArns:
18
+ - arn:aws:iam::aws:policy/PowerUserAccess
19
+ LambdaFunction:
20
+ Type: AWS::Lambda::Function
21
+ Properties:
22
+ Code: ./lambda_function
23
+ Handler: index.handler
24
+ Role:
25
+ Fn::GetAtt:
26
+ - LambdaRole
27
+ - Arn
28
+ Runtime: "nodejs12.x"
@@ -0,0 +1,35 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Stack2",
4
+ "Parameters": {
5
+ "VpcId": {
6
+ "Type": "String"
7
+ }
8
+ },
9
+ "Resources": {
10
+ "TestSg": {
11
+ "Type": "AWS::EC2::SecurityGroup",
12
+ "Properties": {
13
+ "GroupDescription": "Web ELB Acccess Security Group",
14
+ "VpcId": {
15
+ "Ref": "VpcId"
16
+ },
17
+ "SecurityGroupIngress": [
18
+ {
19
+ "IpProtocol": "tcp",
20
+ "FromPort": 80,
21
+ "ToPort": 80,
22
+ "CidrIp": "0.0.0.0/0",
23
+ "Description": "Allow HTTP Access From Internet"
24
+ }
25
+ ],
26
+ "Tags": [
27
+ {
28
+ "Key": "Name",
29
+ "Value": "TestSg"
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,20 @@
1
+ AWSTemplateFormatVersion: '2010-09-09'
2
+ Description: Stack2
3
+ Parameters:
4
+ VpcId:
5
+ Type: String
6
+ Resources:
7
+ TestSg:
8
+ Type: AWS::EC2::SecurityGroup
9
+ Properties:
10
+ GroupDescription: Web ELB Acccess Security Group
11
+ VpcId: !Ref VpcId
12
+ SecurityGroupIngress:
13
+ - IpProtocol: tcp
14
+ FromPort: 80
15
+ ToPort: 80
16
+ CidrIp: 0.0.0.0/0
17
+ Description: Allow HTTP Access From Internet
18
+ Tags:
19
+ - Key: Name
20
+ Value: TestSg
@@ -0,0 +1,4 @@
1
+
2
+ exports.handler = function(event, context) {
3
+ console.log('test');
4
+ };
@@ -0,0 +1,4 @@
1
+ {
2
+ "Parameters": [
3
+ ]
4
+ }
@@ -0,0 +1,21 @@
1
+
2
+
3
+ AWSTemplateFormatVersion: '2010-09-09'
4
+ Transform: AWS::Serverless-2016-10-31
5
+ Resources:
6
+ ServerlessFunction:
7
+ Type: AWS::Serverless::Function
8
+ Properties:
9
+ FunctionName: serverless-func
10
+ CodeUri: ./serverless_function
11
+ Handler: index.handler
12
+ Runtime: "nodejs12.x"
13
+ AutoPublishAlias: live
14
+ Timeout: 10
15
+ MemorySize: 128
16
+
17
+ ServerlessFunctionLogGroup:
18
+ Type: AWS::Logs::LogGroup
19
+ Properties:
20
+ LogGroupName: !Sub /aws/lambda/${ServerlessFunction}
21
+ RetentionInDays: 14
@@ -0,0 +1,8 @@
1
+ {
2
+ "Parameters": [
3
+ {
4
+ "ParameterKey": "VpcName",
5
+ "ParameterValue": "sample"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,39 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Stack1",
4
+ "Parameters": {
5
+ "VpcName": {
6
+ "Description": "Name for this VPC",
7
+ "Type": "String"
8
+ }
9
+ },
10
+ "Resources": {
11
+ "Vpc": {
12
+ "Type": "AWS::EC2::VPC",
13
+ "Properties": {
14
+ "CidrBlock": "192.168.0.0/24",
15
+ "EnableDnsHostnames": true,
16
+ "Tags": [
17
+ {
18
+ "Key": "Name",
19
+ "Value": {
20
+ "Fn::Sub": "${VpcName}-VPC"
21
+ }
22
+ }
23
+ ]
24
+ }
25
+ },
26
+ "SgStack": {
27
+ "Type": "AWS::CloudFormation::Stack",
28
+ "Properties": {
29
+ "Parameters": {
30
+ "VpcId": {
31
+ "Ref": "Vpc"
32
+ }
33
+ },
34
+ "TemplateURL": "./nested_stack.json",
35
+ "TimeoutInMinutes": 2
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,22 @@
1
+ AWSTemplateFormatVersion: '2010-09-09'
2
+ Description: Stack1
3
+ Parameters:
4
+ VpcName:
5
+ Description: Name for this VPC
6
+ Type: String
7
+ Resources:
8
+ Vpc:
9
+ Type: AWS::EC2::VPC
10
+ Properties:
11
+ CidrBlock: 192.168.0.0/24
12
+ EnableDnsHostnames: true
13
+ Tags:
14
+ - Key: Name
15
+ Value: !Sub ${VpcName}-VPC
16
+ SgStack:
17
+ Type: AWS::CloudFormation::Stack
18
+ Properties:
19
+ Parameters:
20
+ VpcId: !Ref Vpc
21
+ TemplateURL: ./nested_stack.yaml
22
+ TimeoutInMinutes: 2
@@ -0,0 +1,40 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Stack1",
4
+ "Parameters": {
5
+ "VpcName": {
6
+ "Description": "Name for this VPC",
7
+ "Type": "String"
8
+ }
9
+ },
10
+ "Resources": {
11
+ "Vpc": {
12
+ "Type": "AWS::EC2::VPC",
13
+ "Properties": {
14
+ "CidrBlock": "192.168.0.0/24",
15
+ "EnableDnsHostnames": true,
16
+ "Tags": [
17
+ {
18
+ "Key": "Name",
19
+ "Value": {
20
+ "Fn::Sub": "${VpcName}-VPC"
21
+ }
22
+ }
23
+ ]
24
+ }
25
+ }
26
+ },
27
+ "Outputs": {
28
+ "VpcId": {
29
+ "Description": "VPC ID",
30
+ "Value": {
31
+ "Ref": "Vpc"
32
+ },
33
+ "Export": {
34
+ "Name": {
35
+ "Fn::Sub": "${VpcName}-VpcId"
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,89 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # All Vagrant configuration is done below. The "2" in Vagrant.configure
5
+ # configures the configuration version (we support older styles for
6
+ # backwards compatibility). Please don't change it unless you know what
7
+ # you're doing.
8
+ Vagrant.configure('2') do |config|
9
+ # vagrant plugin install vagrant-vbgues
10
+ config.vbguest.auto_update = true
11
+ config.vbguest.no_remote = true
12
+
13
+ # Every Vagrant development environment requires a box. You can search for
14
+ # boxes at https://vagrantcloud.com/search.
15
+ config.vm.box = 'centos/7'
16
+
17
+ # Disable automatic box update checking. If you disable this, then
18
+ # boxes will only be checked for updates when the user runs
19
+ # `vagrant box outdated`. This is not recommended.
20
+ # config.vm.box_check_update = false
21
+
22
+ # Create a forwarded port mapping which allows access to a specific port
23
+ # within the machine from a port on the host machine. In the example below,
24
+ # accessing "localhost:8080" will access port 80 on the guest machine.
25
+ # NOTE: This will enable public access to the opened port
26
+ # config.vm.network "forwarded_port", guest: 80, host: 8081
27
+
28
+ # Create a forwarded port mapping which allows access to a specific port
29
+ # within the machine from a port on the host machine and only allow access
30
+ # via 127.0.0.1 to disable public access
31
+ # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
32
+
33
+ # Create a private network, which allows host-only access to the machine
34
+ # using a specific IP.
35
+ # config.vm.network "private_network", ip: "192.168.33.10"
36
+
37
+ # Create a public network, which generally matched to bridged network.
38
+ # Bridged networks make the machine appear as another physical device on
39
+ # your network.
40
+ # config.vm.network "public_network"
41
+
42
+ # Share an additional folder to the guest VM. The first argument is
43
+ # the path on the host to the actual folder. The second argument is
44
+ # the path on the guest to mount the folder. And the optional third
45
+ # argument is a set of non-required options.
46
+ # config.vm.synced_folder "../data", "/vagrant_data"
47
+ config.vm.synced_folder "~/.aws", "/home/vagrant/.aws"
48
+
49
+ config.vm.provider 'virtualbox' do |vb|
50
+ vb.memory = '1024'
51
+ vb.cpus = 2
52
+ vb.customize [
53
+ 'modifyvm', :id,
54
+ #'--vtxvpid', :on,
55
+ #'--hwvirtex', :on,
56
+ '--nestedpaging', :on,
57
+ '--largepages', :on,
58
+ '--ioapic', :on,
59
+ '--pae', :on,
60
+ '--paravirtprovider', :kvm
61
+ ]
62
+ end
63
+
64
+ #
65
+ # View the documentation for the provider you are using for more
66
+ # information on available options.
67
+
68
+ # Enable provisioning with a shell script. Additional provisioners such as
69
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
70
+ # documentation for more information about their specific syntax and use.
71
+ # config.vm.provision "shell", inline: <<-SHELL
72
+ # apt-get update
73
+ # apt-get install -y apache2
74
+ # SHELL
75
+
76
+ config.vm.provision "shell", inline: <<-SHELL
77
+ yum clean all
78
+ yum update -y
79
+ yum -y install epel-release centos-release-scl-rh
80
+ yum -y install jq git
81
+ yum -y --enablerepo=centos-sclo-rh install rh-ruby26
82
+ ln -s /opt/rh/rh-ruby26/enable /etc/profile.d/rh-ruby26.sh
83
+ source /etc/profile.d/rh-ruby26.sh
84
+ curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
85
+ python get-pip.py
86
+ pip install awscli
87
+ gem install cfndk -V
88
+ SHELL
89
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfndk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.2
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshihisa AMAKATA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-15 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubyzip
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.3.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.3.0
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: aws-sdk
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +192,34 @@ dependencies:
178
192
  - - ">="
179
193
  - !ruby/object:Gem::Version
180
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: diff-lcs
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: polyfill
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
181
223
  description: cfndk is AWS Cloud Formation Development Kit
182
224
  email:
183
225
  - amakata@gmail.com
@@ -188,6 +230,7 @@ extra_rdoc_files: []
188
230
  files:
189
231
  - ".circleci/config.yml"
190
232
  - ".gitignore"
233
+ - ".rspec"
191
234
  - ".rspec_parallel"
192
235
  - ".rubocop.yml"
193
236
  - ".simplecov"
@@ -198,11 +241,16 @@ files:
198
241
  - Rakefile
199
242
  - bin/cfndk
200
243
  - cfndk.gemspec
244
+ - docker/Dockerfile
245
+ - docker/build.sh
246
+ - docker/cfndk.sh
201
247
  - lib/cfndk.rb
202
248
  - lib/cfndk/change_set_command.rb
203
249
  - lib/cfndk/command.rb
204
250
  - lib/cfndk/config_file_loadable.rb
205
251
  - lib/cfndk/credential_provider_chain.rb
252
+ - lib/cfndk/credential_resolvable.rb
253
+ - lib/cfndk/diff.rb
206
254
  - lib/cfndk/erb_string.rb
207
255
  - lib/cfndk/global_config.rb
208
256
  - lib/cfndk/key_pair.rb
@@ -213,6 +261,8 @@ files:
213
261
  - lib/cfndk/stack_command.rb
214
262
  - lib/cfndk/stacks.rb
215
263
  - lib/cfndk/subcommand_help_returnable.rb
264
+ - lib/cfndk/template_packager.rb
265
+ - lib/cfndk/uuid.rb
216
266
  - lib/cfndk/version.rb
217
267
  - skel/cfndk.yml
218
268
  - skel/db/db.yaml
@@ -246,19 +296,33 @@ files:
246
296
  - spec/cfndk_stack_report_spec.rb
247
297
  - spec/cfndk_stack_spec.rb
248
298
  - spec/cfndk_stack_update_spec.rb
299
+ - spec/fixtures/big_vpc.yaml
249
300
  - spec/fixtures/empty_resource.yaml
250
301
  - spec/fixtures/iam.json
251
302
  - spec/fixtures/iam.yaml
252
303
  - spec/fixtures/iam_different.json
253
304
  - spec/fixtures/invalid_vpc.yaml
305
+ - spec/fixtures/lambda_function/index.js
306
+ - spec/fixtures/lambda_function/lambda_function.json
307
+ - spec/fixtures/lambda_function/lambda_function.yaml
308
+ - spec/fixtures/nested_stack.json
309
+ - spec/fixtures/nested_stack.yaml
310
+ - spec/fixtures/serverless_function/index.js
311
+ - spec/fixtures/serverless_function/serverless_function.json
312
+ - spec/fixtures/serverless_function/serverless_function.yaml
254
313
  - spec/fixtures/sg.json
255
314
  - spec/fixtures/sg.yaml
256
315
  - spec/fixtures/sg_different.yaml
316
+ - spec/fixtures/stack.json
317
+ - spec/fixtures/stack.template.json
318
+ - spec/fixtures/stack.yaml
257
319
  - spec/fixtures/vpc.json
320
+ - spec/fixtures/vpc.template.json
258
321
  - spec/fixtures/vpc.yaml
259
322
  - spec/fixtures/vpc_different.yaml
260
323
  - spec/spec_helper.rb
261
324
  - spec/support/aruba.rb
325
+ - vagrant/Vagrantfile
262
326
  homepage: https://github.com/Amakata/cfndk
263
327
  licenses:
264
328
  - http://www.apache.org/licenses/license-2.0
@@ -278,8 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
342
  - !ruby/object:Gem::Version
279
343
  version: '0'
280
344
  requirements: []
281
- rubyforge_project:
282
- rubygems_version: 2.5.1
345
+ rubygems_version: 3.1.2
283
346
  signing_key:
284
347
  specification_version: 4
285
348
  summary: cfndk is AWS Cloud Formation Development Kit
@@ -300,15 +363,28 @@ test_files:
300
363
  - spec/cfndk_stack_report_spec.rb
301
364
  - spec/cfndk_stack_spec.rb
302
365
  - spec/cfndk_stack_update_spec.rb
366
+ - spec/fixtures/big_vpc.yaml
303
367
  - spec/fixtures/empty_resource.yaml
304
368
  - spec/fixtures/iam.json
305
369
  - spec/fixtures/iam.yaml
306
370
  - spec/fixtures/iam_different.json
307
371
  - spec/fixtures/invalid_vpc.yaml
372
+ - spec/fixtures/lambda_function/index.js
373
+ - spec/fixtures/lambda_function/lambda_function.json
374
+ - spec/fixtures/lambda_function/lambda_function.yaml
375
+ - spec/fixtures/nested_stack.json
376
+ - spec/fixtures/nested_stack.yaml
377
+ - spec/fixtures/serverless_function/index.js
378
+ - spec/fixtures/serverless_function/serverless_function.json
379
+ - spec/fixtures/serverless_function/serverless_function.yaml
308
380
  - spec/fixtures/sg.json
309
381
  - spec/fixtures/sg.yaml
310
382
  - spec/fixtures/sg_different.yaml
383
+ - spec/fixtures/stack.json
384
+ - spec/fixtures/stack.template.json
385
+ - spec/fixtures/stack.yaml
311
386
  - spec/fixtures/vpc.json
387
+ - spec/fixtures/vpc.template.json
312
388
  - spec/fixtures/vpc.yaml
313
389
  - spec/fixtures/vpc_different.yaml
314
390
  - spec/spec_helper.rb