Protection
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 Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var available = Output.Create(Aws.GetAvailabilityZones.InvokeAsync());
var currentRegion = Output.Create(Aws.GetRegion.InvokeAsync());
var currentCallerIdentity = Output.Create(Aws.GetCallerIdentity.InvokeAsync());
var fooEip = new Aws.Ec2.Eip("fooEip", new Aws.Ec2.EipArgs
{
Vpc = true,
});
var fooProtection = new Aws.Shield.Protection("fooProtection", new Aws.Shield.ProtectionArgs
{
ResourceArn = Output.Tuple(currentRegion, currentCallerIdentity, fooEip.Id).Apply(values =>
{
var currentRegion = values.Item1;
var currentCallerIdentity = values.Item2;
var id = values.Item3;
return $"arn:aws:ec2:{currentRegion.Name}:{currentCallerIdentity.AccountId}:eip-allocation/{id}";
}),
});
}
}
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/shield"
"github.com/pulumi/pulumi/sdk/v2/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
}
fooEip, err := ec2.NewEip(ctx, "fooEip", &ec2.EipArgs{
Vpc: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = shield.NewProtection(ctx, "fooProtection", &shield.ProtectionArgs{
ResourceArn: fooEip.ID().ApplyT(func(id string) (string, error) {
return fmt.Sprintf("%v%v%v%v%v%v", "arn:aws:ec2:", currentRegion.Name, ":", currentCallerIdentity.AccountId, ":eip-allocation/", id), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
available = aws.get_availability_zones()
current_region = aws.get_region()
current_caller_identity = aws.get_caller_identity()
foo_eip = aws.ec2.Eip("fooEip", vpc=True)
foo_protection = aws.shield.Protection("fooProtection", resource_arn=foo_eip.id.apply(lambda id: f"arn:aws:ec2:{current_region.name}:{current_caller_identity.account_id}:eip-allocation/{id}"))import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const available = pulumi.output(aws.getAvailabilityZones({ async: true }));
const currentRegion = pulumi.output(aws.getRegion({ async: true }));
const currentCallerIdentity = pulumi.output(aws.getCallerIdentity({ async: true }));
const fooEip = new aws.ec2.Eip("foo", {
vpc: true,
});
const fooProtection = new aws.shield.Protection("foo", {
resourceArn: pulumi.interpolate`arn:aws:ec2:${currentRegion.name!}:${currentCallerIdentity.accountId}:eip-allocation/${fooEip.id}`,
});Create a Protection Resource
new Protection(name: string, args: ProtectionArgs, opts?: CustomResourceOptions);def Protection(resource_name, opts=None, name=None, resource_arn=None, __props__=None);func NewProtection(ctx *Context, name string, args ProtectionArgs, opts ...ResourceOption) (*Protection, error)public Protection(string name, ProtectionArgs args, CustomResourceOptions? opts = null)- 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.
- opts ResourceOptions
- A bag of options that control this 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.
Protection Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The Protection resource accepts the following input properties:
- Resource
Arn string The ARN (Amazon Resource Name) of the resource to be protected.
- Name string
A friendly name for the Protection you are creating.
- Resource
Arn string The ARN (Amazon Resource Name) of the resource to be protected.
- Name string
A friendly name for the Protection you are creating.
- resource
Arn string The ARN (Amazon Resource Name) of the resource to be protected.
- name string
A friendly name for the Protection you are creating.
- 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the Protection resource produces the following output properties:
Look up an 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): Protectionstatic get(resource_name, id, opts=None, name=None, resource_arn=None, __props__=None);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)- 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.
The following state arguments are supported:
- Name string
A friendly name for the Protection you are creating.
- Resource
Arn string The ARN (Amazon Resource Name) of the resource to be protected.
- Name string
A friendly name for the Protection you are creating.
- Resource
Arn string The ARN (Amazon Resource Name) of the resource to be protected.
- name string
A friendly name for the Protection you are creating.
- resource
Arn string The ARN (Amazon Resource Name) of the resource to be protected.
- 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.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.