open-index/open-npm huggingface dataset:
npm package: @nona-creative/aws-cdk-api-gateway
Description: AWS API Gateway package with CDK
Author: NoNa Creative
Latest version: 1.0.2

AWS API Gateway (CDK)
===

Installation
---

```bash
npm i -S @nona-creative/aws-cdk-api-gateway
```


Usage
---

 1. Create the API Gateway stack

    ```typescript
    import { ApiGatewayStack } from '@nona-creative/aws-cdk-api-gateway'
    
    this.apiGatewayStack = new ApiGatewayStack(this.scope, `${this.id}-lambda-${this.stage}`, {
      stage: 'test',
    })
    ```

 2. Create a Security Group for Lambda on the relevant VPC (if you are using VPC eg. using ``@nona-creative/aws-cdk-vpc``)
    
    ```typescript
    this.vpcStack.createSecurityGroup({
      name: LAMBDA_VPC_SECURITY_GROUP_NAME,
      description: 'Lambda Security Group for app VPC',
    })
    ```

 3. You can then attach API Gateway to Lambdas by adding the Lambdas as Resources and Methods on the API Gateway Stack instance, eg.

    ```typescript
    const books = this.apiGatewayStack.addResource('books', 'GET', getBooksLambda, this.apiGatewayStack.api.root)
    this.apiGatewayStack.addMethod('POST', createBooksLambda, books)
    ```
npm package: @nona-creative/aws-cdk-config
Description: AWS Config package
Author: NoNa Creative
Latest version: 1.0.2

AWS Config (CDK)
===

Installation
---

```bash
npm i -S @nona-creative/aws-cdk-config
```


Usage
---

 1. Create a ``config`` directory in the AWS CDK package that needs access to environment specific configuration variables
    ```text
    +-- packages
        +-- some-api-aws-cdk
            +-- src
                +-- config
    ```

 2. Then add any of the following json files:
    - ``paramstore.json``
    - ``secrets-manager.json``

 3. Configure each of these config files as described in the ``Config Files`` below


Config Files
---

There are 2 ways to load environment specific configuration variables into a AWS CDK App, Stack or Construct using this package:
 1. from AWS Paramstore
 2. from AWS Secrets Manager

The resulting values from both approaches are returned together when you call ``loadConfig`` on the ``AWSConfig`` instance as follows:
```typescript
const awsConfig = new AWSConfig(...)
const configData = awsConfig.loadConfig()
```

### AWS Paramstore config file

``src/config/paramstore.json``

##### syntax:
```json
{
  "<env name>": "<paramstore path>"
}
```

##### example:
```json
{
  "EMAIL_FROM": "email/fromAddress"
}
```

The param store paths will have the App & Package names, as well as the stage prepended eg.
the example above will become:
```json
{
  "EMAIL_FROM": "/some-project/some-package/dev/email/fromAddress"
}
```
These are set in the ``.env`` file corresponding to the deployment stage, eg.
if you are deploying ``some-api-aws-cdk`` to ``dev`` stage, then:
``pacakges/some-api-aws-cdk/.env.dev`` will contain App & Package names, eg.
```
APP_NAME=some-project
PACKAGE_NAME=some-api
```

##### usage:
```typescript
import * as paramStoreKeys from '../config/aws-params.json'

const awsConfig = new AWSConfig(stack, `${id}-config`, {
  stage,
  paramStoreKeys,
})
const configData = awsConfig.loadConfig()
const { EMAIL_FROM } = configData
```

### AWS Secrets Manager config file

``src/config/paramstore.json``

##### syntax:
```json
{
  "<env name>": "<secret key>"
}
```

##### example:
```json
{
  "PG_PASSWORD": "dbMasterPassword"
}
```

##### usage:
As well as providing the config as demonstrated above,
you will also need to provide the AWS Secrets Manager Secret ARN when instantiating the `AWSConfig` class,
do this by defining an ``SECRETS_ARN`` env in the ``.env`` file corresponding to the deployment stage, eg.
in:
``pacakges/some-api-aws-cdk/.env.dev``, add the following:
```
SECRETS_ARN=<your secret's ARN>
```

Then use this env when you instantiating the `AWSConfig` class:
```typescript
import * as secretsManagerKeys from '../config/aws-secrets.json'

const awsConfig = new AWSConfig(stack, `${id}-config`, {
  stage,
  secretsManagerKeys,
  secretsArn: process.env.SECRETS_ARN,
})
const configData = awsConfig.loadConfig()
const { PG_PASSWORD } = awsConfig
```
npm package: @nona-creative/aws-cdk-lambda
Description: AWS Lambda package with CDK
Author: NoNa Creative
Latest version: 1.0.2

AWS Lambda (CDK)
===

Installation
---

```bash
npm i -S @nona-creative/aws-cdk-lambda
```


Usage
---

 1. Configure the build Lambda function
 
    ```typescript
    const _buildLambdaFunction = buildLambdaFunction(
      Code.fromAsset(codeAssetsZipFile),
      `${this.id}-handlers`,
      `${this.id}-lambda-${this.stage}`,
    )
    ```
    
    optionally with VPC:

    ```typescript
    const functionProps = {
      vpc: this.vpcStack.vpc,
      securityGroup: this.vpcStack.securityGroups[LAMBDA_VPC_SECURITY_GROUP_NAME],
      vpcSubnets: { subnetType: SubnetType.PRIVATE },
    }
    const _buildLambdaFunction = buildLambdaFunction(
      Code.fromAsset(codeAssetsZipFile),
      `${this.id}-handlers`,
      `${this.id}-lambda-${this.stage}`,
      functionProps,
    )
    ```

 2. Build functions as needed, eg.

    ```typescript
    const getBooksLambda = _buildLambdaFunction(stack, 'getBooks', environment)
    const createBookLambda = _buildLambdaFunction(stack, 'createBook', environment)
    ```