From f3c3f87f4f033135e2463de245002956e6504663 Mon Sep 17 00:00:00 2001 From: corymhall <43035978+corymhall@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:18:58 -0500 Subject: [PATCH 1/3] Fix CDK errors not being logged For some reason trying to log an error using `error` does not log anything. Also, we were not throwing the error so we were continuing until it failed later with a different very unhelpful error message. Instead of logging (since it doesn't work) just throw the error --- integration/errors-test/Pulumi.yaml | 3 +++ integration/errors-test/index.ts | 23 +++++++++++++++++++++++ integration/errors-test/package.json | 15 +++++++++++++++ integration/errors-test/tsconfig.json | 18 ++++++++++++++++++ integration/examples_nodejs_test.go | 14 ++++++++++++++ src/stack.ts | 6 ++---- 6 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 integration/errors-test/Pulumi.yaml create mode 100644 integration/errors-test/index.ts create mode 100644 integration/errors-test/package.json create mode 100644 integration/errors-test/tsconfig.json diff --git a/integration/errors-test/Pulumi.yaml b/integration/errors-test/Pulumi.yaml new file mode 100644 index 00000000..046ca94b --- /dev/null +++ b/integration/errors-test/Pulumi.yaml @@ -0,0 +1,3 @@ +name: pulumi-aws-errors +runtime: nodejs +description: errors integration test diff --git a/integration/errors-test/index.ts b/integration/errors-test/index.ts new file mode 100644 index 00000000..9f4dab09 --- /dev/null +++ b/integration/errors-test/index.ts @@ -0,0 +1,23 @@ +import * as aws from '@pulumi/aws'; +import * as iam from 'aws-cdk-lib/aws-iam'; +import * as events from 'aws-cdk-lib/aws-events'; +import * as pulumicdk from '@pulumi/cdk'; + +class ErrorsStack extends pulumicdk.Stack { + constructor(app: pulumicdk.App, id: string, options?: pulumicdk.StackOptions) { + super(app, id, options); + const eventBus = new events.EventBus(this, 'testbus'); + // This will fail because the `sid` property is required + eventBus.addToResourcePolicy( + new iam.PolicyStatement({ + actions: ['events:PutEvents'], + principals: [new iam.AccountRootPrincipal()], + resources: [eventBus.eventBusArn], + }), + ); + } +} + +new pulumicdk.App('app', (scope: pulumicdk.App) => { + new ErrorsStack(scope, 'teststack'); +}); diff --git a/integration/errors-test/package.json b/integration/errors-test/package.json new file mode 100644 index 00000000..888282a9 --- /dev/null +++ b/integration/errors-test/package.json @@ -0,0 +1,15 @@ +{ + "name": "pulumi-aws-cdk", + "devDependencies": { + "@types/node": "^10.0.0" + }, + "dependencies": { + "@pulumi/aws": "^6.0.0", + "@pulumi/aws-native": "^1.5.0", + "@pulumi/cdk": "^0.5.0", + "@pulumi/pulumi": "^3.0.0", + "aws-cdk-lib": "2.149.0", + "constructs": "10.3.0", + "esbuild": "^0.24.0" + } +} diff --git a/integration/errors-test/tsconfig.json b/integration/errors-test/tsconfig.json new file mode 100644 index 00000000..eac442cb --- /dev/null +++ b/integration/errors-test/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "strict": true, + "outDir": "bin", + "target": "es2019", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "experimentalDecorators": true, + "pretty": true, + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true + }, + "include": [ + "./*.ts" + ] +} diff --git a/integration/examples_nodejs_test.go b/integration/examples_nodejs_test.go index 13f4b909..2a40ec4c 100644 --- a/integration/examples_nodejs_test.go +++ b/integration/examples_nodejs_test.go @@ -15,6 +15,7 @@ package examples import ( + "bytes" "path/filepath" "testing" @@ -118,6 +119,19 @@ func TestCloudFront(t *testing.T) { integration.ProgramTest(t, &test) } +func TestErrors(t *testing.T) { + var buf bytes.Buffer + test := getJSBaseOptions(t). + With(integration.ProgramTestOptions{ + Dir: filepath.Join(getCwd(t), "errors-test"), + Stderr: &buf, + ExpectFailure: true, + }) + + integration.ProgramTest(t, &test) + assert.Containsf(t, buf.String(), "Error: Event Bus policy statements must have a sid", "Expected error message not found in pulumi up output") +} + func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions { base := getBaseOptions(t) baseJS := base.With(integration.ProgramTestOptions{ diff --git a/src/stack.ts b/src/stack.ts index 4a70fab4..e538ac57 100644 --- a/src/stack.ts +++ b/src/stack.ts @@ -152,15 +152,13 @@ export class App const message = e.message as string; const messageParts = message.split('Context lookups have been disabled. '); const missingParts = messageParts[1].split('Missing context keys: '); - error( + throw new Error( 'Context lookups have been disabled. Make sure all necessary context is already in "cdk.context.json". \n' + 'Missing context keys: ' + missingParts[1], - this, ); - } else { - error(e, this); } + throw e; } const converter = new AppConverter(this); From 10936265399bd060318ba432db6cf1dcac5342ce Mon Sep 17 00:00:00 2001 From: corymhall <43035978+corymhall@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:21:45 -0500 Subject: [PATCH 2/3] removing unused import --- src/stack.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stack.ts b/src/stack.ts index e538ac57..859e1078 100644 --- a/src/stack.ts +++ b/src/stack.ts @@ -17,7 +17,6 @@ import { AppComponent, AppOptions, AppResourceOptions } from './types'; import { AppConverter, StackConverter } from './converters/app-converter'; import { PulumiSynthesizer, PulumiSynthesizerBase } from './synthesizer'; import { AwsCdkCli, ICloudAssemblyDirectoryProducer } from '@aws-cdk/cli-lib-alpha'; -import { error } from '@pulumi/pulumi/log'; import { CdkConstruct } from './interop'; export type AppOutputs = { [outputId: string]: pulumi.Output }; From 3d208d9b1aded8542eefd5c2e40af504efd28bbe Mon Sep 17 00:00:00 2001 From: corymhall <43035978+corymhall@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:14:26 -0500 Subject: [PATCH 3/3] update aws-native dependency --- examples/alb/package.json | 2 +- examples/api-websocket-lambda-dynamodb/package.json | 2 +- examples/apprunner/package.json | 2 +- examples/appsvc/package.json | 2 +- examples/cloudfront-lambda-urls/package.json | 2 +- examples/cron-lambda/package.json | 2 +- examples/ec2-instance/package.json | 2 +- examples/ecscluster/package.json | 2 +- examples/eventbridge-atm/package.json | 2 +- examples/eventbridge-sns/package.json | 2 +- examples/fargate/package.json | 2 +- examples/lookups/package.json | 2 +- examples/s3-object-lambda/package.json | 2 +- examples/scalable-webhook/package.json | 2 +- examples/the-big-fan/package.json | 2 +- integration/apigateway-domain/package.json | 2 +- integration/apigateway/package.json | 2 +- integration/cloudfront/package.json | 2 +- integration/ec2/package.json | 2 +- integration/errors-test/package.json | 2 +- integration/kms/package.json | 2 +- integration/logs/package.json | 2 +- integration/misc-services/package.json | 2 +- integration/route53/package.json | 2 +- integration/secretsmanager/package.json | 2 +- package.json | 4 ++-- yarn.lock | 8 ++++---- 27 files changed, 31 insertions(+), 31 deletions(-) diff --git a/examples/alb/package.json b/examples/alb/package.json index 3ab75a7f..e5403e2a 100644 --- a/examples/alb/package.json +++ b/examples/alb/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0", diff --git a/examples/api-websocket-lambda-dynamodb/package.json b/examples/api-websocket-lambda-dynamodb/package.json index 6fdfc1bb..11f857f7 100644 --- a/examples/api-websocket-lambda-dynamodb/package.json +++ b/examples/api-websocket-lambda-dynamodb/package.json @@ -8,7 +8,7 @@ "@aws-sdk/client-dynamodb": "^3.632.0", "@aws-sdk/lib-dynamodb": "^3.632.0", "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/examples/apprunner/package.json b/examples/apprunner/package.json index 04e2065d..7b80aff5 100644 --- a/examples/apprunner/package.json +++ b/examples/apprunner/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0", diff --git a/examples/appsvc/package.json b/examples/appsvc/package.json index 87bc0525..a970e7eb 100644 --- a/examples/appsvc/package.json +++ b/examples/appsvc/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0", diff --git a/examples/cloudfront-lambda-urls/package.json b/examples/cloudfront-lambda-urls/package.json index 36cd4da5..cef6c83c 100644 --- a/examples/cloudfront-lambda-urls/package.json +++ b/examples/cloudfront-lambda-urls/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "@types/aws-lambda": "^8.10.145", diff --git a/examples/cron-lambda/package.json b/examples/cron-lambda/package.json index 5a633bb5..fe8a4cff 100644 --- a/examples/cron-lambda/package.json +++ b/examples/cron-lambda/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0", diff --git a/examples/ec2-instance/package.json b/examples/ec2-instance/package.json index 87bc0525..a970e7eb 100644 --- a/examples/ec2-instance/package.json +++ b/examples/ec2-instance/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0", diff --git a/examples/ecscluster/package.json b/examples/ecscluster/package.json index 87bc0525..a970e7eb 100644 --- a/examples/ecscluster/package.json +++ b/examples/ecscluster/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0", diff --git a/examples/eventbridge-atm/package.json b/examples/eventbridge-atm/package.json index 742a9260..57d6a673 100644 --- a/examples/eventbridge-atm/package.json +++ b/examples/eventbridge-atm/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@aws-sdk/client-eventbridge": "^3.678.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "@types/aws-lambda": "^8.10.145", diff --git a/examples/eventbridge-sns/package.json b/examples/eventbridge-sns/package.json index ffc5c758..ccfe4d79 100644 --- a/examples/eventbridge-sns/package.json +++ b/examples/eventbridge-sns/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@aws-sdk/client-eventbridge": "^3.678.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/examples/fargate/package.json b/examples/fargate/package.json index 3ab75a7f..e5403e2a 100644 --- a/examples/fargate/package.json +++ b/examples/fargate/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0", diff --git a/examples/lookups/package.json b/examples/lookups/package.json index c3d51556..915f953a 100644 --- a/examples/lookups/package.json +++ b/examples/lookups/package.json @@ -4,7 +4,7 @@ "@types/node": "^10.0.0" }, "dependencies": { - "@pulumi/aws-native": "^1.0.2", + "@pulumi/aws-native": "^1.7.0", "@pulumi/aws": "^6.0.0", "@pulumi/cdk": "^0.5.0", "aws-cdk-lib": "2.156.0", diff --git a/examples/s3-object-lambda/package.json b/examples/s3-object-lambda/package.json index adff1f12..707514f3 100644 --- a/examples/s3-object-lambda/package.json +++ b/examples/s3-object-lambda/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/cdk": "^0.5.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", "constructs": "10.3.0" diff --git a/examples/scalable-webhook/package.json b/examples/scalable-webhook/package.json index a58d481b..152571e8 100644 --- a/examples/scalable-webhook/package.json +++ b/examples/scalable-webhook/package.json @@ -7,7 +7,7 @@ "@aws-sdk/client-dynamodb": "^3.679.0", "@aws-sdk/client-eventbridge": "^3.678.0", "@aws-sdk/client-sqs": "^3.679.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "@types/aws-lambda": "^8.10.145", diff --git a/examples/the-big-fan/package.json b/examples/the-big-fan/package.json index 029f334a..54c56331 100644 --- a/examples/the-big-fan/package.json +++ b/examples/the-big-fan/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/integration/apigateway-domain/package.json b/integration/apigateway-domain/package.json index 03b52439..a05c7208 100644 --- a/integration/apigateway-domain/package.json +++ b/integration/apigateway-domain/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/integration/apigateway/package.json b/integration/apigateway/package.json index 03b52439..a05c7208 100644 --- a/integration/apigateway/package.json +++ b/integration/apigateway/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.0.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/integration/cloudfront/package.json b/integration/cloudfront/package.json index a8bf49ff..a05c7208 100644 --- a/integration/cloudfront/package.json +++ b/integration/cloudfront/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.5.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/integration/ec2/package.json b/integration/ec2/package.json index b85571ab..a05c7208 100644 --- a/integration/ec2/package.json +++ b/integration/ec2/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.6.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/integration/errors-test/package.json b/integration/errors-test/package.json index 888282a9..9ca896c2 100644 --- a/integration/errors-test/package.json +++ b/integration/errors-test/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.5.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.149.0", diff --git a/integration/kms/package.json b/integration/kms/package.json index a8bf49ff..a05c7208 100644 --- a/integration/kms/package.json +++ b/integration/kms/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.5.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/integration/logs/package.json b/integration/logs/package.json index 888282a9..9ca896c2 100644 --- a/integration/logs/package.json +++ b/integration/logs/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.5.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.149.0", diff --git a/integration/misc-services/package.json b/integration/misc-services/package.json index 888282a9..9ca896c2 100644 --- a/integration/misc-services/package.json +++ b/integration/misc-services/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.5.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.149.0", diff --git a/integration/route53/package.json b/integration/route53/package.json index a8bf49ff..a05c7208 100644 --- a/integration/route53/package.json +++ b/integration/route53/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.0.0", - "@pulumi/aws-native": "^1.5.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.156.0", diff --git a/integration/secretsmanager/package.json b/integration/secretsmanager/package.json index 2637194b..d543cbf0 100644 --- a/integration/secretsmanager/package.json +++ b/integration/secretsmanager/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@pulumi/aws": "^6.56.0", - "@pulumi/aws-native": "^1.5.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/cdk": "^0.5.0", "@pulumi/pulumi": "^3.0.0", "aws-cdk-lib": "2.149.0", diff --git a/package.json b/package.json index 96144f99..61bd4985 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "devDependencies": { "@aws-cdk/aws-apprunner-alpha": "2.20.0-alpha.0", "@pulumi/aws": "^6.56.0", - "@pulumi/aws-native": "^1.6.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/docker": "^4.5.0", "@pulumi/pulumi": "3.136.0", "@types/archiver": "^6.0.2", @@ -51,7 +51,7 @@ }, "peerDependencies": { "@pulumi/aws": "^6.56.0", - "@pulumi/aws-native": "^1.6.0", + "@pulumi/aws-native": "^1.7.0", "@pulumi/docker": "^4.5.0", "@pulumi/pulumi": "^3.136.0", "aws-cdk-lib": "^2.20.0", diff --git a/yarn.lock b/yarn.lock index 5b22a82d..e220841f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1037,10 +1037,10 @@ resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" integrity sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw== -"@pulumi/aws-native@^1.6.0": - version "1.6.0" - resolved "https://registry.yarnpkg.com/@pulumi/aws-native/-/aws-native-1.6.0.tgz#8947829fb7fdcef8ce62fe43082b668068281101" - integrity sha512-7b6CVr8XoprdQCWCnmPDhHe+BGHN2LSk+qpeELp8M2YjcwEu2XkFhI7bAj2UjQLcD84HwPM07baM5f2uryrZxA== +"@pulumi/aws-native@^1.7.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@pulumi/aws-native/-/aws-native-1.7.0.tgz#50f2dec9f97780c22781b1ff419e394b6fffbbb6" + integrity sha512-UDz/TSJPCaez955LoVtCtS3PRfWK4rmUav/Mel697aHPWNSU7u+OnCSyzXsK92gm/wem9ZuncuG57XzhwNUWiA== dependencies: "@pulumi/pulumi" "^3.136.0"