convection 0.2.16 → 0.2.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f32f84317e07800f0022642fd1eae90ad88df71d
4
- data.tar.gz: b2db570b8e3a24f2449c1c3c4b42f15f5e0aaf06
3
+ metadata.gz: 1526744195f5e97a7ee8c08588b4f5280a2d5842
4
+ data.tar.gz: 29eecb89170267324e2597cd3186747dd307fa78
5
5
  SHA512:
6
- metadata.gz: 8f699ed14a2c99f6c418a7f0e310b836443332c273d95ec6b0133b05b7ae85970a0ba0ae1b660b29ae931f41bb913d9d45eb766997d04062294b9fc5ee11e2e9
7
- data.tar.gz: 191c84293f1bdc3c39cf768613933b57dad072b354f0c83ff1034a2e0f6ee61e14da5ae2a559a325b6364bbd50de169e345c99659d2738707c61e8877d51faf5
6
+ metadata.gz: c227b72a4a70ca8f6428d154396e3b26490341c10f7f923a787d40a18c9b15515f1047395c30ddfd4c48fc58283329761a40d95564c8d360e208fb2d2ec29755
7
+ data.tar.gz: 32ad69eb4049ddecf9dfbf3ff4972f64ea7e10250c889fe93fd4b5178a752c8582286915b1473f920163f519107b721fc1f86544c3b98a0c780a7f7d981e1d51
@@ -0,0 +1,38 @@
1
+ require_relative '../resource'
2
+
3
+ module Convection
4
+ module Model
5
+ class Template
6
+ class Resource
7
+ ##
8
+ # AWS::Lambda::Function
9
+ ##
10
+ class Lambda < Resource
11
+ type 'AWS::Lambda::Function'
12
+ property :function_code, 'Code'
13
+ property :description, 'Description'
14
+ property :handler, 'Handler'
15
+ property :memory_size, 'MemorySize'
16
+ property :runtime, 'Runtime', :equal_to => ['nodejs', 'nodejs4.3', 'java8', 'python2.7']
17
+ property :timeout, 'Timeout'
18
+ property :role, 'Role'
19
+ property :vpc_cfg, 'VpcConfig'
20
+
21
+ # Add code block
22
+ def code(&block)
23
+ function_code = ResourceProperty::LambdaFunctionCode.new(self)
24
+ function_code.instance_exec(&block) if block
25
+ properties['Code'].set(function_code)
26
+ end
27
+
28
+ # Add vpc_config block
29
+ def vpc_config(&block)
30
+ vpc_cfg = ResourceProperty::LambdaVpcConfig.new(self)
31
+ vpc_cfg.instance_exec(&block) if block
32
+ properties['VpcConfig'].set(vpc_cfg)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '../resource_property'
2
+
3
+ module Convection
4
+ module Model
5
+ class Template
6
+ class ResourceProperty
7
+ # Represents an {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html}
8
+ class LambdaFunctionCode < ResourceProperty
9
+ property :s3_bucket, 'S3Bucket'
10
+ property :s3_key, 'S3Key'
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '../resource_property'
2
+
3
+ module Convection
4
+ module Model
5
+ class Template
6
+ class ResourceProperty
7
+ # Represents an {http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html}
8
+ class LambdaVpcConfig < ResourceProperty
9
+ property :security_groups, 'SecurityGroupIds', :type => :list
10
+ property :subnets, 'SubnetIds', :type => :list
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,53 @@
1
+ require 'test_helper'
2
+ require 'json'
3
+ require 'pp'
4
+
5
+ class TestLambdas < Minitest::Test
6
+ def setup
7
+ @template = ::Convection.template do
8
+ description 'Conditions Test Template'
9
+
10
+ lambda_function 'TestLambda' do
11
+ description 'Test description'
12
+ handler 'index.handler'
13
+ runtime 'nodejs'
14
+ role 'arn:aws:x:y:z'
15
+
16
+ code do
17
+ s3_bucket 'testbucket'
18
+ s3_key 'testkey'
19
+ end
20
+
21
+ vpc_config do
22
+ security_groups %w(group1 group2)
23
+ subnets %w(subnet1a subnet1b)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ def from_json
30
+ JSON.parse(@template.to_json)
31
+ end
32
+
33
+ def test_lambda
34
+ json = from_json['Resources']['TestLambda']['Properties']
35
+
36
+ code = json['Code']
37
+ assert_equal 'testbucket', code['S3Bucket']
38
+ assert_equal 'testkey', code['S3Key']
39
+
40
+ assert_equal 'arn:aws:x:y:z', json['Role']
41
+
42
+ vpc = json['VpcConfig']
43
+ refute vpc.nil?, 'VpcConfig not present in generated template'
44
+
45
+ secgroups = vpc['SecurityGroupIds']
46
+ assert secgroups.is_a?(Array), 'SecurityGroupIds is not an array'
47
+ assert_equal 2, secgroups.size
48
+
49
+ subnets = vpc['SubnetIds']
50
+ assert subnets.is_a?(Array), 'SubnetIds is not an array'
51
+ assert_equal 2, subnets.size
52
+ end
53
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Manero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-14 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -168,6 +168,7 @@ files:
168
168
  - lib/convection/model/template/resource/aws_iam_role.rb
169
169
  - lib/convection/model/template/resource/aws_iam_user.rb
170
170
  - lib/convection/model/template/resource/aws_kms_key.rb
171
+ - lib/convection/model/template/resource/aws_lambda_function.rb
171
172
  - lib/convection/model/template/resource/aws_logs_loggroup.rb
172
173
  - lib/convection/model/template/resource/aws_rds_db_instance.rb
173
174
  - lib/convection/model/template/resource/aws_rds_db_parameter_group.rb
@@ -198,9 +199,12 @@ files:
198
199
  - lib/convection/model/template/resource_property/aws_ec2_block_store_block_device.rb
199
200
  - lib/convection/model/template/resource_property/aws_ec2_mount_point.rb
200
201
  - lib/convection/model/template/resource_property/aws_ec2_network_interface.rb
202
+ - lib/convection/model/template/resource_property/aws_lambda_function_code.rb
203
+ - lib/convection/model/template/resource_property/aws_lambda_vpc_config.rb
201
204
  - lib/convection/version.rb
202
205
  - test/convection/model/test_conditions.rb
203
206
  - test/convection/model/test_elasticache.rb
207
+ - test/convection/model/test_lambdas.rb
204
208
  - test/convection/model/test_loggroups.rb
205
209
  - test/convection/model/test_rds.rb
206
210
  - test/convection/model/test_template.rb
@@ -233,6 +237,7 @@ summary: A fully generic, modular DSL for AWS CloudFormation
233
237
  test_files:
234
238
  - test/convection/model/test_conditions.rb
235
239
  - test/convection/model/test_elasticache.rb
240
+ - test/convection/model/test_lambdas.rb
236
241
  - test/convection/model/test_loggroups.rb
237
242
  - test/convection/model/test_rds.rb
238
243
  - test/convection/model/test_template.rb