serverless-sam
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -26,2 +26,4 @@ /* | ||
this.outputs = null; | ||
this.conditions = null; | ||
this.parameters = null; | ||
} | ||
@@ -87,2 +89,26 @@ | ||
addParameter(logicalId, obj){ | ||
if (!this.parameters) { | ||
this.parameters = {}; | ||
} | ||
if (this.parameters[logicalId]){ | ||
throw new Error("Parameter " + logicalId + " is already defined"); | ||
} | ||
this.parameters[logicalId] = obj; | ||
} | ||
addCondition(logicalId, obj) { | ||
if (!this.conditions) { | ||
this.conditions = {}; | ||
} | ||
if(this.outputs[logicalId]){ | ||
throw new Error("Condition " + logicalId + " is already defined"); | ||
} | ||
this.conditions[logicalId] = obj; | ||
} | ||
getResources(skipNulls) { | ||
@@ -110,2 +136,10 @@ return JSON.parse(JSON.stringify(this.resources, function(key, value) { | ||
if (this.parameters) { | ||
templateObject["Parameters"] = this.parameters; | ||
} | ||
if (this.conditions) { | ||
templateObject["Conditions"] = this.conditions; | ||
} | ||
return templateObject; | ||
@@ -112,0 +146,0 @@ } |
@@ -51,6 +51,12 @@ /* | ||
// 3. read functions | ||
// 3. read parameters if any | ||
this.readParameters(this.serverless.service); | ||
// 4. read conditions if any | ||
this.readConditions(this.serverless.service); | ||
// 5. read functions | ||
this.readFunctions(this.serverless.service); | ||
// 4. create yaml | ||
// 6. create yaml | ||
return this.dumpYamlTemplate(); | ||
@@ -83,2 +89,19 @@ } | ||
readConditions(service){ | ||
this.serverless.cli.log("Exporting conditions"); | ||
if (service.resources && service.resources.Conditions) { | ||
Object.keys(service.resources.Conditions).forEach((id,idx) => { | ||
this.samBuilder.addCondition(id, service.resources.Conditions[id]); | ||
}); | ||
} | ||
} | ||
readParameters(service){ | ||
this.serverless.cli.log("Exporting parameters"); | ||
if (service.resources && service.resources.Parameters) { | ||
Object.keys(service.resources.Parameters).forEach((id,idx) => { | ||
this.samBuilder.addParameter(id, service.resources.Parameters[id]); | ||
}); | ||
} | ||
} | ||
readFunctions(service) { | ||
@@ -85,0 +108,0 @@ this.serverless.cli.log("Exporting functions"); |
{ | ||
"name": "serverless-sam", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Serverless framework plugin to export AWS SAM templates for a service", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
75506
1555