- Initialize your project using projen
npx projen new awscdk-construct --name intelli-agent
-
Add your construct implementation ts file (intell-agent-construct e.g.) inside src folder and corresponding lambda function code (e.g. lambda folder) in root folder
-
Import your custom construct in the main stack file (index.ts)
export * from './intelli-agent-construct';
- Adjust your test file (intell-agent.test.ts) inside test folder and run the test
npx projen test
PASS test/intelli-agent.test.ts
✓ Intelli Agent Construct (437 ms)
----------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------------------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
intelli-agent-construct.ts | 100 | 100 | 100 | 100 |
----------------------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.648 s, estimated 4 s
- Update the .projenrc.ts file to include the new Lambda asset and run npx projen to update the project configuration
npx projen
- Build your project
npx projen build && npm version patch
- Publish your project to npm, we don't use "npx progen release" for simplicity in skip some processes e.g. unused git diff and customized npm authentication
npm login
npm publish --access public
- Create a new CDK project
mkdir my-intelli-agent
cd my-intelli-agent
npx projen new awscdk-app-ts
- Add the new construct to your project
npm install @yike5460/intelli-agent
- Import the construct in your stack
import { AIAgent } from '@yike5460/intelli-agent';
- Use the construct in your stack
export class MyStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps = {}) {
super(scope, id, props);
// define resources here...
new AIAgent(this, 'IntelliAgentConstruct', {
agentName: 'my-intelli-agent',
runtime: lambda.Runtime.NODEJS_LATEST,
memorySize: 256,
});
}
}
- Build and deploy your project
npx projen build
npx cdk deploy