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

fix(servicecatalog): wrong asset path is generated in case outdir is absolute #24393

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ProductStackSynthesizer extends cdk.StackSynthesizer {
throw new Error('An Asset Bucket must be provided to use Assets');
}
const outdir = cdk.App.of(this.boundStack)?.outdir ?? 'cdk.out';
const assetPath = `./${outdir}/${asset.fileName}`;
const assetPath = `${outdir}/${asset.fileName}`;
if (!this.bucketDeployment) {
const parentStack = (this.boundStack as ProductStack)._getParentStack();
if (!cdk.Resource.isOwnedResource(this.assetBucket)) {
Expand Down
26 changes: 26 additions & 0 deletions packages/@aws-cdk/aws-servicecatalog/test/product-stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ describe('ProductStack', () => {
});
});

test('Use correct assetPath when outdir is absolute', () => {
// GIVEN
const app = new cdk.App(
{ outdir: '/tmp/foobar' },
);
const mainStack = new cdk.Stack(app, 'MyStackAbsolutePath');
const testAssetBucket = new s3.Bucket(mainStack, 'TestAssetBucket', {
bucketName: 'test-asset-bucket',
});
const productStack = new servicecatalog.ProductStack(mainStack, 'MyProductStackAbsolutePath', {
assetBucket: testAssetBucket,
});

new lambda.Function(productStack, 'HelloHandler', {
runtime: lambda.Runtime.PYTHON_3_9,
code: lambda.Code.fromAsset(path.join(__dirname, 'assets')),
handler: 'index.handler',
});

// WHEN
const assembly = app.synth();

// THEN
expect(assembly.directory).toBe('/tmp/foobar');
});

test('Used defined Asset bucket in product stack with nested assets', () => {
// GIVEN
const app = new cdk.App(
Expand Down