AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2026-02-22 · Documentation low

File: code-library/latest/ug/cli_2_inspector_code_examples.md

Summary

Added comprehensive documentation for Amazon Inspector CLI commands including examples for creating assessment targets/templates, managing findings, configuring filters, generating reports, and handling multi-account setups.

Security assessment

The documentation focuses exclusively on Amazon Inspector, a security vulnerability scanning service. It demonstrates security features like suppression rules for findings, SBOM exports, and multi-account management, but doesn't address any specific vulnerabilities or security incidents.

Diff

diff --git a/code-library/latest/ug/cli_2_inspector_code_examples.md b/code-library/latest/ug/cli_2_inspector_code_examples.md
index 8b1378917..7b8b5860e 100644
--- a//code-library/latest/ug/cli_2_inspector_code_examples.md
+++ b//code-library/latest/ug/cli_2_inspector_code_examples.md
@@ -0,0 +1 @@
+[](/pdfs/code-library/latest/ug/code-example-library.pdf#cli_2_inspector_code_examples "Open PDF")
@@ -1,0 +3,2107 @@
+[Documentation](/index.html)[AWS SDK Code Examples](/code-library/index.html)[Code Library](what-is-code-library.html)
+
+Actions
+
+There are more AWS SDK examples available in the [AWS Doc SDK Examples](https://github.com/awsdocs/aws-doc-sdk-examples) GitHub repo.
+
+# Amazon Inspector examples using AWS CLI
+
+The following code examples show you how to perform actions and implement common scenarios by using the AWS Command Line Interface with Amazon Inspector.
+
+_Actions_ are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
+
+Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
+
+###### Topics
+
+  * Actions
+
+
+
+
+## Actions
+
+The following code example shows how to use `add-attributes-to-findings`.
+
+**AWS CLI**
+    
+
+**To add attributes to findings**
+
+The following `add-attribute-to-finding` command assigns an attribute with the key of `Example` and value of `example` to the finding with the ARN of `arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-8l1VIE0D/run/0-Z02cjjug/finding/0-T8yM9mEU`:
+    
+    
+    aws inspector add-attributes-to-findings --finding-arns arn:aws:inspector:us-west-2:123456789012:target/0-0kFIPusq/template/0-8l1VIE0D/run/0-Z02cjjug/finding/0-T8yM9mEU --attributes key=Example,value=example
+    
+
+Output:
+    
+    
+    {
+        "failedItems": {}
+    }
+
+For more information, see Amazon Inspector Findings in the _Amazon Inspector_ guide.
+
+  * For API details, see [AddAttributesToFindings](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/inspector/add-attributes-to-findings.html) in _AWS CLI Command Reference_. 
+
+
+
+
+The following code example shows how to use `associate-member`.
+
+**AWS CLI**
+    
+
+**Example: To associate an AWS account with an Amazon Inspector delegated administrator**
+
+The following `associate-member` example associates an AWS account with an Amazon Inspector delegated administrator.
+    
+    
+    aws inspector2 associate-member \
+        --account-id 123456789012
+    
+
+Output:
+    
+    
+    {
+        "accountId": "123456789012"
+    }
+
+For more information, see [Managing multiple accounts in Amazon Inspector with AWS Organizations](https://docs.aws.amazon.com/inspector/latest/user/managing-multiple-accounts.html) in the _Amazon Inspector User Guide_.
+
+  * For API details, see [AssociateMember](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/inspector2/associate-member.html) in _AWS CLI Command Reference_. 
+
+
+
+
+The following code example shows how to use `create-assessment-target`.
+
+**AWS CLI**
+    
+
+**To create an assessment target**
+
+The following `create-assessment-target` command creates an assessment target named `ExampleAssessmentTarget` using the resource group with the ARN of `arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-AB6DMKnv`:
+    
+    
+    aws inspector create-assessment-target --assessment-target-name ExampleAssessmentTarget --resource-group-arn arn:aws:inspector:us-west-2:123456789012:resourcegroup/0-AB6DMKnv
+    
+
+Output:
+    
+    
+    {
+        "assessmentTargetArn": "arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX"
+    }
+
+For more information, see Amazon Inspector Assessment Targets in the _Amazon Inspector_ guide.
+
+  * For API details, see [CreateAssessmentTarget](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/inspector/create-assessment-target.html) in _AWS CLI Command Reference_. 
+
+
+
+
+The following code example shows how to use `create-assessment-template`.
+
+**AWS CLI**
+    
+
+**To create an assessment template**
+
+The following `create-assessment-template` command creates an assessment template called `ExampleAssessmentTemplate` for the assessment target with the ARN of `arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX`:
+    
+    
+    aws inspector create-assessment-template --assessment-target-arn arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX --assessment-template-name ExampleAssessmentTemplate --duration-in-seconds 180 --rules-package-arns arn:aws:inspector:us-west-2:758058086616:rulespackage/0-9hgA516p --user-attributes-for-findings key=ExampleTag,value=examplevalue
+    
+
+Output:
+    
+    
+    {
+        "assessmentTemplateArn": "arn:aws:inspector:us-west-2:123456789012:target/0-nvgVhaxX/template/0-it5r2S4T"
+    }
+
+For more information, see Amazon Inspector Assessment Templates and Assessment Runs in the _Amazon Inspector_ guide.
+
+  * For API details, see [CreateAssessmentTemplate](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/inspector/create-assessment-template.html) in _AWS CLI Command Reference_. 
+
+
+
+
+The following code example shows how to use `create-filter`.
+
+**AWS CLI**
+    
+
+**To create a filter**
+
+The following `create-filter` example creates a suppression rule that omits ECR instance type findings.
+    
+    
+    aws inspector2 create-filter \
+        --name "ExampleSuppressionRuleECR" \
+        --description "This suppression rule omits ECR instance type findings" \
+        --action SUPPRESS \
+        --filter-criteria 'resourceType=[{comparison="EQUALS", value="AWS_ECR_INSTANCE"}]'
+    
+
+Output:
+    
+    
+    {
+        "arn": "arn:aws:inspector2:us-west-2:123456789012:owner/o-EXAMPLE222/filter/EXAMPLE444444444"
+    }
+
+For more information, see [Filtering Amazon Inspector findings](https://docs.aws.amazon.com/inspector/latest/user/findings-managing-filtering.html) in the _Amazon Inspector User Guide_.
+
+  * For API details, see [CreateFilter](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/inspector2/create-filter.html) in _AWS CLI Command Reference_. 
+
+
+
+
+The following code example shows how to use `create-findings-report`.
+
+**AWS CLI**
+    
+
+**To create a findings report**
+
+The following `create-findings-report` example creates a finding report.
+    
+    
+    aws inspector2 create-findings-report \
+        --report-format CSV \
+        --s3-destination bucketName=inspector-sbom-123456789012,keyPrefix=sbom-key,kmsKeyArn=arn:aws:kms:us-west-2:123456789012:key/a1b2c3d4-5678-90ab-cdef-EXAMPLE33333 \
+        --filter-criteria '{"ecrImageRepositoryName":[{"comparison":"EQUALS","value":"debian"}]}'
+    
+
+Output:
+    
+    
+    {
+        "reportId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333"
+    }
+
+For more information, see [Managing findings in Amazon Inspector](https://docs.aws.amazon.com/inspector/latest/user/findings-managing.html) in the _Amazon Inspector User Guide_.
+
+  * For API details, see [CreateFindingsReport](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/inspector2/create-findings-report.html) in _AWS CLI Command Reference_. 
+
+
+
+