-
Notifications
You must be signed in to change notification settings - Fork 4k
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
cli: overrideTemplate is stored in working directory rather than assembly directory (i.e. import does not work) #22928
cli: overrideTemplate is stored in working directory rather than assembly directory (i.e. import does not work) #22928
Comments
Thanks for reporting this @saltman424, I'm unsure what is causing you to run into this. I'm also unable to reproduce this. However, I wonder if it has something to do with the stack being in a stage, or if you're on windows. I'm going to leave this open, it would be really helpful if we have clear reproduction steps if anyone else runs into this in the future. Thanks for the proposed solution by the way, if necessary we can use your suggestion 🙂 |
Experiencing this issue as well, I'm also on Windows 10. Running NodeJS v18.2.0 |
I am also experiencing this issue, running on Amazon Linux 2. CDK version I confirm this only started recently - worked fine ~2 months ago, and without changing anything specific, it's stopped working. My stacktrace below. I tried briefly to use the fix suggested above, but the error references a non-existent
|
@tlrdstd in order to update it in @peterwoodworth is it possible that CDK previously changed the working directory to the assembly directory, but is no longer doing so? |
I ran into this issue as well, though it was the first time using |
I had the same issue as well and the mentioned fix worked for me as well. |
Ran into the same issue. I called it using the following arguments: |
…folder (#29830) ### Issue # (if applicable) Closes #22928 #22530 I'm reopening as the original was closed due to inactivity. ### Reason for this change When the template is synthesized, if it is larger than 50kb and cannot be inlined in the CFN request, CLI writes it to the filesystem to be uploaded to S3. Unlike regular deployments `import` overrides the template, when it does so the code responsible for writing the large template to the filesystem writes to the project root. This code reproduces the issue: ``` import * as cdk from "aws-cdk-lib"; import { Construct } from "constructs"; import * as sqs from "aws-cdk-lib/aws-sqs"; import * as iam from "aws-cdk-lib/aws-iam"; export class AwsCdkImportBugStack extends cdk.Stack { constructor(scope: Construct, id: string, props?: cdk.StackProps) { super(scope, id, props); for (let i = 0; i < 70; i++) { const q = new sqs.Queue(this, `AwsCdkImportBugQueue${i}`, { visibilityTimeout: cdk.Duration.seconds(300), enforceSSL: true, }); } // new sqs.Queue(this, `AwsCdkImportBugQueue`, { // visibilityTimeout: cdk.Duration.seconds(300), // enforceSSL: true, // removalPolicy: cdk.RemovalPolicy.RETAIN, // }); } } ``` Deploy the stack, uncomment the queue, and try to import. This error happens: ``` $ npx cdk import AwsCdkImportBugStack AwsCdkImportBugStack/AwsCdkImportBugQueue/Resource (AWS::SQS::Queue): enter QueueUrl (empty to skip): https://sqs.eu-central-1.amazonaws.com/<cut>/AwsCdkBugStack-keep186A2ECA-IznVNwytuY1b AwsCdkImportBugStack/AwsCdkImportBugQueue/Policy/Resource (AWS::SQS::QueuePolicy): enter Id (empty to skip): Skipping import of AwsCdkImportBugStack/AwsCdkImportBugQueue/Policy/Resource AwsCdkImportBugStack: importing resources into stack... [0%] start: Publishing 06a2c6415fd2982e3285e9d615e5f9b99d1d795a9064479fbe6b88455ac62f6c:current [100%] fail: ENOENT: no such file or directory, open '/home/nburtsev/projects/aws-cdk-import-bug/cdk.out/AwsCdkImportBugStack.template.json-06a2c6415fd2982e3285e9d615e5f9b99d1d795a9064479fbe6b88455ac62f6c.yaml' ❌ AwsCdkImportBugStack failed: Error: Failed to publish one or more assets. See the error messages above for more information. at publishAssets (/home/nburtsev/projects/aws-cdk-import-bug/node_modules/aws-cdk/lib/index.js:420:84876) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async deployStack (/home/nburtsev/projects/aws-cdk-import-bug/node_modules/aws-cdk/lib/index.js:430:391) at async ResourceImporter.importResources (/home/nburtsev/projects/aws-cdk-import-bug/node_modules/aws-cdk/lib/index.js:433:171694) at async ResourceImporter.importResourcesFromMap (/home/nburtsev/projects/aws-cdk-import-bug/node_modules/aws-cdk/lib/index.js:433:171357) at async CdkToolkit.import (/home/nburtsev/projects/aws-cdk-import-bug/node_modules/aws-cdk/lib/index.js:433:205058) at async exec4 (/home/nburtsev/projects/aws-cdk-import-bug/node_modules/aws-cdk/lib/index.js:488:54378) Failed to publish one or more assets. See the error messages above for more information. ``` The file is created, it's just in the project root not in cdk.out: ``` ~/projects/aws-cdk-import-bug $ ls -la total 284 drwxr-xr-x 7 nburtsev users 4096 Mar 22 10:48 . drwxr-xr-x 8 nburtsev users 4096 Mar 22 10:11 .. -rw-r--r-- 1 nburtsev users 64131 Mar 22 10:48 AwsCdkImportBugStack.template.json-06a2c6415fd2982e3285e9d615e5f9b99d1d795a9064479fbe6b88455ac62f6c.yaml drwxr-xr-x 2 nburtsev users 4096 Mar 22 10:12 bin -rw-r--r-- 1 nburtsev users 3185 Mar 22 10:12 cdk.json drwxr-xr-x 2 nburtsev users 4096 Mar 22 10:48 cdk.out <cut> ``` ### Description of changes I've just added a path.join similar to how it is done in regular template generation. ### Description of how you validated changes I've added a test case but I believe tests are broken globally as per @TheRealAmazonKendra ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Describe the bug
Recently, I have had issues using
cdk import
that seem to stem from the overridden template being generated in my working directory rather than the assembly directory. Obviously, whendeploy
tries to use the generated template, it is expecting it to come from my assembly directory. Please see the Possible Solution section below for details.Expected Behavior
cdk import
should work without any issuesCurrent Behavior
Error message from
cdk import
:Note that the
MyStack1234ABCD.template.json-04926632678b4ce87690ab5dff6a51bed012b313a6dbc96b8be43c23aba2a6b1.yaml
file is added to my working directory just before it gets to this stage of the process.Reproduction Steps
I don't have a simple repo to reproduce the issue, but in the Possible Solution section below, I believe I identified the line of code that needs to be updated.
Possible Solution
I believe this line:
aws-cdk/packages/aws-cdk/lib/api/deploy-stack.ts
Line 595 in 8b20446
Should be changed to:
Additional Information/Context
For some reason, I did not used to get this issue. I have been using
cdk import
since shortly after it was released and only recently did I start having issues. I update cdk regularly, so I don't know exactly what version introduced the issue, or if there is something different in my configuration that is causing the issue to surface, but I know that when I go back to 2.46.0 I still have the issue. Also, when I go intonode_modules
and manually update the line mentioned above, everything works as it is supposed to.CDK CLI Version
2.50.0 (build 4c11af6)
Framework Version
2.50.0
Node.js Version
16.15.1
OS
Windows 10 Enterprise
Language
Typescript
Language Version
4.8.4
Other information
No response
The text was updated successfully, but these errors were encountered: