diff --git a/layers/src/canary-stack.ts b/layers/src/canary-stack.ts index 75c4c852a3..af562dd372 100644 --- a/layers/src/canary-stack.ts +++ b/layers/src/canary-stack.ts @@ -1,5 +1,6 @@ import { randomUUID } from 'node:crypto'; -import path from 'node:path'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { CustomResource, Duration, Stack, type StackProps } from 'aws-cdk-lib'; import { Effect, PolicyStatement } from 'aws-cdk-lib/aws-iam'; import { LayerVersion, Runtime, Tracing } from 'aws-cdk-lib/aws-lambda'; @@ -15,6 +16,9 @@ export interface CanaryStackProps extends StackProps { readonly ssmParameterLayerArn: string; } +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + export class CanaryStack extends Stack { public constructor(scope: Construct, id: string, props: CanaryStackProps) { super(scope, id, props); @@ -36,7 +40,7 @@ export class CanaryStack extends Stack { ]; const canaryFunction = new NodejsFunction(this, 'CanaryFunction', { - entry: path.join( + entry: join( __dirname, '../tests/e2e/layerPublisher.class.test.functionCode.ts' ), diff --git a/layers/src/layer-publisher-stack.ts b/layers/src/layer-publisher-stack.ts index b4b7260896..a47cea4bfd 100644 --- a/layers/src/layer-publisher-stack.ts +++ b/layers/src/layer-publisher-stack.ts @@ -1,6 +1,7 @@ import { execSync } from 'node:child_process'; import { randomUUID } from 'node:crypto'; -import { join, resolve, sep } from 'node:path'; +import { dirname, join, resolve, sep } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { CfnOutput, RemovalPolicy, Stack, type StackProps } from 'aws-cdk-lib'; import { Architecture, @@ -12,6 +13,9 @@ import { import { StringParameter } from 'aws-cdk-lib/aws-ssm'; import type { Construct } from 'constructs'; +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + export interface LayerPublisherStackProps extends StackProps { readonly layerName?: string; readonly powertoolsPackageVersion?: string;