cdklabs / cdklabs/cdk-stacksets
Cannot find asset with NodejsFunction created asset
- Dominant language
- TypeScript
- Stars
- 118
- Forks
- 25
- Avg merge
- 33m
- Merged PRs (30d)
- 4
Description
I trying to deploy a `NodejsFunction` with a stackset but I can't get the file asset to work. I get the following error
> Error: Cannot find asset at /Users/markus/src/awsCore-tagScheduler/infrastructure/cdk.out/assembly-awsCoreTagScheduler-awsCoreTagScheduler-frankfurt-dev/Users/markus/src/awsCore-tagScheduler/infrastructure
It looks like it's adding the asset directory as source to the `bucketDeployment` instead of the asset filename. Can't figure out why though.
## How to reproduce
A simplified example of what I'm trying to accomplish, more or less following the example in the project README.
```typescript
export class TagSchedulerStage extends Stage {
constructor(
scope: Construct,
id: string,
props: StageProps,
) {
super(scope, id, props);
const bucketStack = new Stack(this, 'BucketStack');
const bucket = new s3.Bucket(bucketStack, 'Assets', {
bucketName: 'cdkstacket-asset-bucket-xyz',
});
bucket.addToResourcePolicy(
new iam.PolicyStatement({
actions: ['s3:Get*', 's3:List*'],
resources: [bucket.arnForObjects('*'), bucket.bucketArn],
principals: [new iam.OrganizationPrincipal('ou-ab12')],
}),
);
const stack = new Stack(this, 'TopLevelStack');
const stackSetStack = new StackSetStack(stack, 'MyStackSetStack', {
assetBucket: bucket,
});
new lambdaNodejs.NodejsFunction(
stackSetStack,
'MyLambdaHandler',
{
handler: 'handler',
entry: path.join(__dirname, '../../src/function.ts'),
},
);
new StackSet(stack, 'MyStackSet', {
capabilities: [Capability.IAM],
deploymentType: DeploymentType.serviceManaged(),
target: StackSetTarget.fromAccounts({
regions: ['eu-central-1'],
accounts: ['123456789012'],
}),
template: StackSetTemplate.fromStackSetStack(stackSetStack),
});
}
}
```
Any advice?
Contributor guide
Research direction
Start with the project README example, the src/function.ts entry point, and the synthesized cdk.out assembly named in the error. Trace how the NodejsFunction asset is represented before bucketDeployment consumes it, then reproduce the StackSet deployment. Done means the asset resolves to the generated file rather than the directory and deployment proceeds without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100