New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@swarmion/serverless-cdk-plugin

Package Overview
Dependencies
Maintainers
2
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swarmion/serverless-cdk-plugin - npm Package Compare versions

Comparing version 0.9.5 to 0.9.6

22

package.json
{
"name": "@swarmion/serverless-cdk-plugin",
"description": "Serverless plugin to use CDK constructs in serverless framework applications",
"version": "0.9.5",
"version": "0.9.6",
"license": "MIT",

@@ -43,4 +43,4 @@ "homepage": "https://www.swarmion.dev",

"@serverless/typescript": "^3.21.0",
"aws-cdk-lib": "^2.33.0",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"ts-toolbelt": "^9.6.0"
},

@@ -54,9 +54,10 @@ "devDependencies": {

"@serverless/test": "^11.0.1",
"@swarmion/configuration": "^0.9.5",
"@types/node": "^18.6.1",
"@swarmion/configuration": "^0.9.6",
"@types/node": "^18.6.3",
"@zerollup/ts-transform-paths": "^1.7.18",
"aws-cdk-lib": "^2.34.2",
"babel-plugin-module-resolver": "^4.1.0",
"concurrently": "^7.3.0",
"constructs": "^10.1.57",
"dependency-cruiser": "^11.13.0",
"constructs": "^10.1.62",
"dependency-cruiser": "^11.14.0",
"eslint": "^8.20.0",

@@ -68,3 +69,2 @@ "jest": "^27.5.1",

"ts-node": "^10.9.1",
"ts-toolbelt": "^9.6.0",
"ttypescript": "^1.5.13",

@@ -82,3 +82,7 @@ "typescript": "^4.7.4"

},
"gitHead": "663bf932ec92dd9541851ecd2377d003836e0f38"
"peerDependencies": {
"aws-cdk-lib": "^2.34.2",
"constructs": "^10.1.62"
},
"gitHead": "c6d214a2126f0f8f52446bcc61f7dbee5924e5c3"
}

@@ -35,11 +35,11 @@ # :sparkles: :rocket: Serverless CDK Bridge Plugin :rocket: :sparkles:

backend orchestrator > resources > dynamodb.ts
```ts
import type { ServerlessProps } from '@swarmion/serverless-cdk-plugin';
import ServerlessCdkPlugin from '@swarmion/serverless-cdk-plugin';
// ./resources/dynamodb.ts
import { PARTITION_KEY, SORT_KEY } from 'libs/dynamodb/primaryKeys';
import ServerlessCdkPlugin, {
ServerlessProps,
} from '@swarmion/serverless-cdk-plugin';
export class OrchestratorDynamodb extends ServerlessCdkPlugin.ServerlessConstruct {
export class MyConstruct extends ServerlessCdkPlugin.ServerlessConstruct {
public dynamodbArn: string;

@@ -51,5 +51,5 @@ public dynamodbName: string;

const table = new Table(this, 'OrchestratorTable', {
partitionKey: { name: PARTITION_KEY, type: AttributeType.STRING },
sortKey: { name: SORT_KEY, type: AttributeType.STRING },
const table = new Table(this, 'MyDynamoDbTable', {
partitionKey: { name: "PK", type: AttributeType.STRING },
sortKey: { name: "SK", type: AttributeType.STRING },
billingMode: BillingMode.PAY_PER_REQUEST,

@@ -64,50 +64,69 @@ });

export const getCdkProperty =
ServerlessCdkPlugin.getCdkPropertyHelper<OrchestratorDynamodb>;
ServerlessCdkPlugin.getCdkPropertyHelper<MyConstruct>;
```
Then, pass the construct to the `serverless.ts` file at the serverlessConstruct key:
Then, pass the construct to the serverless configuration in the `construct` key:
backend orchestrator > serverless.ts
```ts
// ./serverless.ts
```ts
const serverlessConfiguration: AWS &
ServerlessContracts &
ServerlessCdkPluginConfig = {
// Other properties ...
construct: OrchestratorDynamodb,
params: sharedParams,
import type { ServerlessCdkPluginConfig } from '@swarmion/serverless-cdk-plugin';
import { MyConstruct } from './resources/dynamodb'
const serverlessConfiguration: AWS & ServerlessCdkPluginConfig = {
// ...
plugins: [
'@swarmion/serverless-cdk-plugin',
],
construct: MyConstruct,
provider: {
...sharedProviderConfig,
// ...
},
// ...
};
module.exports = serverlessConfiguration;
```
And that's it! Constructs (e.g. dynamodb table) can now be referenced in the Serverless framework code seamlessly (e.g. within lambdas configuration files).
And that's it! Constructs (e.g. dynamodb table) can now be used with the Serverless framework code seamlessly !
Here is an example in a lambda configuration:
backend orchestrator > functions > requestSyncDeployment > config.ts
```ts
import { requestSyncDeployment } from '@swarmion/orchestrator-contracts';
import { getTrigger } from '@swarmion/serverless-contracts';
import { getHandlerPath, LambdaFunction } from '@swarmion/serverless-helpers';
// ./serverless.ts
import { getCdkProperty } from 'resources/dynamodb';
import type { ServerlessCdkPluginConfig } from '@swarmion/serverless-cdk-plugin';
const config: LambdaFunction = {
environment: {
ORCHESTRATOR_TABLE_NAME: getCdkProperty('dynamodbName'),
import { MyConstruct, getCdkProperty } from './resources/dynamodb'
const serverlessConfiguration: AWS & ServerlessCdkPluginConfig = {
// ...
provider: {
// ...
},
handler: getHandlerPath(__dirname),
iamRoleStatements: [
{
Effect: 'Allow',
Resource: getCdkProperty('dynamodbArn'),
Action: ['dynamodb:PutItem'],
plugins: [
'@swarmion/serverless-cdk-plugin',
'serverless-iam-roles-per-function',
],
functions: {
myLambda: {
environment: {
TABLE_NAME: getCdkProperty('dynamodbName'),
},
handler: 'functions/myHandler.main',
iamRoleStatements: [
{
Effect: 'Allow',
Resource: getCdkProperty('dynamodbArn'),
Action: ['dynamodb:PutItem'],
},
],
events: [ ... ],
},
],
iamRoleStatementsInherit: true,
events: [getTrigger(requestSyncDeployment)],
},
construct: MyConstruct,
// ...
};
export default config;
module.exports = serverlessConfiguration;
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc