Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@croudtech/sst-utils

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@croudtech/sst-utils

Common SST configuration utilities

  • 0.1.7
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@croudtech/sst-utils

Common SST configuration utilities for AWS applications.

Installation

npm install @croudtech/sst-utils

Namespaced imports

This package supports namespaced imports that mirror the directory structure of the package.

So, for example, this import from the package root...

import { stacks } from '@croudtech/sst-utils';
const { BaseConfig, ParameterMap } = stacks.modules.config;

...is equivalent to an import direct from module directly...

import { BaseConfig, ParameterMap } from '@croudtech/sst-utils/stacks/modules/config';

Usage

Config

Utils for working with the Parameter store and Secrets manager

Below is example of defining and using a config class to access parameters and secrets in your SST based functions

import { BaseConfig, ParameterMap } from '@croudtech/sst-utils/stacks/modules/config';

// extend the BaseConfig class with the specific access your SST app needs
export class CommonConfig extends BaseConfig {
  secrets = [
    "AUTH_CLIENT_ID",
    "AUTH_CLIENT_SECRET",
    "AUTH_TOKEN_ENDPOINT",
  ];
  configName: string = "common";
  data: ParameterMap = {
    CROUD_PLATFORM_API_URL: process.env.CROUD_PLATFORM_API_URL,
  }
}

// initialize and load the config class
const commonConfig = new CommonConfig(stack, environment)
const commonParameters = await commonConfig.load()

// Build a policy based on the config defined in the config class
const policyConstruct = new PolicyConstruct(stack, "PolicyConstruct", {
    parameters: [
        ...commonConfig.parameterNames,
    ]
})

// Use the parameters in your SST app
 const apiFunction = new Function(stack, 'ApiFunction', {
    handler: 'app/app.handler',
    runtime: 'python3.12',
    environment: {
      ...commonParameters,
    },
    initialPolicy: [
      policyConstruct.parameterPolicyStatement, 
      policyConstruct.secretPolicyStatement
    ],
  })

VPC

Utils for working with VPCs Below is example of defining a VPC stack in your SST app

import { StackContext, use } from "sst/constructs";
import { Vpc } from "@croudtech/sst-utils/stacks/modules/vpc";
import { Shared } from "./SharedStack";

export function VpcStack({ stack }: StackContext) {
  const { params } = use(Shared)
  const vpcId = params.AWS_VPC_ID as string;

  const vpcInstance = new Vpc(stack, vpcId);

  return {
    vpc: vpcInstance.vpc,
    lambdaSecurityGroups: [vpcInstance.createSecurityGroup()],
  };
}

CI

NPM publish

This repo will automatically publish to npm on create of a new release

Keywords

FAQs

Package last updated on 14 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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