Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const uploadCodeToCos = async (instance, appId, credentials, inputs, region) => {
const bucketName = inputs.code.bucket || `sls-cloudfunction-${region}-code`
const objectName = inputs.code.object || `${inputs.name}-${Math.floor(Date.now() / 1000)}.zip`
// if set bucket and object not pack code
if (!inputs.code.bucket || !inputs.code.object) {
const zipPath = await getCodeZipPath(instance, inputs)
console.log(`Code zip path ${zipPath}`)
// save the zip path to state for lambda to use it
instance.state.zipPath = zipPath
const cos = new Cos(credentials, region)
if (!inputs.code.bucket) {
// create default bucket
await cos.deploy({
bucket: bucketName + '-' + appId,
force: true,
lifecycle: [
{
status: 'Enabled',
id: 'deleteObject',
filter: '',
expiration: { days: '10' },
abortIncompleteMultipartUpload: { daysAfterInitiation: '10' }
}
]
})