in src/shared/cloudformation/cloudformation.ts [413:450]
export function validateResource(resource: Resource, template: Template): void {
if (!resource.Type) {
throw new Error('Missing or invalid value in Template for key: Type')
}
if (resource.Properties) {
if (resource.Properties.PackageType === LAMBDA_PACKAGE_TYPE_IMAGE) {
if (!validatePropertyType(resource.Metadata, 'Dockerfile', template, 'string')) {
throw new Error('Missing or invalid value in Template for key: Metadata.Dockerfile')
}
if (!validatePropertyType(resource.Metadata, 'DockerContext', template, 'string')) {
throw new Error('Missing or invalid value in Template for key: Metadata.DockerContext')
}
} else {
if (!validatePropertyType(resource.Properties, 'Handler', template, 'string')) {
throw new Error('Missing or invalid value in Template for key: Handler')
}
if (!resource.Properties.CodeUri) {
// Missing codeUri is allowed, (SAM pulls from the handler instead). Set as empty string.
resource.Properties.CodeUri = ''
} else if (!validatePropertyType(resource.Properties, 'CodeUri', template, 'string')) {
throw new Error('Invalid value in Template for key: CodeUri')
}
if (
!!resource.Properties.Runtime &&
!validatePropertyType(resource.Properties, 'Runtime', template, 'string')
) {
throw new Error('Invalid value in Template for key: Runtime')
}
}
if (
!!resource.Properties.Timeout &&
!validatePropertyType(resource.Properties, 'Timeout', template, 'number')
) {
throw new Error('Invalid value in Template for key: Timeout')
}
}
}