AWS Shield

2021/03/05 - AWS Shield - 3 new7 updated api methods

Changes  Update shield client to latest version

TagResource (new) Link ¶

Adds or updates tags for a resource in AWS Shield.

See also: AWS API Documentation

Request Syntax

client.tag_resource(
    ResourceARN='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type ResourceARN:

string

param ResourceARN:

[REQUIRED]

The Amazon Resource Name (ARN) of the resource that you want to add or update tags for.

type Tags:

list

param Tags:

[REQUIRED]

The tags that you want to modify or add to the resource.

  • (dict) --

    A tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing or other management. Typically, the tag key represents a category, such as "environment", and the tag value represents a specific value within that category, such as "test," "development," or "production". Or you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.

    • Key (string) --

      Part of the key:value pair that defines a tag. You can use a tag key to describe a category of information, such as "customer." Tag keys are case-sensitive.

    • Value (string) --

      Part of the key:value pair that defines a tag. You can use a tag value to describe a specific value within a category, such as "companyA" or "companyB." Tag values are case-sensitive.

rtype:

dict

returns:

Response Syntax

{}

Response Structure

  • (dict) --

ListTagsForResource (new) Link ¶

Gets information about AWS tags for a specified Amazon Resource Name (ARN) in AWS Shield.

See also: AWS API Documentation

Request Syntax

client.list_tags_for_resource(
    ResourceARN='string'
)
type ResourceARN:

string

param ResourceARN:

[REQUIRED]

The Amazon Resource Name (ARN) of the resource to get tags for.

rtype:

dict

returns:

Response Syntax

{
    'Tags': [
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
}

Response Structure

  • (dict) --

    • Tags (list) --

      A list of tag key and value pairs associated with the specified resource.

      • (dict) --

        A tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing or other management. Typically, the tag key represents a category, such as "environment", and the tag value represents a specific value within that category, such as "test," "development," or "production". Or you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.

        • Key (string) --

          Part of the key:value pair that defines a tag. You can use a tag key to describe a category of information, such as "customer." Tag keys are case-sensitive.

        • Value (string) --

          Part of the key:value pair that defines a tag. You can use a tag value to describe a specific value within a category, such as "companyA" or "companyB." Tag values are case-sensitive.

UntagResource (new) Link ¶

Removes tags from a resource in AWS Shield.

See also: AWS API Documentation

Request Syntax

client.untag_resource(
    ResourceARN='string',
    TagKeys=[
        'string',
    ]
)
type ResourceARN:

string

param ResourceARN:

[REQUIRED]

The Amazon Resource Name (ARN) of the resource that you want to remove tags from.

type TagKeys:

list

param TagKeys:

[REQUIRED]

The tag key for each tag that you want to remove from the resource.

  • (string) --

rtype:

dict

returns:

Response Syntax

{}

Response Structure

  • (dict) --

CreateProtection (updated) Link ¶
Changes (request)
{'Tags': [{'Key': 'string', 'Value': 'string'}]}

Enables AWS Shield Advanced for a specific AWS resource. The resource can be an Amazon CloudFront distribution, Elastic Load Balancing load balancer, AWS Global Accelerator accelerator, Elastic IP Address, or an Amazon Route 53 hosted zone.

You can add protection to only a single resource with each CreateProtection request. If you want to add protection to multiple resources at once, use the AWS WAF console. For more information see Getting Started with AWS Shield Advanced and Add AWS Shield Advanced Protection to more AWS Resources.

See also: AWS API Documentation

Request Syntax

client.create_protection(
    Name='string',
    ResourceArn='string',
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type Name:

string

param Name:

[REQUIRED]

Friendly name for the Protection you are creating.

type ResourceArn:

string

param ResourceArn:

[REQUIRED]

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 AWS CloudFront distribution: arn:aws:cloudfront::account-id:distribution/distribution-id

  • For an AWS Global Accelerator 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

type Tags:

list

param Tags:

One or more tag key-value pairs for the Protection object that is created.

  • (dict) --

    A tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing or other management. Typically, the tag key represents a category, such as "environment", and the tag value represents a specific value within that category, such as "test," "development," or "production". Or you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.

    • Key (string) --

      Part of the key:value pair that defines a tag. You can use a tag key to describe a category of information, such as "customer." Tag keys are case-sensitive.

    • Value (string) --

      Part of the key:value pair that defines a tag. You can use a tag value to describe a specific value within a category, such as "companyA" or "companyB." Tag values are case-sensitive.

rtype:

dict

returns:

Response Syntax

{
    'ProtectionId': 'string'
}

Response Structure

  • (dict) --

    • ProtectionId (string) --

      The unique identifier (ID) for the Protection object that is created.

CreateProtectionGroup (updated) Link ¶
Changes (request)
{'Tags': [{'Key': 'string', 'Value': 'string'}]}

Creates a grouping of protected resources so they can be handled as a collective. This resource grouping improves the accuracy of detection and reduces false positives.

See also: AWS API Documentation

Request Syntax

client.create_protection_group(
    ProtectionGroupId='string',
    Aggregation='SUM'|'MEAN'|'MAX',
    Pattern='ALL'|'ARBITRARY'|'BY_RESOURCE_TYPE',
    ResourceType='CLOUDFRONT_DISTRIBUTION'|'ROUTE_53_HOSTED_ZONE'|'ELASTIC_IP_ALLOCATION'|'CLASSIC_LOAD_BALANCER'|'APPLICATION_LOAD_BALANCER'|'GLOBAL_ACCELERATOR',
    Members=[
        'string',
    ],
    Tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ]
)
type ProtectionGroupId:

string

param ProtectionGroupId:

[REQUIRED]

The name of the protection group. You use this to identify the protection group in lists and to manage the protection group, for example to update, delete, or describe it.

type Aggregation:

string

param Aggregation:

[REQUIRED]

Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events.

  • Sum - Use the total traffic across the group. This is a good choice for most cases. Examples include Elastic IP addresses for EC2 instances that scale manually or automatically.

  • Mean - Use the average of the traffic across the group. This is a good choice for resources that share traffic uniformly. Examples include accelerators and load balancers.

  • Max - Use the highest traffic from each resource. This is useful for resources that don't share traffic and for resources that share that traffic in a non-uniform way. Examples include CloudFront distributions and origin resources for CloudFront distributions.

type Pattern:

string

param Pattern:

[REQUIRED]

The criteria to use to choose the protected resources for inclusion in the group. You can include all resources that have protections, provide a list of resource Amazon Resource Names (ARNs), or include all resources of a specified resource type.

type ResourceType:

string

param ResourceType:

The resource type to include in the protection group. All protected resources of this type are included in the protection group. Newly protected resources of this type are automatically added to the group. You must set this when you set Pattern to BY_RESOURCE_TYPE and you must not set it for any other Pattern setting.

type Members:

list

param Members:

The Amazon Resource Names (ARNs) of the resources to include in the protection group. You must set this when you set Pattern to ARBITRARY and you must not set it for any other Pattern setting.

  • (string) --

type Tags:

list

param Tags:

One or more tag key-value pairs for the protection group.

  • (dict) --

    A tag associated with an AWS resource. Tags are key:value pairs that you can use to categorize and manage your resources, for purposes like billing or other management. Typically, the tag key represents a category, such as "environment", and the tag value represents a specific value within that category, such as "test," "development," or "production". Or you might set the tag key to "customer" and the value to the customer name or ID. You can specify one or more tags to add to each AWS resource, up to 50 tags for a resource.

    • Key (string) --

      Part of the key:value pair that defines a tag. You can use a tag key to describe a category of information, such as "customer." Tag keys are case-sensitive.

    • Value (string) --

      Part of the key:value pair that defines a tag. You can use a tag value to describe a specific value within a category, such as "companyA" or "companyB." Tag values are case-sensitive.

rtype:

dict

returns:

Response Syntax

{}

Response Structure

  • (dict) --

DescribeProtection (updated) Link ¶
Changes (response)
{'Protection': {'ProtectionArn': 'string'}}

Lists the details of a Protection object.

See also: AWS API Documentation

Request Syntax

client.describe_protection(
    ProtectionId='string',
    ResourceArn='string'
)
type ProtectionId:

string

param ProtectionId:

The unique identifier (ID) for the Protection object that is described. When submitting the DescribeProtection request you must provide either the ResourceArn or the ProtectionID, but not both.

type ResourceArn:

string

param ResourceArn:

The ARN (Amazon Resource Name) of the AWS resource for the Protection object that is described. When submitting the DescribeProtection request you must provide either the ResourceArn or the ProtectionID, but not both.

rtype:

dict

returns:

Response Syntax

{
    'Protection': {
        'Id': 'string',
        'Name': 'string',
        'ResourceArn': 'string',
        'HealthCheckIds': [
            'string',
        ],
        'ProtectionArn': 'string'
    }
}

Response Structure

  • (dict) --

    • Protection (dict) --

      The Protection object that is described.

      • Id (string) --

        The unique identifier (ID) of the protection.

      • Name (string) --

        The name of the protection. For example, My CloudFront distributions.

      • ResourceArn (string) --

        The ARN (Amazon Resource Name) of the AWS resource that is protected.

      • HealthCheckIds (list) --

        The unique identifier (ID) for the Route 53 health check that's associated with the protection.

        • (string) --

      • ProtectionArn (string) --

        The ARN (Amazon Resource Name) of the protection.

DescribeProtectionGroup (updated) Link ¶
Changes (response)
{'ProtectionGroup': {'ProtectionGroupArn': 'string'}}

Returns the specification for the specified protection group.

See also: AWS API Documentation

Request Syntax

client.describe_protection_group(
    ProtectionGroupId='string'
)
type ProtectionGroupId:

string

param ProtectionGroupId:

[REQUIRED]

The name of the protection group. You use this to identify the protection group in lists and to manage the protection group, for example to update, delete, or describe it.

rtype:

dict

returns:

Response Syntax

{
    'ProtectionGroup': {
        'ProtectionGroupId': 'string',
        'Aggregation': 'SUM'|'MEAN'|'MAX',
        'Pattern': 'ALL'|'ARBITRARY'|'BY_RESOURCE_TYPE',
        'ResourceType': 'CLOUDFRONT_DISTRIBUTION'|'ROUTE_53_HOSTED_ZONE'|'ELASTIC_IP_ALLOCATION'|'CLASSIC_LOAD_BALANCER'|'APPLICATION_LOAD_BALANCER'|'GLOBAL_ACCELERATOR',
        'Members': [
            'string',
        ],
        'ProtectionGroupArn': 'string'
    }
}

Response Structure

  • (dict) --

    • ProtectionGroup (dict) --

      A grouping of protected resources that you and AWS Shield Advanced can monitor as a collective. This resource grouping improves the accuracy of detection and reduces false positives.

      • ProtectionGroupId (string) --

        The name of the protection group. You use this to identify the protection group in lists and to manage the protection group, for example to update, delete, or describe it.

      • Aggregation (string) --

        Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events.

        • Sum - Use the total traffic across the group. This is a good choice for most cases. Examples include Elastic IP addresses for EC2 instances that scale manually or automatically.

        • Mean - Use the average of the traffic across the group. This is a good choice for resources that share traffic uniformly. Examples include accelerators and load balancers.

        • Max - Use the highest traffic from each resource. This is useful for resources that don't share traffic and for resources that share that traffic in a non-uniform way. Examples include CloudFront distributions and origin resources for CloudFront distributions.

      • Pattern (string) --

        The criteria to use to choose the protected resources for inclusion in the group. You can include all resources that have protections, provide a list of resource Amazon Resource Names (ARNs), or include all resources of a specified resource type.

      • ResourceType (string) --

        The resource type to include in the protection group. All protected resources of this type are included in the protection group. You must set this when you set Pattern to BY_RESOURCE_TYPE and you must not set it for any other Pattern setting.

      • Members (list) --

        The Amazon Resource Names (ARNs) of the resources to include in the protection group. You must set this when you set Pattern to ARBITRARY and you must not set it for any other Pattern setting.

        • (string) --

      • ProtectionGroupArn (string) --

        The ARN (Amazon Resource Name) of the protection group.

DescribeSubscription (updated) Link ¶
Changes (response)
{'Subscription': {'SubscriptionArn': 'string'}}

Provides details about the AWS Shield Advanced subscription for an account.

See also: AWS API Documentation

Request Syntax

client.describe_subscription()
rtype:

dict

returns:

Response Syntax

{
    'Subscription': {
        'StartTime': datetime(2015, 1, 1),
        'EndTime': datetime(2015, 1, 1),
        'TimeCommitmentInSeconds': 123,
        'AutoRenew': 'ENABLED'|'DISABLED',
        'Limits': [
            {
                'Type': 'string',
                'Max': 123
            },
        ],
        'ProactiveEngagementStatus': 'ENABLED'|'DISABLED'|'PENDING',
        'SubscriptionLimits': {
            'ProtectionLimits': {
                'ProtectedResourceTypeLimits': [
                    {
                        'Type': 'string',
                        'Max': 123
                    },
                ]
            },
            'ProtectionGroupLimits': {
                'MaxProtectionGroups': 123,
                'PatternTypeLimits': {
                    'ArbitraryPatternLimits': {
                        'MaxMembers': 123
                    }
                }
            }
        },
        'SubscriptionArn': 'string'
    }
}

Response Structure

  • (dict) --

    • Subscription (dict) --

      The AWS Shield Advanced subscription details for an account.

      • StartTime (datetime) --

        The start time of the subscription, in Unix time in seconds. For more information see timestamp.

      • EndTime (datetime) --

        The date and time your subscription will end.

      • TimeCommitmentInSeconds (integer) --

        The length, in seconds, of the AWS Shield Advanced subscription for the account.

      • AutoRenew (string) --

        If ENABLED, the subscription will be automatically renewed at the end of the existing subscription period.

        When you initally create a subscription, AutoRenew is set to ENABLED. You can change this by submitting an UpdateSubscription request. If the UpdateSubscription request does not included a value for AutoRenew, the existing value for AutoRenew remains unchanged.

      • Limits (list) --

        Specifies how many protections of a given type you can create.

        • (dict) --

          Specifies how many protections of a given type you can create.

          • Type (string) --

            The type of protection.

          • Max (integer) --

            The maximum number of protections that can be created for the specified Type.

      • ProactiveEngagementStatus (string) --

        If ENABLED, the DDoS Response Team (DRT) will use email and phone to notify contacts about escalations to the DRT and to initiate proactive customer support.

        If PENDING, you have requested proactive engagement and the request is pending. The status changes to ENABLED when your request is fully processed.

        If DISABLED, the DRT will not proactively notify contacts about escalations or to initiate proactive customer support.

      • SubscriptionLimits (dict) --

        Limits settings for your subscription.

        • ProtectionLimits (dict) --

          Limits settings on protections for your subscription.

          • ProtectedResourceTypeLimits (list) --

            The maximum number of resource types that you can specify in a protection.

            • (dict) --

              Specifies how many protections of a given type you can create.

              • Type (string) --

                The type of protection.

              • Max (integer) --

                The maximum number of protections that can be created for the specified Type.

        • ProtectionGroupLimits (dict) --

          Limits settings on protection groups for your subscription.

          • MaxProtectionGroups (integer) --

            The maximum number of protection groups that you can have at one time.

          • PatternTypeLimits (dict) --

            Limits settings by pattern type in the protection groups for your subscription.

            • ArbitraryPatternLimits (dict) --

              Limits settings on protection groups with arbitrary pattern type.

              • MaxMembers (integer) --

                The maximum number of resources you can specify for a single arbitrary pattern in a protection group.

      • SubscriptionArn (string) --

        The ARN (Amazon Resource Name) of the subscription.

ListProtectionGroups (updated) Link ¶
Changes (response)
{'ProtectionGroups': {'ProtectionGroupArn': 'string'}}

Retrieves the ProtectionGroup objects for the account.

See also: AWS API Documentation

Request Syntax

client.list_protection_groups(
    NextToken='string',
    MaxResults=123
)
type NextToken:

string

param NextToken:

The next token value from a previous call to ListProtectionGroups. Pass null if this is the first call.

type MaxResults:

integer

param MaxResults:

The maximum number of ProtectionGroup objects to return. If you leave this blank, Shield Advanced returns the first 20 results.

This is a maximum value. Shield Advanced might return the results in smaller batches. That is, the number of objects returned could be less than MaxResults, even if there are still more objects yet to return. If there are more objects to return, Shield Advanced returns a value in NextToken that you can use in your next request, to get the next batch of objects.

rtype:

dict

returns:

Response Syntax

{
    'ProtectionGroups': [
        {
            'ProtectionGroupId': 'string',
            'Aggregation': 'SUM'|'MEAN'|'MAX',
            'Pattern': 'ALL'|'ARBITRARY'|'BY_RESOURCE_TYPE',
            'ResourceType': 'CLOUDFRONT_DISTRIBUTION'|'ROUTE_53_HOSTED_ZONE'|'ELASTIC_IP_ALLOCATION'|'CLASSIC_LOAD_BALANCER'|'APPLICATION_LOAD_BALANCER'|'GLOBAL_ACCELERATOR',
            'Members': [
                'string',
            ],
            'ProtectionGroupArn': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • ProtectionGroups (list) --

      • (dict) --

        A grouping of protected resources that you and AWS Shield Advanced can monitor as a collective. This resource grouping improves the accuracy of detection and reduces false positives.

        • ProtectionGroupId (string) --

          The name of the protection group. You use this to identify the protection group in lists and to manage the protection group, for example to update, delete, or describe it.

        • Aggregation (string) --

          Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events.

          • Sum - Use the total traffic across the group. This is a good choice for most cases. Examples include Elastic IP addresses for EC2 instances that scale manually or automatically.

          • Mean - Use the average of the traffic across the group. This is a good choice for resources that share traffic uniformly. Examples include accelerators and load balancers.

          • Max - Use the highest traffic from each resource. This is useful for resources that don't share traffic and for resources that share that traffic in a non-uniform way. Examples include CloudFront distributions and origin resources for CloudFront distributions.

        • Pattern (string) --

          The criteria to use to choose the protected resources for inclusion in the group. You can include all resources that have protections, provide a list of resource Amazon Resource Names (ARNs), or include all resources of a specified resource type.

        • ResourceType (string) --

          The resource type to include in the protection group. All protected resources of this type are included in the protection group. You must set this when you set Pattern to BY_RESOURCE_TYPE and you must not set it for any other Pattern setting.

        • Members (list) --

          The Amazon Resource Names (ARNs) of the resources to include in the protection group. You must set this when you set Pattern to ARBITRARY and you must not set it for any other Pattern setting.

          • (string) --

        • ProtectionGroupArn (string) --

          The ARN (Amazon Resource Name) of the protection group.

    • NextToken (string) --

      If you specify a value for MaxResults and you have more protection groups than the value of MaxResults, AWS Shield Advanced returns this token that you can use in your next request, to get the next batch of objects.

ListProtections (updated) Link ¶
Changes (response)
{'Protections': {'ProtectionArn': 'string'}}

Lists all Protection objects for the account.

See also: AWS API Documentation

Request Syntax

client.list_protections(
    NextToken='string',
    MaxResults=123
)
type NextToken:

string

param NextToken:

The ListProtectionsRequest.NextToken value from a previous call to ListProtections. Pass null if this is the first call.

type MaxResults:

integer

param MaxResults:

The maximum number of Protection objects to return. If you leave this blank, Shield Advanced returns the first 20 results.

This is a maximum value. Shield Advanced might return the results in smaller batches. That is, the number of objects returned could be less than MaxResults, even if there are still more objects yet to return. If there are more objects to return, Shield Advanced returns a value in NextToken that you can use in your next request, to get the next batch of objects.

rtype:

dict

returns:

Response Syntax

{
    'Protections': [
        {
            'Id': 'string',
            'Name': 'string',
            'ResourceArn': 'string',
            'HealthCheckIds': [
                'string',
            ],
            'ProtectionArn': 'string'
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) --

    • Protections (list) --

      The array of enabled Protection objects.

      • (dict) --

        An object that represents a resource that is under DDoS protection.

        • Id (string) --

          The unique identifier (ID) of the protection.

        • Name (string) --

          The name of the protection. For example, My CloudFront distributions.

        • ResourceArn (string) --

          The ARN (Amazon Resource Name) of the AWS resource that is protected.

        • HealthCheckIds (list) --

          The unique identifier (ID) for the Route 53 health check that's associated with the protection.

          • (string) --

        • ProtectionArn (string) --

          The ARN (Amazon Resource Name) of the protection.

    • NextToken (string) --

      If you specify a value for MaxResults and you have more Protections than the value of MaxResults, AWS Shield Advanced returns a NextToken value in the response that allows you to list another group of Protections. For the second and subsequent ListProtections requests, specify the value of NextToken from the previous response to get information about another batch of Protections.

      Shield Advanced might return the list of Protection objects in batches smaller than the number specified by MaxResults. If there are more Protection objects to return, Shield Advanced will always also return a NextToken.