better-hospital-57959
08/27/2024, 3:53 PMmy-pulumi-project
├── s3.ts
├── index.ts
├── ...
components
└── aws
└── s3
└── PrivateS3BucketV2.ts
The project dir includes the following tsconfig.json
...
"baseUrl": ".",
"paths": {
"*": ["node_modules/*", "../components/*"]
}
},
"include": ["index.ts", "../components/**/*.ts"]
}
And I am importing like this:
import { PrivateS3BucketV2 } from '../components/aws/s3/PrivateS3BucketV2';
Ive not had much luck with this, seeing errors like 13 INTERNAL: Request message serialization failure: b.Va is not a function
. I am somewhat new to Typescript, am I missing something? Does Pulumi support this sort of pattern?little-cartoon-10569
08/27/2024, 9:30 PMlittle-cartoon-10569
08/27/2024, 9:31 PMlittle-cartoon-10569
08/27/2024, 9:32 PMpaths
, that's a convenience thing. Get conveniences working after you've got the full thing right.better-hospital-57959
08/28/2024, 1:48 PMdebug: RegisterResource RPC finished: resource:existing-resource[aws:sns/topic:Topic]; err: Error: 13 INTERNAL: Request message serialization failure: b.Va is not a function, resp: undefined
error: Running program '/Users/me/Repos/x/my-repo/pulumi/base-infra/index.ts' failed with an unhandled exception:
<ref *1> Error: failed to register new resource existing-resource [aws:sns/topic:Topic]: 13 INTERNAL: Request message serialization failure: b.Va is not a function
at Object.registerResource (/Users/me/Repos/x/my-repo/pulumi/base-infra/node_modules/@pulumi/runtime/resource.ts:508:27)
at new Resource (/Users/me/Repos/x/my-repo/pulumi/base-infra/node_modules/@pulumi/resource.ts:557:13)
at new CustomResource (/Users/me/Repos/x/my-repo/pulumi/base-infra/node_modules/@pulumi/resource.ts:1080:9)
at new Topic (/Users/me/Repos/x/my-repo/pulumi/base-infra/node_modules/@pulumi/sns/topic.ts:321:9)
at Object.<anonymous> (/Users/me/Repos/x/my-repo/pulumi/base-infra/sns.ts:8:34)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module.m._compile (/Users/me/Repos/x/my-repo/pulumi/base-infra/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Object.require.extensions.<computed> [as .ts] (/Users/me/Repos/x/my-repo/pulumi/base-infra/node_modules/ts-node/src/index.ts:442:12)
at Module.load (node:internal/modules/cjs/loader:1206:32) {
promise: Promise { <rejected> [Circular *1] }
}
little-cartoon-10569
08/28/2024, 10:43 PMlittle-cartoon-10569
08/28/2024, 10:44 PMbetter-hospital-57959
08/29/2024, 2:09 PMI'm not sure why "existing resources" would be relevantFor more context, the pulumi project I am working in has a set of existing resources, created directly in that project (not component resources). Im noticing some repeated patterns (s3 buckets, etc) that I want to DRY up by writing component resources for. The error above seems to happen for all existing resources, not just the SNS topic or any other specific one, but I can share some more code below. Further troubleshooting, here are some observations; • This issue only happens when the
PrivateS3BucketV2.ts
file is sitting outside of the pulumi project dir. i.e. /components/aws/s3/PrivateS3BucketV2.ts
. If I move this file into the pulumi project dir (/pulumi/my-project/PrivateS3BucketV2.ts
) and import it, everything previews fine.
• I tried to repro this in a separate project, first creating a few resources, then instantiating the PrivateS3BucketV2
component resource, and had no issues. Package versions where the same, the only difference was the method in which I auth'd to AWS (profile instead of OIDC provider). Using a profile with the existing project doesn't seem to change anything.
Ill include a few things below;
• PrivateS3BucketV2.ts
and its package.json
• A set of S3 resources that currently throw the error.
• Sanitized output of pulumi preview -d
better-hospital-57959
08/29/2024, 2:10 PMbetter-hospital-57959
08/29/2024, 2:10 PMbetter-hospital-57959
08/29/2024, 2:11 PMbetter-hospital-57959
08/29/2024, 2:15 PMlittle-cartoon-10569
08/29/2024, 9:42 PMthis.bucket = new aws.s3.BucketV2(
'bucket', // This will be the same for every bucket and will cause a conflict.
{
bucket: args.bucketName,
},
{ parent: this }
);
You need to use the name parameter of the component resource to make the name of the child resource unique.
https://www.pulumi.com/docs/concepts/resources/components/#creating-child-resourceslittle-cartoon-10569
08/29/2024, 9:51 PMcomponents:aws:s3:PrivateS3BucketV2
does not conform to the required <package>:<module>:<type>
format. You want something more like mycompany:aws:privatebucket
.better-hospital-57959
08/29/2024, 9:59 PMlittle-cartoon-10569
08/29/2024, 10:04 PMlittle-cartoon-10569
08/29/2024, 10:06 PMlittle-cartoon-10569
08/29/2024, 10:08 PMthis.registerOutputs({
bucketName: this.bucket.bucket, // this.bucket.bucket is an Output<string>; this.bucket is a BucketV2 object.
});
better-hospital-57959
08/29/2024, 10:18 PMlittle-cartoon-10569
08/29/2024, 10:19 PMOutput<string>
, Output<number>
, etc.better-hospital-57959
08/29/2024, 10:21 PMlittle-cartoon-10569
08/29/2024, 10:21 PMbetter-hospital-57959
08/29/2024, 10:22 PMclever-sunset-76585
09/09/2024, 4:08 AMnode_modules
installed using npm
. Then I ran yarn link ...
to install a local version of the provider I was working on. Once I did that a StackReference
I had in the project broke with a very similar error message, specifically it's the b.Va is not a function
part that I recognized. Of course, in my case I know that under normal conditions (no locally-built provider installed) it works fine so I didn't spend any time debugging it.better-hospital-57959
09/27/2024, 12:58 PM