1. Packages
  2. AWS
  3. API Docs
  4. shield
  5. Protection
AWS v6.64.0 published on Friday, Dec 6, 2024 by Pulumi

aws.shield.Protection

Explore with Pulumi AI

aws logo
AWS v6.64.0 published on Friday, Dec 6, 2024 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

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const available = aws.getAvailabilityZones({});
    const current = aws.getRegion({});
    const currentGetCallerIdentity = aws.getCallerIdentity({});
    const example = new aws.ec2.Eip("example", {domain: "vpc"});
    const exampleProtection = new aws.shield.Protection("example", {
        name: "example",
        resourceArn: pulumi.all([current, currentGetCallerIdentity, example.id]).apply(([current, currentGetCallerIdentity, id]) => `arn:aws:ec2:${current.name}:${currentGetCallerIdentity.accountId}:eip-allocation/${id}`),
        tags: {
            Environment: "Dev",
        },
    });
    
    import pulumi
    import pulumi_aws as aws
    
    available = aws.get_availability_zones()
    current = aws.get_region()
    current_get_caller_identity = aws.get_caller_identity()
    example = aws.ec2.Eip("example", domain="vpc")
    example_protection = aws.shield.Protection("example",
        name="example",
        resource_arn=example.id.apply(lambda id: f"arn:aws:ec2:{current.name}:{current_get_caller_identity.account_id}: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, &aws.GetAvailabilityZonesArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		current, err := aws.GetRegion(ctx, &aws.GetRegionArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		currentGetCallerIdentity, err := aws.GetCallerIdentity(ctx, &aws.GetCallerIdentityArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		example, err := ec2.NewEip(ctx, "example", &ec2.EipArgs{
    			Domain: pulumi.String("vpc"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = shield.NewProtection(ctx, "example", &shield.ProtectionArgs{
    			Name: pulumi.String("example"),
    			ResourceArn: example.ID().ApplyT(func(id string) (string, error) {
    				return fmt.Sprintf("arn:aws:ec2:%v:%v:eip-allocation/%v", current.Name, currentGetCallerIdentity.AccountId, id), nil
    			}).(pulumi.StringOutput),
    			Tags: pulumi.StringMap{
    				"Environment": pulumi.String("Dev"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var available = Aws.GetAvailabilityZones.Invoke();
    
        var current = Aws.GetRegion.Invoke();
    
        var currentGetCallerIdentity = Aws.GetCallerIdentity.Invoke();
    
        var example = new Aws.Ec2.Eip("example", new()
        {
            Domain = "vpc",
        });
    
        var exampleProtection = new Aws.Shield.Protection("example", new()
        {
            Name = "example",
            ResourceArn = Output.Tuple(current, currentGetCallerIdentity, example.Id).Apply(values =>
            {
                var current = values.Item1;
                var currentGetCallerIdentity = values.Item2;
                var id = values.Item3;
                return $"arn:aws:ec2:{current.Apply(getRegionResult => getRegionResult.Name)}:{currentGetCallerIdentity.Apply(getCallerIdentityResult => getCallerIdentityResult.AccountId)}:eip-allocation/{id}";
            }),
            Tags = 
            {
                { "Environment", "Dev" },
            },
        });
    
    });
    
    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 current = AwsFunctions.getRegion();
    
            final var currentGetCallerIdentity = AwsFunctions.getCallerIdentity();
    
            var example = new Eip("example", EipArgs.builder()
                .domain("vpc")
                .build());
    
            var exampleProtection = new Protection("exampleProtection", ProtectionArgs.builder()
                .name("example")
                .resourceArn(example.id().applyValue(id -> String.format("arn:aws:ec2:%s:%s:eip-allocation/%s", current.applyValue(getRegionResult -> getRegionResult.name()),currentGetCallerIdentity.applyValue(getCallerIdentityResult -> getCallerIdentityResult.accountId()),id)))
                .tags(Map.of("Environment", "Dev"))
                .build());
    
        }
    }
    
    resources:
      example:
        type: aws:ec2:Eip
        properties:
          domain: vpc
      exampleProtection:
        type: aws:shield:Protection
        name: example
        properties:
          name: example
          resourceArn: arn:aws:ec2:${current.name}:${currentGetCallerIdentity.accountId}:eip-allocation/${example.id}
          tags:
            Environment: Dev
    variables:
      available:
        fn::invoke:
          Function: aws:getAvailabilityZones
          Arguments: {}
      current:
        fn::invoke:
          Function: aws:getRegion
          Arguments: {}
      currentGetCallerIdentity:
        fn::invoke:
          Function: aws:getCallerIdentity
          Arguments: {}
    

    Create Protection Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Protection(name: string, args: ProtectionArgs, opts?: CustomResourceOptions);
    @overload
    def Protection(resource_name: str,
                   args: ProtectionArgs,
                   opts: Optional[ResourceOptions] = None)
    
    @overload
    def Protection(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   resource_arn: Optional[str] = None,
                   name: Optional[str] = None,
                   tags: Optional[Mapping[str, str]] = 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.
    
    

    Parameters

    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.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var protectionResource = new Aws.Shield.Protection("protectionResource", new()
    {
        ResourceArn = "string",
        Name = "string",
        Tags = 
        {
            { "string", "string" },
        },
    });
    
    example, err := shield.NewProtection(ctx, "protectionResource", &shield.ProtectionArgs{
    	ResourceArn: pulumi.String("string"),
    	Name:        pulumi.String("string"),
    	Tags: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    })
    
    var protectionResource = new Protection("protectionResource", ProtectionArgs.builder()
        .resourceArn("string")
        .name("string")
        .tags(Map.of("string", "string"))
        .build());
    
    protection_resource = aws.shield.Protection("protectionResource",
        resource_arn="string",
        name="string",
        tags={
            "string": "string",
        })
    
    const protectionResource = new aws.shield.Protection("protectionResource", {
        resourceArn: "string",
        name: "string",
        tags: {
            string: "string",
        },
    });
    
    type: aws:shield:Protection
    properties:
        name: string
        resourceArn: string
        tags:
            string: string
    

    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

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    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
    

    To learn more about importing existing cloud resources, see Importing resources.

    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
    AWS v6.64.0 published on Friday, Dec 6, 2024 by Pulumi