如何对 AWS Config 中的失败修正操作进行问题排查?

2 分钟阅读
0

我已遵循了按照 AWS Config 规则修正不合规 AWS 资源的说明。但修正操作失败,并且 AWS Config 控制台显示操作状态错误“Action execution failed (details)”(操作执行失败 (详细信息))。我打开了 Details (详细信息)页面,但该页面没有足够的信息来排查问题。

解决方法

按照以下说明使用 AWS 命令行界面 (AWS CLI) 或 AWS CloudTrail 事件历史记录对修正操作失败问题进行排查。

注意:如果在运行 AWS CLI 命令时遇到错误,请确保您使用的是最新版本的 AWS CLI

AWS CLI

1.    运行 AWS CLI 命令 describe-remediation-execution-status,获取更详细的错误消息、状态和时间戳,从而获取类似以下内容的修正操作步骤:

aws configservice describe-remediation-execution-status \
     --config-rule-name example-rule \
     --region example-region \
     --resource-keys resourceType=example-resource-type,resourceId=example-resource-ID

**注意:**请将 example-ruleexample-regionexample-resource-typeexample-resource-ID 替换为您的 AWS Config 规则名称、区域、资源类型和资源 ID。

2.    您会收到类似如下内容的输出:

{
    "RemediationExecutionStatuses": [
        {
            "ResourceKey": {
                "resourceType": "AWS::EC2::Volume",
                "resourceId": "vol-0b399a24561582586"
            },
            "State": "FAILED",
            "StepDetails": [
                {
                    "Name": "createDocumentStack",
                    "State": "FAILED",
                    "ErrorMessage": "Automation Step Execution fails when it is creating a CloudFormation stack. 
Get Exception from CreateStack API of cloudformation Service. Exception Message from CreateStack API:
[User: arn:aws:sts::xxxxx:assumed-role/config-remediation-sshpublic-role-zkga0ot3/config-remediation-sshpublic is not authorized to perform: cloudformation:CreateStack 
on resource: arn:aws:cloudformation:eu-west-2:xxxxx:stack/DetachEBSVolumeStack2f6d3590-ea2c-424a-97ea-045749f07164/* 
(Service: AmazonCloudFormation; Status Code: 403; Error Code: AccessDenied; Request ID: b8f41dd6-9020-11e9-897d-f9719db1a9e6)]. 
Please refer to Automation Service Troubleshooting Guide for more diagnosis details.",
                    "StartTime": 1560680582.675,
                    "StopTime": 1560680582.884
                },
                {
                    "Name": "detachVolume",
                    "State": "PENDING"
                },
                {
                    "Name": "deleteCloudFormationTemplate",
                    "State": "PENDING"
                }
            ],
            "InvocationTime": 1560680582.419,
            "LastUpdatedTime": 1560680583.67
        }
    ]
}

3.    在 StepDetails 列表中,记下错误消息和失败原因。

CloudTrail 事件历史记录

1.    打开 AWS CloudTrail 控制台

2.    按照在 CloudTrail 控制台中查看 CloudTrail 事件的说明进行操作。

3.    当 AWS Config 启动修正操作时,系统将调用 StartAutomationExecution API 操作。使用 StartAutomationExecution API 筛选事件名称,然后在事件详细信息页面中复制 requestID

4.    打开 AWS Systems Manager 控制台,然后从导航窗格中选择 Automation (自动化)

5.    将 requestID 粘贴到 Automation document (自动化文档) 搜索字段中。

6.    然后,找到修正执行的操作。验证该错误是否与 AWS Identity and Access Management (IAM) 权限、语法问题或修正操作中配置的参数不正确有关。


相关信息

向 AWS Config 用户授予自定义权限

如何排查 AWS Config 控制台错误消息问题?

查看、更新和删除规则 (AWS CLI)

如何解决在尝试删除 AWS Config 中的修正操作时出现的错误“NoSuchRemediationConfigurationException”或“unexpected internal error”?

相关视频

AWS 官方
AWS 官方已更新 3 年前