-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: seven <[email protected]>
- Loading branch information
Showing
11 changed files
with
110 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { deployStack } from '../stack'; | ||
import { printer } from '../common'; | ||
import { parseYaml } from '../iac'; | ||
|
||
export const deploy = (location?: string) => { | ||
printer.info('Validating yaml...'); | ||
const iac = parseYaml(location); | ||
printer.success('Yaml is valid! 🎉'); | ||
|
||
printer.info('Deploying stack...'); | ||
deployStack(iac); | ||
printer.success('Stack deployed! 🎉'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,7 @@ | ||
import { parseYaml } from '../iac'; | ||
import path from 'node:path'; | ||
import { printer } from '../common'; | ||
|
||
export const validate = (location?: string) => { | ||
const projectRoot = path.resolve(process.cwd()); | ||
const yamlPath = location | ||
? path.resolve(projectRoot, location) | ||
: path.resolve(projectRoot, 'serverless-insight.yml'); | ||
|
||
parseYaml(yamlPath); | ||
parseYaml(location); | ||
printer.success('Yaml is valid! 🎉'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// import * as ros from '@alicloud/ros-cdk-core'; | ||
// import * as fc from '@alicloud/ros-cdk-fc'; | ||
// | ||
// export class IacStack extends ros.Stack { | ||
// constructor(scope: ros.Construct, id: string, props?: ros.StackProps) { | ||
// super(scope, id, props); | ||
// new ros.RosInfo(this, ros.RosInfo.description, 'This is the simple ros cdk app example.'); | ||
// | ||
// const functionCompute = new fc.RosFunction( | ||
// this, | ||
// 'MyFunction', | ||
// { | ||
// functionName: 'my-function', | ||
// serviceName: service.attrServiceName, | ||
// handler: 'index.handler', | ||
// runtime: 'nodejs14', | ||
// code: { | ||
// zipFile: | ||
// 'exports.handler = function(event, context, callback) { callback(null, "Hello World"); }', | ||
// }, | ||
// }, | ||
// false, | ||
// ); | ||
// console.log(functionCompute); | ||
// } | ||
// } | ||
// | ||
// export const defineResource = (name: string, type: string, properties: Record<string, any>) => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as ros from '@alicloud/ros-cdk-core'; | ||
import * as fc from '@alicloud/ros-cdk-fc'; | ||
import { ServerlessIac } from '../types'; | ||
|
||
export class IacStack extends ros.Stack { | ||
constructor(scope: ros.Construct, iac: ServerlessIac, props?: ros.StackProps) { | ||
super(scope, iac.service, props); | ||
new ros.RosInfo(this, ros.RosInfo.description, 'This is the simple ros cdk app example.'); | ||
iac.functions.map( | ||
(fnc) => | ||
new fc.RosFunction( | ||
this, | ||
fnc.name, | ||
{ | ||
functionName: fnc.name, | ||
serviceName: `${fnc.name}-service`, | ||
handler: fnc.handler, | ||
runtime: fnc.runtime, | ||
memorySize: fnc.memory, | ||
timeout: fnc.timeout, | ||
environmentVariables: fnc.environment, | ||
code: { | ||
zipFile: | ||
'exports.handler = function(event, context, callback) { callback(null, "Hello World"); }', | ||
}, | ||
}, | ||
false, | ||
), | ||
); | ||
} | ||
} | ||
|
||
export const deployStack = (iac: ServerlessIac) => { | ||
console.log(`Deploying stack... ${JSON.stringify(iac)}`); | ||
const app = new ros.App(); | ||
new IacStack(app, iac); | ||
app.synth(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { deployStack } from './deploy'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters