npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

neulabs-cdk-constructs

v0.7.0

Published

--- id: index title: Getting Started ---

Downloads

2,625

Readme


id: index title: Getting Started

Neulabs CDK Constructs

NPM PyPI PyPI License

The neulabs-cdk-constructs library contains CDK-based constructs and stacks to allow the creation of cloud infrastructure on AWS.

The purpose of the library is to expose modules that can facilitate the creation and maintenance of the infrastructure as code.

Inside you will find generic stacks that allow the creation of services by simply instantiating a class, or constructs that implement logic to facilitate the developer and many other aspects.

We decided to develop it in Typescript, using projen for repository management, and the JSII library to be able to compile the neulabs-cdk-constructs package into multiple languages.

Usage

Package Installation (npm)

yarn add neulabs-cdk-constructs
# or
npm install neulabs-cdk-constructs

Package Installation (python)

pip install neulabs-cdk-constructs

Construct APIs

View on Construct Hub

Examples

Lambda Function with New Relic

import {aws_lambda as neulabs_lambda} from 'neulabs-cdk-constructs';


    // Create the lambda function
    this.lambdaFn = new neulabs_lambda.NewRelicFunction(this, functionName, {
      stage: props.stage,
      functionName: functionName,
      runtime: Runtime.PYTHON_3_9,
      handler: 'app.handler',
      code: Code.fromAsset(path.join(__dirname, handler), {}),
      layers: [baseLayer, ...(layers || [])],
      environment: props.environment,
      memorySize: props.memorySize || 128,
      timeout: props.timeout || Duration.seconds(30),
      architecture: lambda.Architecture.X86_64,
      newRelicAccountId: '3540246',
      newRelicLayerName: 'NewRelicPython39',
      newRelicLayerVersion: 49,
      newRelicwithExtensionSendLogs: true,
      disableNewRelic: props.stage === 'production' ? false : true,
    });

    this.lambdaFn.addPowerToolsLayer(
      app,
      neulabs_lambda.LambdaPowerToolsLayerName.TYPESCRIPT,
      neulabs_lambda.LambdaPowerToolsLayerAccountId.TYPESCRIPT,
      20,
      props.stage === 'production' ? false : true,
      props.stage === 'production' ? 'WARGNING' : 'DEBUG'
    );

Create Github OIDC

AWS (Amazon Web Services) supports the use of OpenID Connect (OIDC) for identity federation. OIDC allows you to use an identity provider (such as GitHub) to authenticate users and grant them temporary security credentials to access AWS resources. Here's a brief overview of using GitHub as an identity provider with AWS OIDC:

  • Identity Provider (GitHub): GitHub acts as the identity provider in this setup. Users authenticate with GitHub, and GitHub issues identity tokens following the OIDC standard.
  • AWS IAM Role: In AWS, you create an IAM (Identity and Access Management) role that specifies the permissions users should have when authenticated. This role trusts the GitHub OIDC provider.
  • GithubOIDCStack a neulabs construct: create a new stack with three roles:
    • github-oidc-workflow-role user used for authentication
    • cdk-oidc-deploy-role role used for cdk deploying
    • cdk-oidc-bootsrap-role role used for cdk bootstrap
  1. Create GithubOIDCStack
environment = process.env.ENVIRONMENT! || 'staging';

new GithubOIDCStack(app, 'OidcStack', {
  env: {
    account: process.env.CDK_DEFAULT_ACCOUNT,
    region: process.env.CDK_DEFAULT_REGION,
  },
  stage: environment,
  githubUser: 'username',
  githubRepository: 'repositoryName', # You can also use '*'
  tokenAction: TokenActions.ALL,
  cdkDeployRoleAwsManagedPolicies: ['AdministratorAccess'],
});
  1. Use oidc role to authenticate the Github workflow
...

permissions:
  id-token: write
  contents: read

jobs:
  ...
  deploy:
    name: OIDC Auth
    runs-on: ubuntu-20.04
    steps:
      - name: Configure aws credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: arn:aws:iam::{ACCOUNT ID}:role/github-oidc-workflow-role
          aws-region: {REGION}
          mask-aws-account-id: no
  ...

Create NewRelic Connection

The NewRelicStack implements the infrastructure to send metrics and logs to Newrelic through Kinesis and Cloudwatch Stream. Once deployed you can copy the ARN of the 'NewRelicInfrastructure-Integrations' role and use it to configure Newrelic.

  new NewRelicStack(app, 'NewrelicStack', {
    env: constants.env,
    stage: constants.environment,
    newRelicBucketName: `newrelic-${constants.awsAccountId}-${constants.environment}`,
    newRelicAccountId: newRelicAccountId,
    newRelicLicenseKey: newRelicLicenseKey,
    newRelicApiUrlMetrics: EndpointUrlMetrics.EU_METRICS,
    newRelicApiUrlLogs: EndpointUrlLogs.EU_LOGS,
  });

Dev mode

Requirements

  • Node >= v20.12.0
  • Yarn >= 1.22

Setup env

yarn install

npx projen default

chmod +x .husky/pre-commit

cd docs yarn install

Contributors

Rules

Read the CONTRIBUTING.md and CODE_OF_CONDUCT.md before create pull-request.

Developers

License

See the LICENSE file for more information.