createAssessmentTarget method

Future<CreateAssessmentTargetResponse> createAssessmentTarget({
  1. required String assessmentTargetName,
  2. String? resourceGroupArn,
})

Creates a new assessment target using the ARN of the resource group that is generated by CreateResourceGroup. If resourceGroupArn is not specified, all EC2 instances in the current AWS account and region are included in the assessment target. If the service-linked role isn’t already registered, this action also creates and registers a service-linked role to grant Amazon Inspector access to AWS Services needed to perform security assessments. You can create up to 50 assessment targets per AWS account. You can run up to 500 concurrent agents per AWS account. For more information, see Amazon Inspector Assessment Targets.

May throw InternalException. May throw InvalidInputException. May throw LimitExceededException. May throw AccessDeniedException. May throw NoSuchEntityException. May throw InvalidCrossAccountRoleException. May throw ServiceTemporarilyUnavailableException.

Parameter assessmentTargetName : The user-defined name that identifies the assessment target that you want to create. The name must be unique within the AWS account.

Parameter resourceGroupArn : The ARN that specifies the resource group that is used to create the assessment target. If resourceGroupArn is not specified, all EC2 instances in the current AWS account and region are included in the assessment target.

Implementation

Future<CreateAssessmentTargetResponse> createAssessmentTarget({
  required String assessmentTargetName,
  String? resourceGroupArn,
}) async {
  ArgumentError.checkNotNull(assessmentTargetName, 'assessmentTargetName');
  _s.validateStringLength(
    'assessmentTargetName',
    assessmentTargetName,
    1,
    140,
    isRequired: true,
  );
  _s.validateStringLength(
    'resourceGroupArn',
    resourceGroupArn,
    1,
    300,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'InspectorService.CreateAssessmentTarget'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'assessmentTargetName': assessmentTargetName,
      if (resourceGroupArn != null) 'resourceGroupArn': resourceGroupArn,
    },
  );

  return CreateAssessmentTargetResponse.fromJson(jsonResponse.body);
}