@ikonintegration/serverless-ikcomponents-plugin

1.2.4 • Public • Published

IKComponents Node.js Package

Overall

  • npm npm npm (tag) Libraries.io dependency status for latest release, scoped npm package
  • GitHub commit activity
  • GitHub last commit

installation:

in webpack.config.js

 const slsikcomponents = require('@ikonintegration/serverless-ikcomponents-plugin');
  // Important step for ikcomponents
  entry: {
    ...slsw.lib.entries,
    ...slsikcomponents.getWebpackEntries()
  },

serverless.yml

  • add the plugin into the list

  • install the module

  • write the component :)

  • plugin will output errors and not allow deployment if additional dependecies are required

    Now done automatically

Options

custom:
  cognito: true || .... (This will enable cognito principal to be added to IAM role)
  apigateway: true || ... (This will enable api gateway principal to be added to IAM role)
stepFunctions: true || .... (This will enable step functions principal to be added to IAM role)
....(your serverless.yml)
ikcomponents:
  tags: Array<{
    key: value
  }>;
  functions?: Array<{
    handler?: string;
    vpc?: OVPCOptions;
    elbListenerArn?: string;
    //Indicates if the cluster will not be created and an shared ECS cluster should be used instead
    ecsClusterArn?: string; //ecs shared cluster ARN
    ecsIngressSecGroupId?: string; //ecs shared cluster ingress vpc group
    timeout?: number; //Only works with lambda based
    memory?: number; //defaults to 1024
    newRelicKey?: string;//
    events?: Array<{
      eventType: 'process' | 'httpd' | 'lambda;
      handler?: string; //this, takes precende over function handler - Usefulll for multi-purpose clusters
      enabled?: boolean; //defaults to true
      <!-- Only available for process and httpd types -->
      runtime?: 'nodejs10' | 'nodejs13' | 'php5' | 'php7';
      concurrency?: number; //defaults to 1
      shouldUseEC2?: boolean; //defaults to false, if true will laucnh task into EC2
      cpu?: number; //defaults to 512
      memory?: number; //defaults to 1024 - takes precedence over OFunction.memory
      role?: string;
      hostname?: string | string[];
      limitSourceIPs?: string | string[];
      <!-- Only available for httpd type -->
      port?: number; // HTTPD port (the port exposed on the container image) - if not specified random port will be used - usefull for busy private subnets - If port is not specified, it will use 80 for non SSL and 443 for SSL
      certificateArns?: string[]; //certificateArn - if present it will use HTTPS
      priority?: number; //Router priority, usefull for leaving wildcard routes to be the last resort
      cognitoAuthorizer? {
          poolDomain: string;
          poolArn: string;
          clientId: string;
      }
      //AS
      autoScale?: {
          min?: number; //default to 1
          max?: number; //default to 1
          metric: string;
          cooldown?: number; //defaults to 30
          cooldownIn?: number; //defaults to cooldown but has priority over it
          cooldownOut?: number; //defaults to cooldown but has priority over it
          targetValue: number;
      }
      //health check
      healthCheckInterval?: number; //defaults to 15,
      healthCheckTimeout?: number; //defaults to 10
      healthCheckHealthyCount?: number; //defaults to 2
      healthCheckUnhealthyCount?: number; //defaults to 5
      <!-- httpd or lambda -->
      routes?: Array<{ //required if on lambda (http) or httpd -- if sqs or other stream type this is desconsidered
        path: string;
        method: string;
      }>;
      cors?: {
        origin: string;
        headers: string[];
        allowCredentials: boolean;
      }
      <!-- Lambda only -->
      layers?: string[];
      protocol?: 'http | 'dynamostreams' | 'sqs' | 'sqs | 'scheduler'; //defaults to HTTP 
      prototocolArn?: any; //Only used when protocol is dynamostreams or sqs
      queueBatchSize?: number; //Only used when protocol is sqs
      schedulerRate?: string; //Only used when protocol is scheduler
      schedulerInput?: string; //Only used when protocol is scheduler
      reservedConcurrency?: number;
      filterPolicy?: object; //Only used when protocol is sns
    }>;
  }>

Example

ikcomponents:
  tags:
    workload: Sample
  functions:
    Proc: #CLUSTER
      handler: src/queue/PROCESS.handler
      vpc: ${self:custom.esvpc}
      events:
        - eventType: process
          runtime: nodejs13
          # memory: 1024 -- default/min for long running
    Httpd: #CLUSTER
      handler: src/router.handler
      vpc: ${self:custom.esvpc}
      events:
        - eventType: httpd
          runtime: nodejs13
          routes:
            - method: ANY
              path: *
    MultiPurp: #CLUSTER
      vpc: ${self:custom.esvpc}
      events:
        - eventType: httpd
          runtime: nodejs13
          handler: src/router.handler
          routes:
            - method: ANY
              path: *
        - eventType: httpd
          runtime: nodejs13
          handler: src/router.handler
          routes:
            - method: GET
              path: /test
      - eventType: process
          runtime: nodejs13
          handler: src/queue/PROCESS.handler

Readme

Keywords

none

Package Sidebar

Install

npm i @ikonintegration/serverless-ikcomponents-plugin

Weekly Downloads

0

Version

1.2.4

License

MIT

Unpacked Size

133 kB

Total Files

41

Last publish

Collaborators

  • vitor-ikon
  • mateus.ikon
  • gwdebes
  • rescio