cdk deploy --revert-drift fails with "Internal Failure" on "/" map keys
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- aws, typescript
- Lĩnh vực
- cli, cloud, infrastructure
Hướng nghiên cứu
Trace the CLI entry points for cdk deploy --revert-drift, change-set creation, and the generic Cloud Control hotswap path; reproduce the SQS VisibilityTimeout and DynamoDB ReadCapacityUnits cases. Compare them with the Lambda hotswap control, and consider the issue done when both numeric-property cases reconcile successfully while the existing controls continue to work.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
cdk deploy --revert-drift fails at change set creation with a bare CloudFormation Internal Failure when the stack's template has a string-map property that meets both conditions:
- a key contains
/, and - the value references another resource in the stack (
Ref/Fn::GetAtt, including insideFn::Join).
--revert-drift sets DeploymentMode: REVERT_DRIFT on CreateChangeSet, and CloudFormation rejects that change set. The failure doesn't depend on drift: it also happens on a freshly deployed, fully in-sync stack. A plain cdk deploy on the same stack succeeds.
A common real-world trigger is an API Gateway non-proxy integration whose mapping template references another resource. For example, the CDK Workshop's API Gateway → SNS method:
"RequestTemplates": {
"application/json": { "Fn::Join": ["", ["Action=Publish&TopicArn=$util.urlEncode(\"", { "Ref": "HitsFF5AF8CD" }, "\")&Message=$util.urlEncode($input.body)"]] }
}
Users usually hit this right after cdk deploy --hotswap, because the hotswap output tells them to use --revert-drift on the next deployment. The hotswapped resources (SQS VisibilityTimeout, DynamoDB ReadCapacityUnits, etc.) aren't related to the failure.
Regression?
Unknown. --revert-drift is a new feature.
Last known working version
n/a
Expected behavior
cdk deploy --revert-drift creates and executes the change set. On a stack with no drift, it should report no changes.
Current behavior
Repro2002MinimalStack: creating CloudFormation changeset...
Failed to create change set cdk-deploy-change-set:
Repro2002MinimalStack (AWS::CloudFormation::Stack)
Internal Failure
aws cloudformation describe-change-set returns Status: FAILED, StatusReason: Internal Failure, DeploymentMode: REVERT_DRIFT, and no changes.
Reproduction steps
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as sns from 'aws-cdk-lib/aws-sns';
import * as ssm from 'aws-cdk-lib/aws-ssm';
export class Repro2002MinimalStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const topic = new sns.Topic(this, 'Topic');
new ssm.CfnParameter(this, 'Param', {
type: 'String',
value: 'x',
tags: { 'app/name': topic.topicName }, // '/' in key + resource reference in value
});
}
}
cdk deploy # ✅ succeeds
cdk deploy --revert-drift # ❌ Internal Failure
cdk deploy # ✅ succeeds (no changes)
No hotswap is needed. Controls (each deployed, then run with --revert-drift):
| Tag key | Tag value | --revert-drift |
|---|---|---|
app/name |
topic.topicName |
❌ Internal Failure |
appname |
topic.topicName |
✅ |
app/name |
'static' |
✅ |
The same thing happens when calling CloudFormation directly with this template:
{
"Resources": {
"Topic": { "Type": "AWS::SNS::Topic" },
"Param": {
"Type": "AWS::SSM::Parameter",
"Properties": { "Type": "String", "Value": "x", "Tags": { "app/name": { "Ref": "Topic" } } }
}
}
}
aws cloudformation create-stack --stack-name repro --template-body file://template.json
aws cloudformation create-change-set --stack-name repro --change-set-name rd \
--change-set-type UPDATE --deployment-mode REVERT_DRIFT --template-body file://template.json
# -> Status: FAILED, StatusReason: Internal Failure
Possible solution
This needs a fix on the CloudFormation side. The CLI only passes DeploymentMode: REVERT_DRIFT through to CreateChangeSet.
Unverified hypothesis: during drift-aware change set creation, CloudFormation locates resource references by a property path (for example, a JSON Pointer) without escaping / in map keys. A key like application/json would then be parsed as two path segments.
Possible CLI-side improvement: when a REVERT_DRIFT change set fails with Internal Failure, print a hint suggesting a plain cdk deploy. The hotswap output points users to --revert-drift, and the current error gives no clue that a regular deploy works.
Workaround: use a plain cdk deploy (without --revert-drift) after hotswapping.
Additional information / context
Narrowed down by bisecting a CDK Workshop stack (API Gateway → SNS → SQS → Lambda → DynamoDB):
RequestTemplatesremoved, or replaced with the identical string as a literal: ✅RequestTemplatesvalue is just{ "Ref": topic }, or usesFn::GetAtt: ❌IntegrationResponses[].ResponseTemplates(application/jsonkey) with aRef: ❌RequestParameters(keys have no/) with aGetAtt: ✅Fn::Subwith only pseudo parameters (${AWS::Region}), or a staticFn::Join: ✅- SQS, DynamoDB, Lambda, SNS, and IAM resources on their own: ✅
Reproduced in two accounts: one with a custom bootstrap template (v32) and one with standard cdk bootstrap. The result is the same with and without the CloudFormation execution role, so it isn't related to bootstrap or IAM.
CDK CLI Version
2.1143.0 (build 9c6bd0e)
CDK library version
aws-cdk-lib 2.271.0
Environment details (OS name and version, etc.)
macOS and Linux (AWS Code Editor on EC2), Node.js 24, us-east-1
- Ngôn ngữ chính
- TypeScript
- Star
- 110
- Fork
- 138
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 55
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/aws-cdk-cli
-
aws-cdk bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/aws-cdk-cli#2179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(cli): deploy waits forever when an AWS API call gets no response, because requestTimeout only logs a warningCó thể đã có người làm @abhiramshaji-cyber đã nhận 27 ngày trước. Đang mởaws-cdk bug p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/aws-cdk-cli#2097 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(bootstrap) FilePublishingRoleDefaultPolicy permission incorrect when FileAssetsBucketKmsKeyId is an ARN valueCó thể đã có người làm @lemon0333 đã nhận 95 ngày trước. Đang mởbug p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
aws/aws-cdk-cli#921 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(garbage-collection): cdk gc takes hours on a large bootstrap bucketCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
aws/aws-cdk-cli#2165 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(cli): cdk flags --set always reports no template differences before applying flagsCó thể đã có người làm @go-to-k đã nhận 9 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
aws/aws-cdk-cli#2153 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/aws-cdk-cli
Issue tương tự
-
Diagram: Gantt qa-manually-tested Type: Bug / Error
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
mermaid-js/mermaid-v13#1255 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Name Option For /gifĐang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
BaseAdresseNationale/adresse.data.gouv.fr#2620 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày