@rlyle1179/serverless-aws-batch 1.0.36 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/generateCoreTemplate.js +25 -23
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ const path = require('path');
|
|
|
7
7
|
const _ = require('lodash');
|
|
8
8
|
var util = require('util');
|
|
9
9
|
|
|
10
|
-
const lifeCyclePolicies =
|
|
10
|
+
const lifeCyclePolicies = {
|
|
11
11
|
"rules": [
|
|
12
12
|
{
|
|
13
13
|
"rulePriority": 1,
|
|
@@ -23,50 +23,52 @@ const lifeCyclePolicies = JSON.stringify({
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
]
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Adds the ECR repository to the "create" template so that we have a repository we can upload our docker image to
|
|
30
30
|
* during deployment.
|
|
31
31
|
*/
|
|
32
32
|
function generateCoreTemplate() {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// Setup our ECR Repository to delete untagged images after 1 day
|
|
34
|
+
const ecrTemplate = `
|
|
35
35
|
{
|
|
36
36
|
"Type" : "AWS::ECR::Repository",
|
|
37
37
|
"Properties" : {
|
|
38
38
|
"LifecyclePolicy" : {
|
|
39
|
-
"LifecyclePolicyText" :
|
|
39
|
+
"LifecyclePolicyText" : ${JSON.stringify(JSON.stringify(lifeCyclePolicies))}
|
|
40
40
|
},
|
|
41
41
|
"RepositoryName" : "${this.provider.naming.getECRRepositoryName()}"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
`;
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
[this.provider.naming.getECRLogicalId()]: JSON.parse(ecrTemplate)
|
|
48
|
-
};
|
|
46
|
+
console.log("ecrTemplate:", ecrTemplate );
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
newECRObject
|
|
54
|
-
);
|
|
48
|
+
const newECRObject = {
|
|
49
|
+
[this.provider.naming.getECRLogicalId()]: JSON.parse(ecrTemplate)
|
|
50
|
+
};
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
// Add it to our initial compiled cloud formation templates
|
|
53
|
+
_.merge(
|
|
54
|
+
this.serverless.service.provider.compiledCloudFormationTemplate.Resources,
|
|
55
|
+
newECRObject
|
|
56
|
+
);
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
coreTemplateFileName);
|
|
58
|
+
// Then write it back out to the file
|
|
59
|
+
const coreTemplateFileName = this.provider.naming.getCoreTemplateFileName();
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
const coreTemplateFilePath = path.join(this.serverless.config.servicePath,
|
|
62
|
+
'.serverless',
|
|
63
|
+
coreTemplateFileName);
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
this.serverless.utils.writeFileSync(coreTemplateFilePath,
|
|
66
|
+
this.serverless.service.provider.compiledCloudFormationTemplate);
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
this.serverless.service.provider.coreCloudFormationTemplate =
|
|
69
|
+
_.cloneDeep(this.serverless.service.provider.compiledCloudFormationTemplate);
|
|
70
|
+
|
|
71
|
+
return BbPromise.resolve();
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
module.exports = { generateCoreTemplate };
|