{"version":3,"sources":["jsdelivr-header.js","/npm/@aws-solutions-konstruk/aws-lambda-dynamodb@0.8.1/lib/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,oECQA,MAAA,SAAA,QAAA,yBACA,SAAA,QAAA,gCACA,OAAA,QAAA,iBACA,OAAA,QAAA,gCAmCA,MAAa,yBAAyB,OAAA,UAYpC,WAAA,CAAY,EAAkB,EAAY,G,MAUxC,GATA,MAAM,EAAO,GAEb,KAAK,GAAK,SAAS,oBAAoB,KAAM,CAC3C,aAAc,EAAM,aACpB,kBAAmB,EAAM,kBACzB,oBAAqB,EAAM,sBAIzB,EAAM,iBAAkB,CAC1B,MAAM,EAAmB,OAAA,cAAc,SAAS,kBAAmB,EAAM,kBACzE,KAAK,MAAQ,IAAI,SAAS,MAAM,KAAM,cAAe,E,MAErD,KAAK,MAAQ,IAAI,SAAS,MAAM,KAAM,cAAe,SAAS,mBAQhE,GALA,KAAK,GAAG,eAAe,iBAAkB,KAAK,MAAM,WAEpD,KAAK,MAAM,mBAAmB,KAAK,GAAG,iBAGZ,QAAtB,EAAA,EAAM,wBAAgB,IAAA,OAAA,EAAA,EAAE,eAAgB,SAAS,YAAY,YAAa,CACxC,KAAK,MAAM,KAAK,UAAU,YACrD,WAAW,SAAW,CAC3B,QAAS,CACL,kBAAmB,CAAC,CAChB,GAAI,MACJ,OAAQ,uF,CAKxB,CAQO,WAAA,GACL,OAAO,KAAK,KACd,CAQO,cAAA,GACL,OAAO,KAAK,EACd,EAjEF,QAAA","file":"/npm/@aws-solutions-konstruk/aws-lambda-dynamodb@0.8.1/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@aws-solutions-konstruk/aws-lambda-dynamodb@0.8.1/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n *  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n *\n *  Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance\n *  with the License. A copy of the License is located at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n *  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES\n *  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions\n *  and limitations under the License.\n */\n\nimport * as lambda from '@aws-cdk/aws-lambda';\nimport * as dynamodb from '@aws-cdk/aws-dynamodb';\nimport * as defaults from '@aws-solutions-konstruk/core';\nimport { Construct } from '@aws-cdk/core';\nimport { overrideProps } from '@aws-solutions-konstruk/core';\n\n/**\n * @summary The properties for the LambdaToDynamoDB Construct\n */\nexport interface LambdaToDynamoDBProps {\n  /**\n   * Whether to create a new lambda function or use an existing lambda function.\n   * If set to false, you must provide a lambda function object as `existingObj`\n   *\n   * @default - true\n   */\n  readonly deployLambda: boolean,\n  /**\n   * Existing instance of Lambda Function object.\n   * If `deploy` is set to false only then this property is required\n   *\n   * @default - None\n   */\n  readonly existingLambdaObj?: lambda.Function,\n  /**\n   * Optional user provided props to override the default props.\n   * If `deploy` is set to true only then this property is required\n   *\n   * @default - Default props are used\n   */\n  readonly lambdaFunctionProps?: lambda.FunctionProps,\n  /**\n   * Optional user provided props to override the default props\n   *\n   * @default - Default props are used\n   */\n  readonly dynamoTableProps?: dynamodb.TableProps\n}\n\nexport class LambdaToDynamoDB extends Construct {\n  private fn: lambda.Function;\n  private table: dynamodb.Table;\n\n  /**\n   * @summary Constructs a new instance of the LambdaToDynamoDB class.\n   * @param {cdk.App} scope - represents the scope for all the resources.\n   * @param {string} id - this is a a scope-unique id.\n   * @param {LambdaToDynamoDBProps} props - user provided props for the construct\n   * @since 0.8.0\n   * @access public\n   */\n  constructor(scope: Construct, id: string, props: LambdaToDynamoDBProps) {\n    super(scope, id);\n\n    this.fn = defaults.buildLambdaFunction(this, {\n      deployLambda: props.deployLambda,\n      existingLambdaObj: props.existingLambdaObj,\n      lambdaFunctionProps: props.lambdaFunctionProps\n    });\n\n    // Set the default props for DynamoDB table\n    if (props.dynamoTableProps) {\n      const dynamoTableProps = overrideProps(defaults.DefaultTableProps, props.dynamoTableProps);\n      this.table = new dynamodb.Table(this, 'DynamoTable', dynamoTableProps);\n    } else {\n      this.table = new dynamodb.Table(this, 'DynamoTable', defaults.DefaultTableProps);\n    }\n\n    this.fn.addEnvironment('DDB_TABLE_NAME', this.table.tableName);\n\n    this.table.grantReadWriteData(this.fn.grantPrincipal);\n\n    // Conditional metadata for cfn_nag\n    if (props.dynamoTableProps?.billingMode === dynamodb.BillingMode.PROVISIONED) {\n      const cfnTable: dynamodb.CfnTable = this.table.node.findChild('Resource') as dynamodb.CfnTable;\n      cfnTable.cfnOptions.metadata = {\n          cfn_nag: {\n              rules_to_suppress: [{\n                  id: 'W73',\n                  reason: `PROVISIONED billing mode is a default and is not explicitly applied as a setting.`\n              }]\n          }\n      };\n    }\n  }\n\n  /**\n   * @summary Returns an instance of dynamodb.Table created by the construct.\n   * @returns {dynamodb.Table} Instance of dynamodb.Table created by the construct\n   * @since 0.8.0\n   * @access public\n   */\n  public dynamoTable(): dynamodb.Table {\n    return this.table;\n  }\n\n  /**\n   * @summary Returns an instance of lambda.Function created by the construct.\n   * @returns {lambda.Function} Instance of lambda.Function created by the construct\n   * @since 0.8.0\n   * @access public\n   */\n  public lambdaFunction(): lambda.Function {\n    return this.fn;\n  }\n\n}"]}