AWS code-library documentation change
Summary
Complete rewrite of Amazon Inspector CLI code examples documentation. Removed old content and replaced with updated examples covering Inspector v1 and v2 commands including assessment management, finding operations, filters, reports, and organizational features.
Security assessment
The changes document security assessment capabilities of Amazon Inspector but don't reference any specific vulnerability or incident. The examples show routine usage of security features like finding management (add-attributes-to-findings), suppression rules (create-filter), and SBOM exports (create-sbom-export), which are security features but not tied to a specific security issue.
Diff
diff --git a/code-library/latest/ug/cli_2_inspector2_code_examples.md b/code-library/latest/ug/cli_2_inspector2_code_examples.md index e50450a48..8b1378917 100644 --- a//code-library/latest/ug/cli_2_inspector2_code_examples.md +++ b//code-library/latest/ug/cli_2_inspector2_code_examples.md @@ -1 +0,0 @@ -[View a markdown version of this page](cli_2_inspector2_code_examples.md) @@ -3,2109 +1,0 @@ -[](/pdfs/code-library/latest/ug/code-example-library.pdf#cli_2_inspector2_code_examples "Open PDF") - -[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_. - -