Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use GetComplianceDetailsByResource
with an Amazon SDK or CLI
The following code examples show how to use GetComplianceDetailsByResource
.
- CLI
-
- Amazon CLI
-
To get the evaluation results for an Amazon 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-id i-1a2b3c4d
--compliance-types NON_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"
}
]
}
- PowerShell
-
- Tools for PowerShell
-
Example 1: This example evaulation results for the given resource.
Get-CFGComplianceDetailsByResource -ResourceId ABCD5STJ4EFGHIVEW6JAH -ResourceType 'AWS::IAM::User'
Output:
Annotation :
ComplianceType : COMPLIANT
ConfigRuleInvokedTime : 8/25/2019 11:34:56 PM
EvaluationResultIdentifier : Amazon.ConfigService.Model.EvaluationResultIdentifier
ResultRecordedTime : 8/25/2019 11:34:56 PM
ResultToken :
For a complete list of Amazon SDK developer guides and code examples, see
Using Amazon Config with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.