in provider-utils/awscloudformation/utils/video-staging.js [267:357]
function handleEJS(props, src, dest, targetDir) {
/*
Special case for selecting the template. Don't want to polute the props
var with a massive template. Template name will be stored and will pull
info from `${targetDir}/video/${props.shared.resourceName}/mediaconvert-job-temp.json`
*/
if (src.includes('CreateJobTemplate.template.ejs')) {
const ejsFormated = fs.readFileSync(src, { encoding: 'utf-8' });
const jobTemplate = JSON.parse(fs.readFileSync(`${targetDir}/video/${props.shared.resourceName}/mediaconvert-job-temp.json`));
jobTemplate.SettingsJson = jobTemplate.Settings;
jobTemplate.Name = {
'Fn::If': [
'HasEnvironmentParameter',
{
'Fn::Join': [
'-',
[
jobTemplate.Name,
{
Ref: 'pProjectName',
},
{
Ref: 'env',
},
],
],
},
{
Ref: 'pProjectName',
},
],
};
delete jobTemplate.Settings;
const template = {
AWSTemplateFormatVersion: '2010-09-09',
Description: 'Auto generated by Amplify Video',
Parameters: {
env: {
Type: 'String',
Description: 'The environment name. e.g. Dev, Test, or Production.',
Default: 'NONE',
},
pProjectName: {
Type: 'String',
Description: 'Project name for the template',
Default: 'VodTemplate',
},
},
Resources: {
JobTemplate: {
Type: 'AWS::MediaConvert::JobTemplate',
Properties: jobTemplate,
},
},
Conditions: {
HasEnvironmentParameter: {
'Fn::Not': [
{
'Fn::Equals': [
{
Ref: 'env',
},
'NONE',
],
},
],
},
},
Outputs: {
oJobArn: {
Value: {
'Fn::GetAtt':
['JobTemplate', 'Arn'],
},
Description: 'Job Arn',
},
},
};
const templateProps = { yamlTemplate: YAML.stringify(template) };
const ejsOutput = ejs.render(ejsFormated, { templateProps });
const newDest = dest.replace('.ejs', '');
fs.writeFileSync(newDest, ejsOutput);
return false;
}
const ejsFormated = fs.readFileSync(src, { encoding: 'utf-8' });
const ejsOutput = ejs.render(ejsFormated, { props });
const newDest = dest.replace('.ejs', '');
fs.writeFileSync(newDest, ejsOutput);
return false;
}