Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(funcInstance.ufs) || resolve(this.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(funcInstance.ufs) || resolve(this.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
...resolve(funcInstance.environment)
},
code,
tags: {
...resolve(this.tags),
...resolve(funcInstance.tags)
}
}
if (ufs) {
code = [code, getShimFile(runtime)]
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(this.ufs) || resolve(funcInstance.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
...resolve(funcInstance.environment)
},
async construct(inputs, context) {
await super.construct(inputs, context)
this.buildCmd = inputs.buildCmd
this.env = inputs.env
this.projectDir = resolve(inputs.projectDir)
this.assets = resolve(inputs.assets) || resolve(inputs.projectDir)
// TODO BRN: Move this to a validate step (maybe on a per property basis that validates when set)
if (!path.isAbsolute(this.projectDir)) {
throw new Error('projectDir must be an absolute path. Construct local paths using ${path}.')
}
this.envFileLocation = path.resolve(this.projectDir, resolve(inputs.envFileLocation))
this.assets = path.resolve(this.projectDir, resolve(inputs.assets))
}
(accum, value, key) => {
value = resolve(value)
if (isSerializable(value)) {
if (isSymbol(key)) {
const symbolString = getSymbolString(context, key)
if (symbolString) {
if (isSerializableReferenceable(value)) {
return set(['symbols', symbolString], toReference(context, value), accum)
}
return set(['symbols', symbolString], serializeValue(context, value), accum)
}
// context.log(`unhandled symbol detected ${toString(key)}`)
} else {
if (isSerializableReferenceable(value)) {
return set(['props', key], toReference(context, value), accum)
}
return set(['props', key], serializeValue(context, value), accum)
}
async defineFunction(functionInstance, context) {
const funcInstance = resolve(functionInstance)
// need to resolve these two variables now to convert values
const ufs = resolve(this.ufs) || resolve(funcInstance.ufs) || false
const runtime = convertRuntime(resolve(funcInstance.runtime) || resolve(this.runtime))
let code = resolve(funcInstance.code)
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
...resolve(funcInstance.environment)
},
code,
tags: {
...resolve(this.tags),
...resolve(funcInstance.tags)
}
}
if (ufs) {
code = [code, getShimFile(runtime)]
inputs.code = code
(accum, childKey) => {
const instanceId = resolve(get('instanceId', children[childKey]))
if (isNil(instanceId)) {
throw new Error(
`Found a child without an instanceId while getting children ids. This should not happen. The child was ${
children[childKey]
} and belongs to parent ${component}`
)
}
return append(instanceId, accum)
},
[],
const inputs = {
provider: this.provider,
role: this.role,
functionName: funcInstance.functionName,
functionDescription: funcInstance.functionDescription,
memorySize: resolve(funcInstance.memory) || resolve(this.memory),
timeout: resolve(funcInstance.timeout) || resolve(this.timeout),
runtime,
handler: resolve(funcInstance.handler),
environment: {
...resolve(this.environment),
...resolve(funcInstance.environment)
},
code,
tags: {
...resolve(this.tags),
...resolve(funcInstance.tags)
}
}
if (ufs) {
code = [code, getShimFile(runtime)]
inputs.code = code
inputs.handler = 'shim.handler'
inputs.environment.SERVERLESS_HANDLER = functionInstance.handler
}
return context.construct(AwsLambdaFunction, inputs)
},
async defineSchedule(functionInstance, rate, context) {
async sync() {
let { provider } = this
provider = resolve(provider)
const AWS = provider.getSdk()
const S3 = new AWS.S3()
try {
await S3.getBucketLocation({ Bucket: resolve(this.bucketName) }).promise()
} catch (e) {
if (e.code === 'NoSuchBucket') {
return 'removed'
}
throw e
}
}