Skip to content

Commit

Permalink
chore: bump dependencies and the lambda environment
Browse files Browse the repository at this point in the history
  • Loading branch information
HQarroum committed Jul 19, 2024
1 parent dedfb02 commit 2049013
Show file tree
Hide file tree
Showing 8 changed files with 1,359 additions and 971 deletions.
2 changes: 1 addition & 1 deletion cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Resources:
Handler: index.handler
Role: !GetAtt EvaluationRole.Arn
Code: ./lambda/
Runtime: nodejs14.x
Runtime: nodejs20.x
Timeout: !Ref Timeout
MemorySize: !Ref MemorySize
Environment:
Expand Down
2 changes: 1 addition & 1 deletion examples/aws-sdk/cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Resources:
# The outputs to be generated by this template.
Outputs:
AsyncOutput:
Value: !GetAtt AsyncResource.data
Value: !GetAtt AsyncResource.data
2 changes: 1 addition & 1 deletion examples/hashes/cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Outputs:
Description: The generated SHA-1 hash for `bar`.
Value: !Sub ${HashTransformFunction.BarSha1}
Export:
Name: !Sub ${AWS::StackName}-BarSha1
Name: !Sub ${AWS::StackName}-BarSha1
2 changes: 1 addition & 1 deletion examples/to-json/cloudformation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Outputs:
Description: The generated JSON string by the evaluation function.
Value: !Sub ${JsonTransformResource.string}
Export:
Name: !Sub ${AWS::StackName}-JsonString
Name: !Sub ${AWS::StackName}-JsonString
25 changes: 3 additions & 22 deletions lambda/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Joi = require('joi');
const vm = require('./vm');
const request = require('request-promise');
const vm = require('./vm');
const request = require('request-promise');

/**
* Cloudformation result codes.
Expand All @@ -10,17 +9,6 @@ const Result = {
FAILURE: 'FAILED'
};

/**
* The schema of a Cloudformation request event.
*/
const schema = Joi.object().keys({
RequestType: Joi.string().valid('Create', 'Update', 'Delete').required(),
LogicalResourceId: Joi.string().required(),
ResourceProperties: Joi.object().keys({
Code: Joi.string().required()
}).unknown().required()
}).unknown().required();

/**
* @return a constructed and valid body response for Cloudformation.
* @param {*} ev the received event.
Expand Down Expand Up @@ -64,16 +52,9 @@ const sendResponse = function (event) {
/**
* Lambda function entry point.
* @param {*} event the lambda function input `event`.
* @param {*} event the lambda function `context` object.
* @param {*} context the lambda function `context` object.
*/
exports.handler = async (event, context) => {
const result = schema.validate(event);

// Validating the `event` object and its attributes.
if (result.error) {
return (sendResponse(event, context, Result.FAILED, { error: result.error }));
}

try {
if (event.RequestType === 'Create' || event.RequestType === 'Update') {
// Retrieving parameters declared on the custom resource.
Expand Down
Loading

0 comments on commit 2049013

Please sign in to comment.