Ongoing service disruptions
For the most recent update on ongoing service disruptions affecting the AWS Middle East (UAE) Region (ME-CENTRAL-1), refer to the AWS Health Dashboard. For information on AWS Service migration, see How do I migrate my services to another region?
如何解决 CloudFormation 中的更改集错误?
我在尝试将资源导入 AWS CloudFormation 堆栈时收到错误。
解决方法
根据您的错误类型,完成相关部分中的步骤以对错误进行故障排查。
**注意:**如果您在运行 AWS 命令行界面 (AWS CLI) 命令时收到错误,请参阅 AWS CLI 错误故障排除。此外,请确保您使用的是最新版本的 AWS CLI。
修改后的输出错误
两个模板中的 Outputs(输出)部分必须相同。如果您通过 CloudFormation 控制台使用包含输出的资源导入模板创建新堆栈,则会收到与以下内容类似的错误:
"There was an error creating this change set.As part of the import operation, you cannot modify or add [Outputs]"
当您尝试将资源导入堆栈时,也会出现此错误。
要解决此错误,请确保最新 CloudFormation 模板的 Outputs(输出)部分与您的堆栈当前使用的模板相匹配。如果值不相同,请更新最新模板,使其与当前模板 Outputs(输出)部分中的值和输出相匹配。
重要事项:导入操作不能包含对逻辑 ID、描述、值、导出或输出的添加和修改。
导入操作完成后,使用 Outputs(输出)配置中的更改更新堆栈。或者,您可以自动将 AWS 资源导入 CloudFormation 堆栈。
堆栈属性验证错误
如果您使用 AWS CLI 或 AWS SDK 创建包含已修改或已添加堆栈属性的 IMPORT 类型更改集,则会收到与以下内容类似的错误:
"An error occurred (ValidationError) when calling the CreateChangeSet operation: As part of the import operation, you cannot modify or add [Tags]"
当您的 IMPORT 类型更改集包含已修改的堆栈属性时,就会出现此错误。
要解决此错误,请确认更改集创建操作中包含的堆栈属性与堆栈的当前属性值相匹配。
**重要事项:**不要更新或添加任何新的属性值。
导入资源后,另外执行单独的更新操作更新您的属性。或者,您可以自动将 AWS 资源导入 CloudFormation 堆栈。
修改后的资源错误
在导入操作期间,您无法创建、更新或删除资源。如果您在资源导入操作期间修改现有资源,则会收到与以下内容类似的错误:
"There was an error creating this change set.You have modified resources [ResourceName] in your template that are not being imported.Update, create or delete operations cannot be executed during import operations."
要解决此错误,请创建 UPDATE 类型更改集,而非 IMPORT 类型更改集。这会为您显示资源中更改的来源。然后,对现有资源使用相同的资源规范,仅向模板添加要导入的相应资源。或者,您可以自动将 AWS 资源导入 CloudFormation 堆栈。
要导入的资源列表错误
如果您使用 AWS CLI 或 AWS SDK 创建 IMPORT 类型更改集,则会收到以下错误消息之一:
<ResourceName>"An error occurred (ValidationError) when calling the CreateChangeSet operation: Resources [] is missing from ResourceToImport list"
"Error: "An error occurred (ValidationError) when calling the CreateChangeSet operation: Must Provide at least one resource to import""
要解决此错误,请验证您是否在 AWS CLI 命令中向 --resources-to-import 属性传递了物理 ID。或者,对要导入堆栈的资源使用 CreateChangeSet API 中的 ResourceToImport 属性。
要进行导入,必须将物理 ID 传递给新资源。要解决此错误,请验证您是否在 AWS CLI 命令中包含 --resources-to-import,或在 API 调用中包含 ResourceToImport。此外,请务必列出要导入的资源。
IAM 权限错误
如果您的更改集包含您无权访问的 IAM 资源,则会收到以下错误消息之一:
<StackName>"Error: Failed to create changeset for the stack: , ex: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state: For expression "Status" we matched expected path: "FAILED" Status: FAILED.Reason: Requires capabilities: [CAPABILITY_NAMED_IAM]"
"When calling the CreateChangeSet operation: Requires capabilities : [CAPABILITY_IAM/CAPABILITY_NAMED_IAM]"
"Please acknowledge all checkboxes before proceeding."
要解决此错误,请完成以下步骤:
- 打开 CloudFormation 控制台。
- 选择使用现有资源 Create stack(创建堆栈)或 Update stack(更新堆栈)。
- 继续前往 Review(审查)页面,然后选择 I acknowledge that AWS CloudFormation might create IAM resources(我确认 AWS CloudFormation 可能会创建 IAM 资源)/ I acknowledge that AWS CloudFormation might create IAM resources with custom names(我确认 AWS CloudFormation 可能会创建包含自定义名称的 IAM 资源)。
-or-
使用 create-stack 和 update-stack AWS CLI 命令,为 --capabilities 参数指定 CAPABILITY_IAM 或 CAPABILITY_NAMED_IAM 值。
注意:如果您的 CloudFormation 模板包含 AWS Identity and Access Management (IAM) 资源,则必须确认 CAPABILITY_IAM。如果您的模板包含 IAM 资源的自定义名称,则必须确认 CAPABILITY_NAMED_IAM。有关更多信息,请参阅 AWS CloudFormation 部署操作参考的功能部分。
更新堆栈操作期间出现 "Submitted information didn't contain changes" 错误
如果您在更新堆栈操作期间使用相同的堆栈模板,则会收到以下错误消息之一:
"The submitted information didn't contain changes.Submit different information to create a change set"
"An error occurred (ValidationError) when calling the UpdateStack operation: No updates are to be performed."
要解决此错误,请执行以下操作:
- 确认已对堆栈进行更改。CloudFormation 不会将 Parameters(参数)或 Stack Description(堆栈描述)的修改视为对堆栈模板的更改。
- 确保资源有实质性更改。例如,如果您要向堆栈添加描述,则在下次更新堆栈中的其他资源时进行更改。
- 进行实质性更改,例如修改堆栈标签,激活堆栈的更改检测。例如,如果您仅向模板添加描述,则可能会收到错误。但是,如果您在创建更改集的同时修改了堆栈标签,则不会收到错误。
- 向任何资源添加自定义元数据以激活更改。<br id=hardline_break/>
模板示例:
**注意:**请将 MyResourceType 替换为您的资源类型,并将 MyResourceProperties 替换为您的资源属性。Description: This description is the cause of the error when only updating this field. Resources: myResource: Type: MyResourceType Properties: MyResourceProperties Metadata: ### ADD THIS CUSTOM METADATA test: 1 ### ANY KEY-VALUE PAIR
如果您仍然无法更新堆栈,请联系 AWS Support。
ExecuteChangeSet API 调用错误
您不能同时使用 CreateChangeSet API 中的 OnStackFailure 参数和 ExecuteChangeSet API 中的 DisableRollback 参数。
"Either DisableRollback or OnStackFailure can be specified, but not both.Validation error as OnStackFailure parameter was specified during CreateChangeSet."
要解决此错误,请确保不要同时使用这两个参数。
控制台上更改集的输入和格式不匹配错误
如果您在 CloudFormation 模板中使用格式有误的 AWS Secrets Manager 动态引用,则会收到以下错误之一:
"Given input did not match expected format"
"Incorrect format is used in the following SSM reference"
要解决此错误,请确保遵循 Secrets Manager 动态引用的最佳实践。有关更多信息,请参阅使用动态引用获取存储在其他服务中的值。
相关信息
- 语言
- 中文 (简体)
