1.0.1 ā€¢ Published 2 years ago

@genie-solutions/gdk v1.0.1

Weekly downloads
207
License
ISC
Repository
-
Last release
2 years ago

GDK - Genie Constructs Library for AWS CDK

Set of reusable constructs for deploying AWS resources to Gentu and Platform.

Installing

Installing this library into your project

$ npm i @genie-solutions/gdk

Dependencies

IMPORTANT:

Major version 1.0.0 is built using version 2.0.0 of the AWS CDK. If you are using this library fresh, please use version 1.0.0 of the library and version 2.0.0+ of the AWS CDK. Legacy instructions remain below for supporting version 0.40.0.

LEGACY SUPPORT ONLY

This library is built using using version 1.151.0 of the AWS CDK. To ensure that you are able to use cdk and this library, please pin your cdk version.

$ npm i -g aws-cdk@1.151.0

Again also if you are using native CDK packages in your project, please ensure that you are using the same version. Example: S3 package...

$ npm install @aws-cdk/aws-s3@1.151.0

Structure

Modules

The GDK Library is organized into several modules but are packaged up into a single asset. The structure of the project is as follows:

  • src/xxx: where xxx represents the service component of an AWS CDK package name. Example: src/ecs will contain constructs that are extensions of aws-ecs constructs.
  • src/base-infra: this contains base infrastructure constructs that are imports of native CloudFormation templates.

Module Contents

Modules contain the following types:

  • Constructs - All higher-level constructs in this library.
  • Other Types - All non-construct classes, interfaces, structs and enums that exist to support the constructs.

Module Tests

The tests for the library should follow the same structure as the src folder.

How to publish a new version

After your branch has been merged into master: 1. Push your feature onto master 2. Tag your commit, like so: git tag -a v<major>.<minor>.<patch> -m "<major>.<minor>.<patch>" -- eg. git tag -a v0.31.14 -m "0.31.14" (comment here is very important) 3. Push tag to master git push --tags origin master

Gitlab pipeline will publish new version.

Useful commands

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests

Examples

Prerequisites

These variables are used to namespace all resources, generate stack names, tags and to ensure that the correct base infrastructure is targeted. They form the base of a GenieStack type.

ā— Required variables include: 1. executionEnvironment 2. featureEnvironment 3. application 4. service 5. version

You can read more about environment strategy on the wiki.

Example 1

This example creates an empty stack in which to build upon.

// The GDK includes a util module that allows developers to map environment variables to variables
export const configFromEnv =
  fromEnv({
    executionEnvironment: "EXECUTION_ENVIRONMENT",
    featureEnvironment: "FEATURE_ENVIRONMENT",
    application: "APPLICATION",
    service: "SERVICE",
    version: "VERSION",
    containerImage: "CONTAINER_IMAGE"
  });

// The service stack where everything is created
export class MyWebServiceStack extends GenieStack {
  constructor(scope: Construct, id: string, props: BaseServiceStackProps) {
    super(props, scope, id);

  }
}

const app = new App();

// Service stack is instantiated with the properties pulled from environment variables
new MyWebServiceStack(app, "MyWebServiceStack", {
  ...configFromEnv
});

app.synth();

Example 2

Building upon Example 1, this code contains a number of constructs in use, GenieFargateTaskDefinition and GenieFargateService. You will notice that props is passed around to each construct. This variable contains the minimum required variables as mentioned in Prerequisites, which again helps namespace, tag and target the correct infrastructure.

export class MyWebServiceStack extends GenieStack {
  constructor(scope: Construct, id: string, props: BaseServiceStackProps) {
    super(props, scope, id);

    const myWebServiceTaskDef = new GenieFargateTaskDefinition(this, "EcsTaskDefinition", {
      ...props,
      memoryLimitMiB: 1024,
      cpu: 512,
    });

    myWebServiceTaskDef.addGenieContainer("MyWebContainer", {
      imageName: configFromEnv.containerImage,
      port: 8086,
      cpu: 512,
      memoryLimitMiB: 1024,
      environment: {
        "THIRD_PARTY_API_URL": "http://www.somethirdparty.com/api/v2"
      },
      ...props
    });

    new GenieFargateService(this, "EcsService", {
      ...props,
      taskDefinition: myWebServiceTaskDef,
      desiredCount: 2,
      isPublic: true,
      healthCheck: {
        path: "/health",
        port: "8086"
      }
    });
  }
}
1.0.1

2 years ago

0.40.2

2 years ago

0.40.3

2 years ago

0.40.1

3 years ago

0.35.0

4 years ago

0.34.4

4 years ago

0.34.3

4 years ago

0.34.2

4 years ago

0.33.0

4 years ago

0.32.19

4 years ago

0.32.18

4 years ago

0.32.17

4 years ago

0.32.16

4 years ago

0.32.15

4 years ago

0.32.14

4 years ago

0.32.13

4 years ago

0.32.12

4 years ago

0.32.11

4 years ago

0.32.10

4 years ago

0.32.9

4 years ago

0.32.8

4 years ago

0.32.7

4 years ago

0.32.6

4 years ago

0.32.5

4 years ago

0.32.4

4 years ago

0.32.3

4 years ago

0.32.2

4 years ago

0.32.1

4 years ago

0.31.16

4 years ago

0.31.14

4 years ago

0.31.12

4 years ago

0.31.10

4 years ago

0.31.11

4 years ago

0.31.13

4 years ago

0.31.9

4 years ago

0.31.6

4 years ago

0.31.4

4 years ago

0.31.3

4 years ago

0.31.2

4 years ago

0.31.1

4 years ago

0.31.0

4 years ago

0.30.9

4 years ago

0.30.8

4 years ago

0.30.7

4 years ago

0.30.6

4 years ago

0.30.5

4 years ago

0.30.4

4 years ago

0.30.3

4 years ago

0.30.2

4 years ago

0.30.1

4 years ago

0.30.0

4 years ago

0.29.11

4 years ago

0.29.10

4 years ago

0.29.9

4 years ago

0.29.8

4 years ago

0.29.7

4 years ago

0.29.6

4 years ago

0.29.5

4 years ago

0.29.4

4 years ago

0.29.3

4 years ago

0.29.2

4 years ago

0.29.1

4 years ago

0.29.0

4 years ago

0.28.0

4 years ago

0.26.0

4 years ago

0.25.0

4 years ago

0.24.0

4 years ago

0.23.0

4 years ago

0.22.0

4 years ago

0.21.0

4 years ago

0.20.0

4 years ago

0.19.0

4 years ago

0.18.0

4 years ago

0.16.0

4 years ago

0.17.0

4 years ago

0.15.0

4 years ago

0.10.0

4 years ago

0.11.0

4 years ago

0.9.0

4 years ago

0.12.0

4 years ago

0.8.0

4 years ago

0.13.0

4 years ago

0.14.0

4 years ago

0.7.0

4 years ago

0.5.0

4 years ago

0.6.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago