Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CodeUri support #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ class SamPlugin {
required: true,
shortcut: 'o',
},
codeuri: {
usage:
'Specify CodeUri for package '
+ '(e.g. "--codeuri s3://deploy-bucket/function.zip")',
required: false,
shortcut: 'u',
default: null
},
},
}
}
Expand Down Expand Up @@ -203,7 +211,7 @@ class SamPlugin {
return new BbPromise((resolve, reject) => {
this.serverless.cli.log('Export:');
try {
this.samTemplate = this.samGenerator.generate();
this.samTemplate = this.samGenerator.generate(this.serverless.providers.aws.options.codeuri);
resolve(this.samTemplate);
} catch (err) {
reject(err);
Expand Down
4 changes: 2 additions & 2 deletions lib/FunctionConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class FunctionConverter {
this.samBuilder = samBuilder;
}

serverlessFunctionToSam(resourceName, serverlessFunction) {
serverlessFunctionToSam(resourceName, serverlessFunction, codeuri) {
let lambdaHandler = serverlessFunction.handler;
let codeUri = this.serverless.service.package.artifact;
let codeUri = codeuri || this.serverless.service.package.artifact;

// looks like this is not required. Commenting out for the time being
/*if (!codeUri) {
Expand Down
8 changes: 4 additions & 4 deletions lib/SamGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SamGenerator {
/**
* Main entry point for the object that returns the generated SAM template as a string.
*/
generate() {
generate(codeuri) {
// 1. read custom resources
this.readResources(this.serverless.service);

Expand All @@ -55,7 +55,7 @@ class SamGenerator {
this.readConditions(this.serverless.service);

// 5. read functions
this.readFunctions(this.serverless.service);
this.readFunctions(this.serverless.service, codeuri);

// 6. create yaml
return this.dumpYamlTemplate();
Expand Down Expand Up @@ -102,7 +102,7 @@ class SamGenerator {
});
}
}
readFunctions(service) {
readFunctions(service, codeuri) {
this.serverless.cli.log("Exporting functions");
let allFunctions = service.getAllFunctions();
if (allFunctions && allFunctions.length > 0) {
Expand All @@ -116,7 +116,7 @@ class SamGenerator {
this.serverless.cli.log('Exporting function: ' + functionName + ' as ' + functionResourceName);

// uses the SamBuilder object behind the scenes to add functions and new custom resources
this.functionConverter.serverlessFunctionToSam(functionResourceName, sFunction);
this.functionConverter.serverlessFunctionToSam(functionResourceName, sFunction, codeuri);
});
}
}
Expand Down