0.1.1 • Published 2 years ago

dvs-inbox-infra v0.1.1

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
2 years ago

AWS CDK Construct for DVS Inbox!

This package provides a CDK Constrcut and related TS Types for creating DVS Inbox related resources.

Setup

import { App, Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import { InboxConstruct, InboxProps } from "@a-cloud-guru/dvs-inbox-infra";

const app = new App();

class ExampleServiceStack extends Stack {
  constructor(scope: Construct, id: string, props: StackProps = {}) {
    super(scope, id, props);

    const inboxProps: InboxProps = {
      vpcId: "vpc-12345",
      subnetIds: ["subnet-12345", "subnet-67890"],
      kafka: {
        bootstrapServers: ["kafka1-broker-staging.vnerd.com:9092"],
        topicName: "dvs.foo.v1",
        schemaRegistryHost: "http://dvs-schema-registry-stage.vnerd.com:8081",
      }
    };

    const inboxConstruct = new InboxConstruct(
      this,
      'MyFooInbox', // Prefix for this Inbox. 
      inboxProps
    );

    console.log("Created inbox resources", inboxConstruct);
  }
}

new ExampleServiceStack(app, "MyExampleServiceStack", {
  env: {
    account: "123456789012",
    region: "us-east-1",
  },
  tags: {
    "cc_service": "cloud-dvs-integration-example",
    "cc_company_usage": "acg",
    "team": "principle-engineers",
    "info:env": "dev"
  }
});

Configuration

type InboxProps = {
  vpcId: string;
  subnetIds: string[];
  kafka: {
    bootstrapServers: string[];
    schemaRegistryHost: string;
    topicName: string;
  };
};

Output

This construct generates the following CfOutput variables. Please note these names exclude the random hash that cdk normally generates. This is to make it easier for these variables to be referenced in the tools like Serverless framework.

  • ${camelCasePrefix}TargetVpcId - VPC ID of where the construct is deployed
  • ${camelCasePrefix}DynamoDBTableName - Name of the DynamoDB table
  • ${camelCasePrefix}SecurityGroupId - ID of the Security Group generated for the nested resources
  • ${camelCasePrefix}ExecutionRoleArn - ARN of the Lambda's execution Role
  • ${camelCasePrefix}ConsumerFunctionArn - ARN of the consumer Function

camelCasePrefix is basde on the prefix parameter of the construct and stage tag (ie info:env), which are formatted in camleCase. (eg. MyFooInbox & dev -> myFooInboxDev)