Creates an assessment template for the assessment target that is specified by the ARN of 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.
Parameters:
-
assessment_target_arn
(Arn)
–
The ARN that specifies the assessment target for which you want to create the assessment template.
-
assessment_template_name
(AssessmentTemplateName)
–
The user-defined name that identifies the assessment template that you want to create. You can create several assessment templates for an assessment target. The names of the assessment templates that correspond to a particular assessment target must be unique.
-
duration_in_seconds
(AssessmentRunDuration)
–
The duration of the assessment run in seconds.
-
rules_package_arns
(AssessmentTemplateRulesPackageArnList)
–
The ARNs that specify the rules packages that you want to attach to the assessment template.
-
user_attributes_for_findings
(Optional[UserAttributeList], default:
None
)
–
The user-defined attributes that are assigned to every finding that is generated by the assessment run that uses this assessment template. An attribute is a key and value pair (an Attribute object). Within an assessment template, each key must be unique.
Raises:
Examples:
Create assessment template
Creates an assessment template for the assessment target that is specified by the ARN of the assessment target.
>>> await client.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-11B9DBXp'], user_attributes_for_findings=[{'key': 'Example', 'value': 'example'}])
Source code in docs_src/capo_inspector/_services/async_inspector.py
| async def create_assessment_template(
self,
assessment_target_arn: "capo_inspector.types.arn.Arn",
assessment_template_name: "capo_inspector.types.assessment_template_name.AssessmentTemplateName",
duration_in_seconds: "capo_inspector.types.assessment_run_duration.AssessmentRunDuration",
rules_package_arns: "capo_inspector.types.assessment_template_rules_package_arn_list.AssessmentTemplateRulesPackageArnList",
*,
config_overrides: Optional[AsyncInspectorClientConfig] = None,
user_attributes_for_findings: Optional[
"capo_inspector.types.user_attribute_list.UserAttributeList"
] = None,
) -> "capo_inspector.types.create_assessment_template_response.CreateAssessmentTemplateResponse":
"""<p>Creates an assessment template for the assessment target that is specified by the ARN of the assessment target. If the <a href="https://docs.aws.amazon.com/inspector/latest/userguide/inspector_slr.html">service-linked role</a> 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.</p>
Args:
assessment_target_arn: <p>The ARN that specifies the assessment target for which you want to create the assessment template.</p>
assessment_template_name: <p>The user-defined name that identifies the assessment template that you want to create. You can create several assessment templates for an assessment target. The names of the assessment templates that correspond to a particular assessment target must be unique.</p>
duration_in_seconds: <p>The duration of the assessment run in seconds.</p>
rules_package_arns: <p>The ARNs that specify the rules packages that you want to attach to the assessment template.</p>
user_attributes_for_findings: <p>The user-defined attributes that are assigned to every finding that is generated by the assessment run that uses this assessment template. An attribute is a key and value pair (an <a>Attribute</a> object). Within an assessment template, each key must be unique.</p>
Raises:
capo_inspector.errors.access_denied_exception.AccessDeniedException: <p>You do not have required permissions to access the requested resource.</p>
capo_inspector.errors.internal_exception.InternalException: <p>Internal server error.</p>
capo_inspector.errors.invalid_input_exception.InvalidInputException: <p>The request was rejected because an invalid or out-of-range value was supplied for an input parameter.</p>
capo_inspector.errors.limit_exceeded_exception.LimitExceededException: <p>The request was rejected because it attempted to create resources beyond the current AWS account limits. The error code describes the limit exceeded.</p>
capo_inspector.errors.no_such_entity_exception.NoSuchEntityException: <p>The request was rejected because it referenced an entity that does not exist. The error code describes the entity.</p>
capo_inspector.errors.service_temporarily_unavailable_exception.ServiceTemporarilyUnavailableException: <p>The serice is temporary unavailable.</p>
capo_inspector.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
Create assessment template
Creates an assessment template for the assessment target that is specified by the ARN of the assessment target.
>>> await client.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-11B9DBXp'], user_attributes_for_findings=[{'key': 'Example', 'value': 'example'}])
"""
async def _handler(
req: "AsyncOperationRequest[capo_inspector.types.create_assessment_template_request.CreateAssessmentTemplateRequest]",
) -> AsyncOperationResponse[
"capo_inspector.types.create_assessment_template_response.CreateAssessmentTemplateResponse"
]:
import capo_inspector._operations.inspector_service.create_assessment_template
(
output,
http_response,
) = await capo_inspector._operations.inspector_service.create_assessment_template.async_create_assessment_template(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateAssessmentTemplate")
)
input_: capo_inspector.types.create_assessment_template_request.CreateAssessmentTemplateRequest = {
"assessment_target_arn": assessment_target_arn,
"assessment_template_name": assessment_template_name,
"duration_in_seconds": duration_in_seconds,
"rules_package_arns": rules_package_arns,
}
if user_attributes_for_findings is not None:
input_["user_attributes_for_findings"] = user_attributes_for_findings
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|