-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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): import fails with with 'S3 error: Access Denied #31716
Comments
Reproducible using customer provided code:
References: Didn't dive into root cause as of now. |
I tested this issue using CDK CLI version 2.147.1 and was not able to reproduce it. However after updating to version 2.162.0 I was able to reproduce it, looks like there was a change to the import logic between these versions. |
The last working version in my testing is 2.160.0. This issue started on CDK CLI version 2.161.0. |
This change implemented in 2.161.0 stands out to me as a potential cause for this issue. This change moved where the synthesized template is uploaded from deployment.ts to cloudformation.ts . |
Thanks for the report! I'm looking into it. |
Comments on closed issues and PRs are hard for our team to see. |
1 similar comment
Comments on closed issues and PRs are hard for our team to see. |
In #31597 we changed `cdk diff` to always use the file asset publishing role, instead of direct CLI credentials. This included a refactor that impacted `cdk import`, which was now not uploading the stack template at all anymore. The operation that is now broken only happens in a case with interactive input, which is why this wasn't caught by integ tests. In this change, put the requisite asset-handling code around `makeBodyParameter` to make the asset uploading happen properly. In future PRs: - Add an integration test for `cdk import` which would have exposed the same error. - Refactor the contract of `makeBodyParameter`, and perhaps more around asset uploading, to make the expectations and promises of that function more clear; right now it was not obvious what the function would and wouldn't do for you, which led to this error. I did some refactorings in this PR already (renames, removing an unused argument). I saw an opportunity for more but didn't want to add risk and delay to this patch. Hence, forthcoming 😄 . Closes #31716. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Please add your +1 👍 to let us know you have encountered this
Status: IN-PROGRESS
Overview:
Versions
2.161.0
,2.161.1
and2.162.0
of the CDK CLI will fail with an S3 error when performing an interactivecdk import
.In #31597 we changed cdk diff to always use the file asset publishing role, instead of direct CLI credentials. This included a refactor that impacted cdk import, which was now not uploading the stack template at all anymore. The operation that is now broken only happens in a case with interactive input, which is why this wasn't caught by integ tests.
Complete Error Message:
Workaround:
We are rolling out a fix now. If you are blocked by this, you can temporarily try using an older version of the CDK CLI to perform the import
npx cdk@2.160.0 import ...
Related Issues:
None yet.
Original report
Describe the bug
When using
cdk import
, the command tries to read a template that doesn't exist from the assets bucket.It also returns an uninformative S3 error.
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
I can import without any manual intervention (especially error-prone tinkering with the assets bucket).
Current Behavior
Output of
import --force -v
command:Diff output
If I take the result of
synth
and put it in the bucket with exactly the expected key (52852392599fc7aa03a114e1052f31dc18d35712e91b343b2038748dfa86a257.json
in this case) it works.Reproduction Steps
Just trying to import a table should do it.
Possible Solution
Either don't read the template from S3 as it won't contain the latest version. We can't have a template for importing that's identical to the one deployed, otherwise the resources to import will have been created already.
Or here
aws-cdk/packages/aws-cdk/lib/api/deployments.ts
Lines 429 to 435 in c1b240e
This function is called here
aws-cdk/packages/aws-cdk/lib/import.ts
Line 250 in c1b240e
Additional Information/Context
I know it's not an
Access Denied
error per se as I have full admin access and candiff
/deploy
/etc. It should be a 404 instead of a 403.Also, my lambdas prevent importing because of metadata changes even though they don't appear in the
diff
. Probably related to #31677CDK CLI Version
2.161.1 (build 0a606c9)
Framework Version
No response
Node.js Version
20.17.0
OS
Mac OS
Language
TypeScript
Language Version
5.6.2
Other information
No response
The text was updated successfully, but these errors were encountered: