Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

servicecatalog: wrong asset path is generated in case outdir is an absolute path #24392

Closed
bruecktech opened this issue Mar 1, 2023 · 2 comments · Fixed by #24393
Closed
Labels
@aws-cdk/aws-servicecatalog Related to AWS Service Catalog bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@bruecktech
Copy link
Contributor

Describe the bug

When synthesizing a service catalog product stack a wrong assetPath is generated in case outdir is an absolute path

Expected Behavior

stack should get synthesized with no error

Current Behavior

An exception is thrown

Error: Cannot find asset at /Users/johannes.brueck/repos/personio/landing-zone-network/private/var/folders/jj/28bsyn3n6d52nwkpgj3ytzd80000gn/T/cdk.out3XgSAR/asset.400f664767ec04a0966c8d688fa643ee8f6d0c94c8d91a71d3af814cc9b9e6ab

    at new AssetStaging (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/core/lib/asset-staging.js:1:1318)
    at new Asset (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:756)
    at Object.bind (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1220)
    at /Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:2962
    at Array.map (<anonymous>)
    at new BucketDeployment (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:2943)
    at ProductStackSynthesizer.addFileAsset (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-servicecatalog/lib/private/product-stack-synthesizer.js:1:964)
    at new Asset (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-s3-assets/lib/asset.js:1:1223)
    at AssetCode.bind (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-lambda/lib/code.js:1:4648)
    at new Function (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-lambda/lib/function.js:1:2849)
    at SingletonFunction.ensureLambda (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.js:1:2699)
    at new SingletonFunction (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/aws-lambda/lib/singleton-lambda.js:1:687)
    at new AwsCustomResource (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.js:1:3540)
    at /Users/johannes.brueck/repos/personio/landing-zone-network/src/shared-subnet-product-stack.ts:97:13
    at Array.forEach (<anonymous>)
    at new forEach (/Users/johannes.brueck/repos/personio/landing-zone-network/src/shared-subnet-product-stack.ts:96:19)
    at new LandingZoneEventHandler (/Users/johannes.brueck/repos/personio/landing-zone-network/src/constructs/landing-zone-event-handler.ts:41:30)
    at new NetworkStack (/Users/johannes.brueck/repos/personio/landing-zone-network/src/network-stack.ts:64:9)
    at Object.<anonymous> (/Users/johannes.brueck/repos/personio/landing-zone-network/test/network-stack.test.ts:9:23)
    at Promise.then.completed (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/utils.js:293:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/utils.js:226:10)
    at _callCircusTest (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/run.js:248:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at _runTest (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/run.js:184:3)
    at _runTestsForDescribeBlock (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/run.js:86:9)
    at _runTestsForDescribeBlock (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/run.js:81:9)
    at run (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/run.js:26:3)
    at runAndTransformResultsToJestFormat (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:120:21)
    at jestAdapter (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/Users/johannes.brueck/repos/personio/landing-zone-network/node_modules/jest-runner/build/runTest.js:444:34)

Reproduction Steps

write a test like this where NetworkStack contains a service catalog ProductStack that includes assets

describe('Stack', () => {
    test('matches the snapshot', () => {
        const app = new App();
        const stack = new NetworkStack(app, 'NetworkStack', {});
        const template = Template.fromStack(stack);
        expect(template.toJSON()).toMatchSnapshot();
    });
});

Possible Solution

Remove ./ here

Additional Information/Context

No response

CDK CLI Version

2.66.1

Framework Version

No response

Node.js Version

v16.16.0

OS

macOs Ventura

Language

Typescript

Language Version

No response

Other information

No response

@bruecktech bruecktech added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 1, 2023
@github-actions github-actions bot added the @aws-cdk/aws-servicecatalog Related to AWS Service Catalog label Mar 1, 2023
@pahud pahud added p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Mar 1, 2023
@pahud
Copy link
Contributor

pahud commented Mar 1, 2023

Yes this seems to be a bug when outdir is provided as an absolute path. Thank you for your PR.

@mergify mergify bot closed this as completed in #24393 Mar 1, 2023
mergify bot pushed a commit that referenced this issue Mar 1, 2023
…absolute (#24393)

In case we get an absolute path like `/tmp/foobar` then `./` is always prepended which makes the assetPath relative to the current directory.

Fixes #24392

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Mar 1, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

homakk pushed a commit to homakk/aws-cdk that referenced this issue Mar 28, 2023
…absolute (aws#24393)

In case we get an absolute path like `/tmp/foobar` then `./` is always prepended which makes the assetPath relative to the current directory.

Fixes aws#24392

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-servicecatalog Related to AWS Service Catalog bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants