CreateFilterCommand

Creates a filter resource using specified filter criteria. When the filter action is set to SUPPRESS this action creates a suppression rule.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { Inspector2Client, CreateFilterCommand } from "@aws-sdk/client-inspector2"; // ES Modules import
// const { Inspector2Client, CreateFilterCommand } = require("@aws-sdk/client-inspector2"); // CommonJS import
const client = new Inspector2Client(config);
const input = { // CreateFilterRequest
  action: "STRING_VALUE", // required
  description: "STRING_VALUE",
  filterCriteria: { // FilterCriteria
    findingArn: [ // StringFilterList
      { // StringFilter
        comparison: "STRING_VALUE", // required
        value: "STRING_VALUE", // required
      },
    ],
    awsAccountId: [
      {
        comparison: "STRING_VALUE", // required
        value: "STRING_VALUE", // required
      },
    ],
    findingType: [
      {
        comparison: "STRING_VALUE", // required
        value: "STRING_VALUE", // required
      },
    ],
    severity: [
      {
        comparison: "STRING_VALUE", // required
        value: "STRING_VALUE", // required
      },
    ],
    firstObservedAt: [ // DateFilterList
      { // DateFilter
        startInclusive: new Date("TIMESTAMP"),
        endInclusive: new Date("TIMESTAMP"),
      },
    ],
    lastObservedAt: [
      {
        startInclusive: new Date("TIMESTAMP"),
        endInclusive: new Date("TIMESTAMP"),
      },
    ],
    updatedAt: [
      {
        startInclusive: new Date("TIMESTAMP"),
        endInclusive: new Date("TIMESTAMP"),
      },
    ],
    findingStatus: [
      {
        comparison: "STRING_VALUE", // required
        value: "STRING_VALUE", // required
      },
    ],
    title: "<StringFilterList>",
    inspectorScore: [ // NumberFilterList
      { // NumberFilter
        upperInclusive: Number("double"),
        lowerInclusive: Number("double"),
      },
    ],
    resourceType: "<StringFilterList>",
    resourceId: "<StringFilterList>",
    resourceTags: [ // MapFilterList
      { // MapFilter
        comparison: "STRING_VALUE", // required
        key: "STRING_VALUE", // required
        value: "STRING_VALUE",
      },
    ],
    ec2InstanceImageId: "<StringFilterList>",
    ec2InstanceVpcId: "<StringFilterList>",
    ec2InstanceSubnetId: "<StringFilterList>",
    ecrImagePushedAt: [
      {
        startInclusive: new Date("TIMESTAMP"),
        endInclusive: new Date("TIMESTAMP"),
      },
    ],
    ecrImageArchitecture: "<StringFilterList>",
    ecrImageRegistry: "<StringFilterList>",
    ecrImageRepositoryName: "<StringFilterList>",
    ecrImageTags: "<StringFilterList>",
    ecrImageHash: "<StringFilterList>",
    portRange: [ // PortRangeFilterList
      { // PortRangeFilter
        beginInclusive: Number("int"),
        endInclusive: Number("int"),
      },
    ],
    networkProtocol: "<StringFilterList>",
    componentId: "<StringFilterList>",
    componentType: "<StringFilterList>",
    vulnerabilityId: "<StringFilterList>",
    vulnerabilitySource: "<StringFilterList>",
    vendorSeverity: "<StringFilterList>",
    vulnerablePackages: [ // PackageFilterList
      { // PackageFilter
        name: "<StringFilter>",
        version: "<StringFilter>",
        epoch: {
          upperInclusive: Number("double"),
          lowerInclusive: Number("double"),
        },
        release: "<StringFilter>",
        architecture: "<StringFilter>",
        sourceLayerHash: "<StringFilter>",
        sourceLambdaLayerArn: "<StringFilter>",
        filePath: "<StringFilter>",
      },
    ],
    relatedVulnerabilities: "<StringFilterList>",
    fixAvailable: "<StringFilterList>",
    lambdaFunctionName: "<StringFilterList>",
    lambdaFunctionLayers: "<StringFilterList>",
    lambdaFunctionRuntime: "<StringFilterList>",
    lambdaFunctionLastModifiedAt: [
      {
        startInclusive: new Date("TIMESTAMP"),
        endInclusive: new Date("TIMESTAMP"),
      },
    ],
    lambdaFunctionExecutionRoleArn: "<StringFilterList>",
    exploitAvailable: "<StringFilterList>",
    codeVulnerabilityDetectorName: "<StringFilterList>",
    codeVulnerabilityDetectorTags: "<StringFilterList>",
    codeVulnerabilityFilePath: "<StringFilterList>",
    epssScore: [
      {
        upperInclusive: Number("double"),
        lowerInclusive: Number("double"),
      },
    ],
  },
  name: "STRING_VALUE", // required
  tags: { // TagMap
    "<keys>": "STRING_VALUE",
  },
  reason: "STRING_VALUE",
};
const command = new CreateFilterCommand(input);
const response = await client.send(command);
// { // CreateFilterResponse
//   arn: "STRING_VALUE", // required
// };

CreateFilterCommand Input

See CreateFilterCommandInput for more details

Parameter
Type
Description
action
Required
FilterAction | undefined

Defines the action that is to be applied to the findings that match the filter.

filterCriteria
Required
FilterCriteria | undefined

Defines the criteria to be used in the filter for querying findings.

name
Required
string | undefined

The name of the filter. Minimum length of 3. Maximum length of 64. Valid characters include alphanumeric characters, dot (.), underscore (_), and dash (-). Spaces are not allowed.

description
string | undefined

A description of the filter.

reason
string | undefined

The reason for creating the filter.

tags
Record<string, string> | undefined

A list of tags for the filter.

CreateFilterCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
arn
Required
string | undefined

The Amazon Resource Number (ARN) of the successfully created filter.

Throws

Name
Fault
Details
AccessDeniedException
client

You do not have sufficient access to perform this action.

BadRequestException
client

One or more tags submitted as part of the request is not valid.

InternalServerException
server

The request has failed due to an internal failure of the Amazon Inspector service.

ServiceQuotaExceededException
client

You have exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use Service Quotas to request a service quota increase.

ThrottlingException
client

The limit on the number of requests per second was exceeded.

ValidationException
client

The request has failed validation due to missing required fields or having invalid inputs.

Inspector2ServiceException
Base exception class for all service exceptions from Inspector2 service.