diff --git a/lib/authentication/index.ts b/lib/authentication/index.ts index c547d17..b850b34 100644 --- a/lib/authentication/index.ts +++ b/lib/authentication/index.ts @@ -38,6 +38,8 @@ import { Tracing } from 'aws-cdk-lib/aws-lambda' import { NagSuppressions } from 'cdk-nag' +import path, { dirname } from 'path' +import { fileURLToPath } from 'url' interface AuthenticationProps { userPoolId?: string @@ -45,6 +47,9 @@ interface AuthenticationProps { userPoolClientId?: string } +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) + export class Authentication extends Construct { public readonly userPool: IUserPool private readonly identityPool: IIdentityPool @@ -95,18 +100,14 @@ export class Authentication extends Construct { 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole' ) ) + const preTokenGenerationHookFunction = new NodejsFunction( this, 'pre-token-generation-hook', { description: "Post Authentication, Pre-Token Generation Hook that creates a user's accountId", - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'pre-token-generation-hook' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'index.pre-token-generation-hook.ts'), handler: 'handler', role: preTokenGenerationHookFunctionRole, architecture: Architecture.ARM_64, diff --git a/lib/authorization/index.ts b/lib/authorization/index.ts index 2ba043b..d63cf7c 100644 --- a/lib/authorization/index.ts +++ b/lib/authorization/index.ts @@ -125,12 +125,7 @@ export class Authorization extends Construct { description: 'Function responsible for checking if requests are authorized to create items using Amazon Verified Permissions', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'action-authorization' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'index.action-authorization.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -157,12 +152,7 @@ export class Authorization extends Construct { description: 'Function responsible for checking if requests are authorized to read/view data items using Amazon Verified Permissions', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'read-authorization' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'index.read-authorization.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -188,12 +178,7 @@ export class Authorization extends Construct { description: 'Function responsible for checking if requested resources are authorized for viewing data and filtering out unauthorized data from the list.', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'list-filter-authorization' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'index.list-filter-authorization.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, diff --git a/lib/data-feed-ingestion/rss-atom-ingestion/data-feed-poll-step-function.ts b/lib/data-feed-ingestion/rss-atom-ingestion/data-feed-poll-step-function.ts index 6485960..a0e024d 100644 --- a/lib/data-feed-ingestion/rss-atom-ingestion/data-feed-poll-step-function.ts +++ b/lib/data-feed-ingestion/rss-atom-ingestion/data-feed-poll-step-function.ts @@ -32,6 +32,12 @@ import { import { SfnStateMachine as StateMachineTarget } from 'aws-cdk-lib/aws-events-targets' import { Construct } from 'constructs' import { NagSuppressions } from 'cdk-nag' +import { fileURLToPath } from 'url' +import path, { dirname } from 'path' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) + interface DataFeedPollStepFunctionProps extends StackProps { dataFeedTable: Table @@ -52,9 +58,7 @@ export class DataFeedPollStepFunction extends Construct { description: 'Function responsible for getting all enabled data feeds to poll', handler: 'handler', - entry: new URL( - import.meta.url.replace(/(.*)(\..+)/, '$1.' + 'get-data-feeds' + '$2') - ).pathname, + entry: path.join(__dirname, 'data-feed-pool-step-function.get-data-feeds.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, diff --git a/lib/data-feed-ingestion/rss-atom-ingestion/index.ts b/lib/data-feed-ingestion/rss-atom-ingestion/index.ts index 5c7ca28..c7e6d93 100644 --- a/lib/data-feed-ingestion/rss-atom-ingestion/index.ts +++ b/lib/data-feed-ingestion/rss-atom-ingestion/index.ts @@ -19,6 +19,11 @@ import { Tracing } from 'aws-cdk-lib/aws-lambda' import { NagSuppressions } from 'cdk-nag' +import { fileURLToPath } from 'url' +import path, { dirname } from 'path' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) interface RssAtomFeedProps { dataFeedTable: Table @@ -71,9 +76,7 @@ export class RssAtomFeedConstruct extends Construct { description: 'Function responsible for subscribing to a specified RSS/ATOM feed', handler: 'handler', - entry: new URL( - import.meta.url.replace(/(.*)(\..+)/, '$1.' + 'feed-subscriber' + '$2') - ).pathname, + entry: path.join(__dirname, 'index.feed-subscriber.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, diff --git a/lib/data-feed-ingestion/rss-atom-ingestion/ingestion-step-function.ts b/lib/data-feed-ingestion/rss-atom-ingestion/ingestion-step-function.ts index 0d3cf5e..b09a06c 100644 --- a/lib/data-feed-ingestion/rss-atom-ingestion/ingestion-step-function.ts +++ b/lib/data-feed-ingestion/rss-atom-ingestion/ingestion-step-function.ts @@ -33,6 +33,11 @@ import { } from 'aws-cdk-lib/aws-stepfunctions-tasks' import { NagSuppressions } from 'cdk-nag' import { Construct } from 'constructs' +import path, { dirname } from 'path' +import { fileURLToPath } from 'url' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) interface IngestionStepFunctionProps extends StackProps { dataFeedTable: Table @@ -49,9 +54,7 @@ export class IngestionStepFunction extends Construct { description: 'Function responsible for reading feeds and return the articles for ingestion', handler: 'handler', - entry: new URL( - import.meta.url.replace(/(.*)(\..+)/, '$1.' + 'feed-reader' + '$2') - ).pathname, + entry: path.join(__dirname, 'ingestion-step-function.feed-reader.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -71,12 +74,7 @@ export class IngestionStepFunction extends Construct { description: 'Function responsible for filtering out already ingested articles', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'filter-ingested-articles' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'ingestion-step-function.filter-ingested-articles.ts'), runtime: Runtime.NODEJS_20_X, architecture: Architecture.ARM_64, tracing: Tracing.ACTIVE, @@ -98,12 +96,7 @@ export class IngestionStepFunction extends Construct { description: "Function responsible for ingesting each article's content, summarizing it, and storing the data in DDB", handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'article-ingestor' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'ingestion-step-function.article-ingestor.ts'), runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, architecture: Architecture.ARM_64, @@ -134,12 +127,7 @@ export class IngestionStepFunction extends Construct { description: 'Function responsible for filtering out using a user provided prompt and Amazon Bedrock.', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'filter-articles-with-bedrock' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'ingestion-step-function.filter-articles-with-bedrock.ts'), runtime: Runtime.NODEJS_20_X, architecture: Architecture.ARM_64, tracing: Tracing.ACTIVE, diff --git a/lib/newsletter-generator/index.ts b/lib/newsletter-generator/index.ts index a634ae4..dabc46c 100644 --- a/lib/newsletter-generator/index.ts +++ b/lib/newsletter-generator/index.ts @@ -34,6 +34,11 @@ import { PinpointApp } from './pinpoint-app' import { type IUserPool } from 'aws-cdk-lib/aws-cognito' import { type UIConfig } from '../shared' import { NagSuppressions } from 'cdk-nag' +import { fileURLToPath } from 'url' +import path, { dirname } from 'path' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) interface NewsletterGeneratorProps { dataFeedTable: Table @@ -126,12 +131,7 @@ export class NewsletterGenerator extends Construct { description: 'Function responsible for creating the newsletter campaigns for each unique email', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'newsletter-campaign-creator' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'index.newsletter-campaign-creator.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -161,9 +161,7 @@ export class NewsletterGenerator extends Construct { description: 'Function responsible for generating the newsletter HTML & Plain Text emails', handler: 'handler', - entry: new URL( - import.meta.url.replace(/(.*)(\..+)/, '$1.' + 'email-generator' + '$2') - ).pathname, + entry: path.join(__dirname, 'index.email-generator.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -221,12 +219,7 @@ export class NewsletterGenerator extends Construct { description: 'Function responsible for creating and scheduling the newsletter', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'newsletter-creator' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'index.newsletter-creator.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -268,9 +261,7 @@ export class NewsletterGenerator extends Construct { description: 'Function responsible for getting looking up a Newsletter and its associated details', handler: 'handler', - entry: new URL( - import.meta.url.replace(/(.*)(\..+)/, '$1.' + 'get-newsletter' + '$2') - ).pathname, + entry: path.join(__dirname, 'index.get-newsletter.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -293,9 +284,7 @@ export class NewsletterGenerator extends Construct { description: 'Function responsible for subscribing a user to the newsletter', handler: 'handler', - entry: new URL( - import.meta.url.replace(/(.*)(\..+)/, '$1.' + 'user-subscriber' + '$2') - ).pathname, + entry: path.join(__dirname, 'index.user-subscriber.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE, @@ -335,12 +324,7 @@ export class NewsletterGenerator extends Construct { description: 'Function responsible for unsubscribing a user from the newsletter', handler: 'handler', - entry: new URL( - import.meta.url.replace( - /(.*)(\..+)/, - '$1.' + 'user-unsubscriber' + '$2' - ) - ).pathname, + entry: path.join(__dirname, 'index.user-unsubscriber.ts'), architecture: Architecture.ARM_64, runtime: Runtime.NODEJS_20_X, tracing: Tracing.ACTIVE,