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: import should write overrideTemplate to assembly.outdir #29509

Closed
wants to merge 7 commits into from
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ class MigrateStack extends cdk.Stack {
value: queue.node.defaultChild.logicalId,
});
}

if (process.env.LARGE_TEMPLATE) {
for (let i = 0; i < 70; i++) {
const q = new sqs.Queue(this, `cdk-import-queue-test${i}`, {
enforceSSL: true,
});
}
}

if (process.env.SAMPLE_RESOURCES) {
const myTopic = new sns.Topic(this, 'migratetopic1', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ integTest('test resource import', withDefaultFixture(async (fixture) => {

// Initial deploy
await fixture.cdkDeploy('importable-stack', {
modEnv: { ORPHAN_TOPIC: '1' },
modEnv: { ORPHAN_TOPIC: '1', LARGE_TEMPLATE: '1' },
options: ['--outputs-file', outputsFile],
});

Expand All @@ -1442,7 +1442,7 @@ integTest('test resource import', withDefaultFixture(async (fixture) => {
try {
// Deploy again, orphaning the queue
await fixture.cdkDeploy('importable-stack', {
modEnv: { OMIT_TOPIC: '1' },
modEnv: { OMIT_TOPIC: '1', LARGE_TEMPLATE: '1' },
});

// Write a resource mapping file based on the ID from step one, then run an import
Expand Down
4 changes: 3 additions & 1 deletion packages/aws-cdk/lib/api/util/template-body-parameter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from 'path';
import * as cxapi from '@aws-cdk/cx-api';
import * as chalk from 'chalk';
import * as fs from 'fs-extra';
Expand Down Expand Up @@ -68,7 +69,8 @@ export async function makeBodyParameter(
if (overrideTemplate) {
// Add a variant of this template
templateFile = `${stack.templateFile}-${templateHash}.yaml`;
await fs.writeFile(templateFile, templateJson, { encoding: 'utf-8' });
const templateFilePath = path.join(stack.assembly.directory, templateFile);
await fs.writeFile(templateFilePath, templateJson, { encoding: 'utf-8' });
}

assetManifest.addFileAsset(templateHash, {
Expand Down
Loading