The following code examples show how to use GetComplianceDetailsByResource
.
- AWS CLI
-
To get the evaluation results for an AWS resource
The following command returns the evaluation results for each rule with which the EC2 instance
i-1a2b3c4d
does not comply:aws configservice get-compliance-details-by-resource --resource-type
AWS::EC2::Instance
--resource-idi-1a2b3c4d
--compliance-typesNON_COMPLIANT
Output:
{ "EvaluationResults": [ { "EvaluationResultIdentifier": { "OrderingTimestamp": 1450314635.065, "EvaluationResultQualifier": { "ResourceType": "AWS::EC2::Instance", "ResourceId": "i-1a2b3c4d", "ConfigRuleName": "InstanceTypesAreT2micro" } }, "ResultRecordedTime": 1450314643.288, "ConfigRuleInvokedTime": 1450314643.034, "ComplianceType": "NON_COMPLIANT" }, { "EvaluationResultIdentifier": { "OrderingTimestamp": 1450314635.065, "EvaluationResultQualifier": { "ResourceType": "AWS::EC2::Instance", "ResourceId": "i-1a2b3c4d", "ConfigRuleName": "RequiredTagForEC2Instances" } }, "ResultRecordedTime": 1450314645.261, "ConfigRuleInvokedTime": 1450314642.948, "ComplianceType": "NON_COMPLIANT" } ] }
-
For API details, see GetComplianceDetailsByResource
in AWS CLI Command Reference.
-
For a complete list of AWS SDK developer guides and code examples, see Using AWS Config with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.