1. Packages
  2. AWS Classic
  3. API Docs
  4. shield
  5. Protection

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.13.0 published on Saturday, Dec 2, 2023 by Pulumi

aws.shield.Protection

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.13.0 published on Saturday, Dec 2, 2023 by Pulumi

    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.

    Example Usage

    Create protection

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var available = Aws.GetAvailabilityZones.Invoke();
    
        var currentRegion = Aws.GetRegion.Invoke();
    
        var currentCallerIdentity = Aws.GetCallerIdentity.Invoke();
    
        var exampleEip = new Aws.Ec2.Eip("exampleEip", new()
        {
            Domain = "vpc",
        });
    
        var exampleProtection = new Aws.Shield.Protection("exampleProtection", new()
        {
            ResourceArn = Output.Tuple(currentRegion, currentCallerIdentity, exampleEip.Id).Apply(values =>
            {
                var currentRegion = values.Item1;
                var currentCallerIdentity = values.Item2;
                var id = values.Item3;
                return $"arn:aws:ec2:{currentRegion.Apply(getRegionResult => getRegionResult.Name)}:{currentCallerIdentity.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:eip-allocation/{id}";
            }),
            Tags = 
            {
                { "Environment", "Dev" },
            },
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/shield"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := aws.GetAvailabilityZones(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		currentRegion, err := aws.GetRegion(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		currentCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		exampleEip, err := ec2.NewEip(ctx, "exampleEip", &ec2.EipArgs{
    			Domain: pulumi.String("vpc"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = shield.NewProtection(ctx, "exampleProtection", &shield.ProtectionArgs{
    			ResourceArn: exampleEip.ID().ApplyT(func(id string) (string, error) {
    				return fmt.Sprintf("arn:aws:ec2:%v:%v:eip-allocation/%v", currentRegion.Name, currentCallerIdentity.AccountId, id), nil
    			}).(pulumi.StringOutput),
    			Tags: pulumi.StringMap{
    				"Environment": pulumi.String("Dev"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.AwsFunctions;
    import com.pulumi.aws.inputs.GetAvailabilityZonesArgs;
    import com.pulumi.aws.inputs.GetRegionArgs;
    import com.pulumi.aws.inputs.GetCallerIdentityArgs;
    import com.pulumi.aws.ec2.Eip;
    import com.pulumi.aws.ec2.EipArgs;
    import com.pulumi.aws.shield.Protection;
    import com.pulumi.aws.shield.ProtectionArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var available = AwsFunctions.getAvailabilityZones();
    
            final var currentRegion = AwsFunctions.getRegion();
    
            final var currentCallerIdentity = AwsFunctions.getCallerIdentity();
    
            var exampleEip = new Eip("exampleEip", EipArgs.builder()        
                .domain("vpc")
                .build());
    
            var exampleProtection = new Protection("exampleProtection", ProtectionArgs.builder()        
                .resourceArn(exampleEip.id().applyValue(id -> String.format("arn:aws:ec2:%s:%s:eip-allocation/%s", currentRegion.applyValue(getRegionResult -> getRegionResult.name()),currentCallerIdentity.applyValue(getCallerIdentityResult -> getCallerIdentityResult.accountId()),id)))
                .tags(Map.of("Environment", "Dev"))
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    available = aws.get_availability_zones()
    current_region = aws.get_region()
    current_caller_identity = aws.get_caller_identity()
    example_eip = aws.ec2.Eip("exampleEip", domain="vpc")
    example_protection = aws.shield.Protection("exampleProtection",
        resource_arn=example_eip.id.apply(lambda id: f"arn:aws:ec2:{current_region.name}:{current_caller_identity.account_id}:eip-allocation/{id}"),
        tags={
            "Environment": "Dev",
        })
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const available = aws.getAvailabilityZones({});
    const currentRegion = aws.getRegion({});
    const currentCallerIdentity = aws.getCallerIdentity({});
    const exampleEip = new aws.ec2.Eip("exampleEip", {domain: "vpc"});
    const exampleProtection = new aws.shield.Protection("exampleProtection", {
        resourceArn: pulumi.all([currentRegion, currentCallerIdentity, exampleEip.id]).apply(([currentRegion, currentCallerIdentity, id]) => `arn:aws:ec2:${currentRegion.name}:${currentCallerIdentity.accountId}:eip-allocation/${id}`),
        tags: {
            Environment: "Dev",
        },
    });
    
    resources:
      exampleEip:
        type: aws:ec2:Eip
        properties:
          domain: vpc
      exampleProtection:
        type: aws:shield:Protection
        properties:
          resourceArn: arn:aws:ec2:${currentRegion.name}:${currentCallerIdentity.accountId}:eip-allocation/${exampleEip.id}
          tags:
            Environment: Dev
    variables:
      available:
        fn::invoke:
          Function: aws:getAvailabilityZones
          Arguments: {}
      currentRegion:
        fn::invoke:
          Function: aws:getRegion
          Arguments: {}
      currentCallerIdentity:
        fn::invoke:
          Function: aws:getCallerIdentity
          Arguments: {}
    

    Create Protection Resource

    new Protection(name: string, args: ProtectionArgs, opts?: CustomResourceOptions);
    @overload
    def Protection(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   name: Optional[str] = None,
                   resource_arn: Optional[str] = None,
                   tags: Optional[Mapping[str, str]] = None)
    @overload
    def Protection(resource_name: str,
                   args: ProtectionArgs,
                   opts: Optional[ResourceOptions] = None)
    func NewProtection(ctx *Context, name string, args ProtectionArgs, opts ...ResourceOption) (*Protection, error)
    public Protection(string name, ProtectionArgs args, CustomResourceOptions? opts = null)
    public Protection(String name, ProtectionArgs args)
    public Protection(String name, ProtectionArgs args, CustomResourceOptions options)
    
    type: aws:shield:Protection
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args ProtectionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args ProtectionArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args ProtectionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ProtectionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ProtectionArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Protection Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The Protection resource accepts the following input properties:

    ResourceArn string

    The ARN (Amazon Resource Name) of the resource to be protected.

    Name string

    A friendly name for the Protection you are creating.

    Tags Dictionary<string, string>

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    ResourceArn string

    The ARN (Amazon Resource Name) of the resource to be protected.

    Name string

    A friendly name for the Protection you are creating.

    Tags map[string]string

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    resourceArn String

    The ARN (Amazon Resource Name) of the resource to be protected.

    name String

    A friendly name for the Protection you are creating.

    tags Map<String,String>

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    resourceArn string

    The ARN (Amazon Resource Name) of the resource to be protected.

    name string

    A friendly name for the Protection you are creating.

    tags {[key: string]: string}

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    resource_arn str

    The ARN (Amazon Resource Name) of the resource to be protected.

    name str

    A friendly name for the Protection you are creating.

    tags Mapping[str, str]

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    resourceArn String

    The ARN (Amazon Resource Name) of the resource to be protected.

    name String

    A friendly name for the Protection you are creating.

    tags Map<String>

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Protection resource produces the following output properties:

    Arn string

    The ARN of the Protection.

    Id string

    The provider-assigned unique ID for this managed resource.

    TagsAll Dictionary<string, string>

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    Arn string

    The ARN of the Protection.

    Id string

    The provider-assigned unique ID for this managed resource.

    TagsAll map[string]string

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn String

    The ARN of the Protection.

    id String

    The provider-assigned unique ID for this managed resource.

    tagsAll Map<String,String>

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn string

    The ARN of the Protection.

    id string

    The provider-assigned unique ID for this managed resource.

    tagsAll {[key: string]: string}

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn str

    The ARN of the Protection.

    id str

    The provider-assigned unique ID for this managed resource.

    tags_all Mapping[str, str]

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn String

    The ARN of the Protection.

    id String

    The provider-assigned unique ID for this managed resource.

    tagsAll Map<String>

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    Look up Existing Protection Resource

    Get an existing Protection resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: ProtectionState, opts?: CustomResourceOptions): Protection
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            arn: Optional[str] = None,
            name: Optional[str] = None,
            resource_arn: Optional[str] = None,
            tags: Optional[Mapping[str, str]] = None,
            tags_all: Optional[Mapping[str, str]] = None) -> Protection
    func GetProtection(ctx *Context, name string, id IDInput, state *ProtectionState, opts ...ResourceOption) (*Protection, error)
    public static Protection Get(string name, Input<string> id, ProtectionState? state, CustomResourceOptions? opts = null)
    public static Protection get(String name, Output<String> id, ProtectionState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Arn string

    The ARN of the Protection.

    Name string

    A friendly name for the Protection you are creating.

    ResourceArn string

    The ARN (Amazon Resource Name) of the resource to be protected.

    Tags Dictionary<string, string>

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    TagsAll Dictionary<string, string>

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    Arn string

    The ARN of the Protection.

    Name string

    A friendly name for the Protection you are creating.

    ResourceArn string

    The ARN (Amazon Resource Name) of the resource to be protected.

    Tags map[string]string

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    TagsAll map[string]string

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn String

    The ARN of the Protection.

    name String

    A friendly name for the Protection you are creating.

    resourceArn String

    The ARN (Amazon Resource Name) of the resource to be protected.

    tags Map<String,String>

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    tagsAll Map<String,String>

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn string

    The ARN of the Protection.

    name string

    A friendly name for the Protection you are creating.

    resourceArn string

    The ARN (Amazon Resource Name) of the resource to be protected.

    tags {[key: string]: string}

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    tagsAll {[key: string]: string}

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn str

    The ARN of the Protection.

    name str

    A friendly name for the Protection you are creating.

    resource_arn str

    The ARN (Amazon Resource Name) of the resource to be protected.

    tags Mapping[str, str]

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    tags_all Mapping[str, str]

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    arn String

    The ARN of the Protection.

    name String

    A friendly name for the Protection you are creating.

    resourceArn String

    The ARN (Amazon Resource Name) of the resource to be protected.

    tags Map<String>

    Key-value map of resource tags. .If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.

    tagsAll Map<String>

    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:

    Please use tags instead.

    Import

    Using pulumi import, import Shield protection resources using specifying their ID. For example:

     $ pulumi import aws:shield/protection:Protection example ff9592dc-22f3-4e88-afa1-7b29fde9669a
    

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the aws Terraform Provider.

    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.13.0 published on Saturday, Dec 2, 2023 by Pulumi