Enables Shield Advanced for a specific Amazon Web Services resource. The resource can be an Amazon CloudFront distribution, Amazon Route 53 hosted zone, Global Accelerator standard accelerator, Elastic IP Address, Application Load Balancer, or a Classic Load Balancer. You can protect Amazon EC2 instances and Network Load Balancers by association with protected Amazon EC2 Elastic IP addresses.
You can add protection to only a single resource with each CreateProtection request. You can add protection to multiple resources at once through the Shield Advanced console at https://console.aws.amazon.com/wafv2/shieldv2#/. For more information see Getting Started with Shield Advanced and Adding Shield Advanced protection to Amazon Web Services resources.
Parameters:
-
name
(ProtectionName)
–
Friendly name for the Protection you are creating.
-
resource_arn
(ResourceArn)
–
The ARN (Amazon Resource Name) of the resource to be protected.
The ARN should be in one of the following formats:
-
For an Application Load Balancer: arn:aws:elasticloadbalancing:region:account-id:loadbalancer/app/load-balancer-name/load-balancer-id
-
For an Elastic Load Balancer (Classic Load Balancer): arn:aws:elasticloadbalancing:region:account-id:loadbalancer/load-balancer-name
-
For an Amazon CloudFront distribution: arn:aws:cloudfront::account-id:distribution/distribution-id
-
For an Global Accelerator standard accelerator: arn:aws:globalaccelerator::account-id:accelerator/accelerator-id
-
For Amazon Route 53: arn:aws:route53:::hostedzone/hosted-zone-id
-
For an Elastic IP address: arn:aws:ec2:region:account-id:eip-allocation/allocation-id
-
tags
(Optional[TagList], default:
None
)
–
One or more tag key-value pairs for the Protection object that is created.
Raises:
-
InternalErrorException
–
Exception that indicates that a problem occurred with the service infrastructure. You can retry the request.
-
InvalidOperationException
–
Exception that indicates that the operation would not cause any change to occur.
-
InvalidParameterException
–
Exception that indicates that the parameters passed to the API are invalid. If available, this exception includes details in additional properties.
-
InvalidResourceException
–
Exception that indicates that the resource is invalid. You might not have access to the resource, or the resource might not exist.
-
LimitsExceededException
–
Exception that indicates that the operation would exceed a limit.
-
OptimisticLockException
–
Exception that indicates that the resource state has been modified by another client. Retrieve the resource and then retry your request.
-
ResourceAlreadyExistsException
–
Exception indicating the specified resource already exists. If available, this exception includes details in additional properties.
-
ResourceNotFoundException
–
Exception indicating the specified resource does not exist. If available, this exception includes details in additional properties.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_shield/_services/shield.py
| def create_protection(
self,
name: "capo_shield.types.protection_name.ProtectionName",
resource_arn: "capo_shield.types.resource_arn.ResourceArn",
*,
config_overrides: Optional[ShieldClientConfig] = None,
tags: Optional["capo_shield.types.tag_list.TagList"] = None,
) -> "capo_shield.types.create_protection_response.CreateProtectionResponse":
"""<p>Enables Shield Advanced for a specific Amazon Web Services resource. The resource can be an Amazon CloudFront distribution, Amazon Route 53 hosted zone, Global Accelerator standard accelerator, Elastic IP Address, Application Load Balancer, or a Classic Load Balancer. You can protect Amazon EC2 instances and Network Load Balancers by association with protected Amazon EC2 Elastic IP addresses.</p> <p>You can add protection to only a single resource with each <code>CreateProtection</code> request. You can add protection to multiple resources at once through the Shield Advanced console at <a href="https://console.aws.amazon.com/wafv2/shieldv2#/">https://console.aws.amazon.com/wafv2/shieldv2#/</a>. For more information see <a href="https://docs.aws.amazon.com/waf/latest/developerguide/getting-started-ddos.html">Getting Started with Shield Advanced</a> and <a href="https://docs.aws.amazon.com/waf/latest/developerguide/configure-new-protection.html">Adding Shield Advanced protection to Amazon Web Services resources</a>.</p>
Args:
name: <p>Friendly name for the <code>Protection</code> you are creating.</p>
resource_arn: <p>The ARN (Amazon Resource Name) of the resource to be protected.</p> <p>The ARN should be in one of the following formats:</p> <ul> <li> <p>For an Application Load Balancer: <code>arn:aws:elasticloadbalancing:<i>region</i>:<i>account-id</i>:loadbalancer/app/<i>load-balancer-name</i>/<i>load-balancer-id</i> </code> </p> </li> <li> <p>For an Elastic Load Balancer (Classic Load Balancer): <code>arn:aws:elasticloadbalancing:<i>region</i>:<i>account-id</i>:loadbalancer/<i>load-balancer-name</i> </code> </p> </li> <li> <p>For an Amazon CloudFront distribution: <code>arn:aws:cloudfront::<i>account-id</i>:distribution/<i>distribution-id</i> </code> </p> </li> <li> <p>For an Global Accelerator standard accelerator: <code>arn:aws:globalaccelerator::<i>account-id</i>:accelerator/<i>accelerator-id</i> </code> </p> </li> <li> <p>For Amazon Route 53: <code>arn:aws:route53:::hostedzone/<i>hosted-zone-id</i> </code> </p> </li> <li> <p>For an Elastic IP address: <code>arn:aws:ec2:<i>region</i>:<i>account-id</i>:eip-allocation/<i>allocation-id</i> </code> </p> </li> </ul>
tags: <p>One or more tag key-value pairs for the <a>Protection</a> object that is created.</p>
Raises:
capo_shield.errors.internal_error_exception.InternalErrorException: <p>Exception that indicates that a problem occurred with the service infrastructure. You can retry the request.</p>
capo_shield.errors.invalid_operation_exception.InvalidOperationException: <p>Exception that indicates that the operation would not cause any change to occur.</p>
capo_shield.errors.invalid_parameter_exception.InvalidParameterException: <p>Exception that indicates that the parameters passed to the API are invalid. If available, this exception includes details in additional properties. </p>
capo_shield.errors.invalid_resource_exception.InvalidResourceException: <p>Exception that indicates that the resource is invalid. You might not have access to the resource, or the resource might not exist.</p>
capo_shield.errors.limits_exceeded_exception.LimitsExceededException: <p>Exception that indicates that the operation would exceed a limit.</p>
capo_shield.errors.optimistic_lock_exception.OptimisticLockException: <p>Exception that indicates that the resource state has been modified by another client. Retrieve the resource and then retry your request.</p>
capo_shield.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>Exception indicating the specified resource already exists. If available, this exception includes details in additional properties. </p>
capo_shield.errors.resource_not_found_exception.ResourceNotFoundException: <p>Exception indicating the specified resource does not exist. If available, this exception includes details in additional properties. </p>
capo_shield.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_shield.types.create_protection_request.CreateProtectionRequest]",
) -> OperationResponse[
"capo_shield.types.create_protection_response.CreateProtectionResponse"
]:
import capo_shield._operations.aws_shield_20160616.create_protection
output, http_response = (
capo_shield._operations.aws_shield_20160616.create_protection.create_protection(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateProtection")
)
input_: capo_shield.types.create_protection_request.CreateProtectionRequest = {
"name": name,
"resource_arn": resource_arn,
}
if tags is not None:
input_["tags"] = tags
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|