Skip to content

Commit

Permalink
feat(aws-lambda:) add Ruby 2.5 runtime (#1267)
Browse files Browse the repository at this point in the history
Add an enum value for the Ruby runtime.
  • Loading branch information
phstc authored and rix0rrr committed Dec 5, 2018
1 parent 5ffa7e2 commit 3d40e13
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-lambda/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export enum RuntimeFamily {
Java,
Python,
DotNetCore,
Go
Go,
Ruby
}

/**
Expand All @@ -32,6 +33,7 @@ export class Runtime {
public static readonly DotNetCore2 = new Runtime('dotnetcore2.0', RuntimeFamily.DotNetCore);
public static readonly DotNetCore21 = new Runtime('dotnetcore2.1', RuntimeFamily.DotNetCore);
public static readonly Go1x = new Runtime('go1.x', RuntimeFamily.Go);
public static readonly Ruby25 = new Runtime('ruby2.5', RuntimeFamily.Ruby, { supportsInlineCode: true });

/**
* The name of this runtime, as expected by the Lambda resource.
Expand Down
34 changes: 34 additions & 0 deletions packages/@aws-cdk/aws-lambda/test/test.lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,40 @@ export = {
// THEN
test.same(bindTarget, fn);
test.done();
},
'support inline code for Ruby runtime'(test: Test) {
const stack = new cdk.Stack();

new lambda.Function(stack, 'MyLambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.Ruby25,
});

expect(stack).toMatch({ Resources:
{ MyLambdaServiceRole4539ECB6:
{ Type: 'AWS::IAM::Role',
Properties:
{ AssumeRolePolicyDocument:
{ Statement:
[ { Action: 'sts:AssumeRole',
Effect: 'Allow',
Principal: { Service: 'lambda.amazonaws.com' } } ],
Version: '2012-10-17' },
ManagedPolicyArns:
// arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
// tslint:disable-next-line:max-line-length
[{'Fn::Join': ['', ['arn:', {Ref: 'AWS::Partition'}, ':iam::aws:policy/service-role/AWSLambdaBasicExecutionRole']]}],
}},
MyLambdaCCE802FB:
{ Type: 'AWS::Lambda::Function',
Properties:
{ Code: { ZipFile: 'foo' },
Handler: 'index.handler',
Role: { 'Fn::GetAtt': [ 'MyLambdaServiceRole4539ECB6', 'Arn' ] },
Runtime: 'ruby2.5' },
DependsOn: [ 'MyLambdaServiceRole4539ECB6' ] } } });
test.done();
}
};

Expand Down

0 comments on commit 3d40e13

Please sign in to comment.