github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/shield/protection.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package shield 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Enables AWS Shield Advanced for a specific AWS resource. 16 // 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. 17 // 18 // ## Example Usage 19 // 20 // ### Create protection 21 // 22 // <!--Start PulumiCodeChooser --> 23 // ```go 24 // package main 25 // 26 // import ( 27 // 28 // "fmt" 29 // 30 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 31 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 32 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/shield" 33 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 34 // 35 // ) 36 // 37 // func main() { 38 // pulumi.Run(func(ctx *pulumi.Context) error { 39 // _, err := aws.GetAvailabilityZones(ctx, nil, nil) 40 // if err != nil { 41 // return err 42 // } 43 // current, err := aws.GetRegion(ctx, nil, nil) 44 // if err != nil { 45 // return err 46 // } 47 // currentGetCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil) 48 // if err != nil { 49 // return err 50 // } 51 // example, err := ec2.NewEip(ctx, "example", &ec2.EipArgs{ 52 // Domain: pulumi.String("vpc"), 53 // }) 54 // if err != nil { 55 // return err 56 // } 57 // _, err = shield.NewProtection(ctx, "example", &shield.ProtectionArgs{ 58 // Name: pulumi.String("example"), 59 // ResourceArn: example.ID().ApplyT(func(id string) (string, error) { 60 // return fmt.Sprintf("arn:aws:ec2:%v:%v:eip-allocation/%v", current.Name, currentGetCallerIdentity.AccountId, id), nil 61 // }).(pulumi.StringOutput), 62 // Tags: pulumi.StringMap{ 63 // "Environment": pulumi.String("Dev"), 64 // }, 65 // }) 66 // if err != nil { 67 // return err 68 // } 69 // return nil 70 // }) 71 // } 72 // 73 // ``` 74 // <!--End PulumiCodeChooser --> 75 // 76 // ## Import 77 // 78 // Using `pulumi import`, import Shield protection resources using specifying their ID. For example: 79 // 80 // ```sh 81 // $ pulumi import aws:shield/protection:Protection example ff9592dc-22f3-4e88-afa1-7b29fde9669a 82 // ``` 83 type Protection struct { 84 pulumi.CustomResourceState 85 86 // The ARN of the Protection. 87 Arn pulumi.StringOutput `pulumi:"arn"` 88 // A friendly name for the Protection you are creating. 89 Name pulumi.StringOutput `pulumi:"name"` 90 // The ARN (Amazon Resource Name) of the resource to be protected. 91 ResourceArn pulumi.StringOutput `pulumi:"resourceArn"` 92 // Key-value map of resource tags. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 93 Tags pulumi.StringMapOutput `pulumi:"tags"` 94 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 95 // 96 // Deprecated: Please use `tags` instead. 97 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 98 } 99 100 // NewProtection registers a new resource with the given unique name, arguments, and options. 101 func NewProtection(ctx *pulumi.Context, 102 name string, args *ProtectionArgs, opts ...pulumi.ResourceOption) (*Protection, error) { 103 if args == nil { 104 return nil, errors.New("missing one or more required arguments") 105 } 106 107 if args.ResourceArn == nil { 108 return nil, errors.New("invalid value for required argument 'ResourceArn'") 109 } 110 opts = internal.PkgResourceDefaultOpts(opts) 111 var resource Protection 112 err := ctx.RegisterResource("aws:shield/protection:Protection", name, args, &resource, opts...) 113 if err != nil { 114 return nil, err 115 } 116 return &resource, nil 117 } 118 119 // GetProtection gets an existing Protection resource's state with the given name, ID, and optional 120 // state properties that are used to uniquely qualify the lookup (nil if not required). 121 func GetProtection(ctx *pulumi.Context, 122 name string, id pulumi.IDInput, state *ProtectionState, opts ...pulumi.ResourceOption) (*Protection, error) { 123 var resource Protection 124 err := ctx.ReadResource("aws:shield/protection:Protection", name, id, state, &resource, opts...) 125 if err != nil { 126 return nil, err 127 } 128 return &resource, nil 129 } 130 131 // Input properties used for looking up and filtering Protection resources. 132 type protectionState struct { 133 // The ARN of the Protection. 134 Arn *string `pulumi:"arn"` 135 // A friendly name for the Protection you are creating. 136 Name *string `pulumi:"name"` 137 // The ARN (Amazon Resource Name) of the resource to be protected. 138 ResourceArn *string `pulumi:"resourceArn"` 139 // Key-value map of resource tags. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 140 Tags map[string]string `pulumi:"tags"` 141 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 142 // 143 // Deprecated: Please use `tags` instead. 144 TagsAll map[string]string `pulumi:"tagsAll"` 145 } 146 147 type ProtectionState struct { 148 // The ARN of the Protection. 149 Arn pulumi.StringPtrInput 150 // A friendly name for the Protection you are creating. 151 Name pulumi.StringPtrInput 152 // The ARN (Amazon Resource Name) of the resource to be protected. 153 ResourceArn pulumi.StringPtrInput 154 // Key-value map of resource tags. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 155 Tags pulumi.StringMapInput 156 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 157 // 158 // Deprecated: Please use `tags` instead. 159 TagsAll pulumi.StringMapInput 160 } 161 162 func (ProtectionState) ElementType() reflect.Type { 163 return reflect.TypeOf((*protectionState)(nil)).Elem() 164 } 165 166 type protectionArgs struct { 167 // A friendly name for the Protection you are creating. 168 Name *string `pulumi:"name"` 169 // The ARN (Amazon Resource Name) of the resource to be protected. 170 ResourceArn string `pulumi:"resourceArn"` 171 // Key-value map of resource tags. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 172 Tags map[string]string `pulumi:"tags"` 173 } 174 175 // The set of arguments for constructing a Protection resource. 176 type ProtectionArgs struct { 177 // A friendly name for the Protection you are creating. 178 Name pulumi.StringPtrInput 179 // The ARN (Amazon Resource Name) of the resource to be protected. 180 ResourceArn pulumi.StringInput 181 // Key-value map of resource tags. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 182 Tags pulumi.StringMapInput 183 } 184 185 func (ProtectionArgs) ElementType() reflect.Type { 186 return reflect.TypeOf((*protectionArgs)(nil)).Elem() 187 } 188 189 type ProtectionInput interface { 190 pulumi.Input 191 192 ToProtectionOutput() ProtectionOutput 193 ToProtectionOutputWithContext(ctx context.Context) ProtectionOutput 194 } 195 196 func (*Protection) ElementType() reflect.Type { 197 return reflect.TypeOf((**Protection)(nil)).Elem() 198 } 199 200 func (i *Protection) ToProtectionOutput() ProtectionOutput { 201 return i.ToProtectionOutputWithContext(context.Background()) 202 } 203 204 func (i *Protection) ToProtectionOutputWithContext(ctx context.Context) ProtectionOutput { 205 return pulumi.ToOutputWithContext(ctx, i).(ProtectionOutput) 206 } 207 208 // ProtectionArrayInput is an input type that accepts ProtectionArray and ProtectionArrayOutput values. 209 // You can construct a concrete instance of `ProtectionArrayInput` via: 210 // 211 // ProtectionArray{ ProtectionArgs{...} } 212 type ProtectionArrayInput interface { 213 pulumi.Input 214 215 ToProtectionArrayOutput() ProtectionArrayOutput 216 ToProtectionArrayOutputWithContext(context.Context) ProtectionArrayOutput 217 } 218 219 type ProtectionArray []ProtectionInput 220 221 func (ProtectionArray) ElementType() reflect.Type { 222 return reflect.TypeOf((*[]*Protection)(nil)).Elem() 223 } 224 225 func (i ProtectionArray) ToProtectionArrayOutput() ProtectionArrayOutput { 226 return i.ToProtectionArrayOutputWithContext(context.Background()) 227 } 228 229 func (i ProtectionArray) ToProtectionArrayOutputWithContext(ctx context.Context) ProtectionArrayOutput { 230 return pulumi.ToOutputWithContext(ctx, i).(ProtectionArrayOutput) 231 } 232 233 // ProtectionMapInput is an input type that accepts ProtectionMap and ProtectionMapOutput values. 234 // You can construct a concrete instance of `ProtectionMapInput` via: 235 // 236 // ProtectionMap{ "key": ProtectionArgs{...} } 237 type ProtectionMapInput interface { 238 pulumi.Input 239 240 ToProtectionMapOutput() ProtectionMapOutput 241 ToProtectionMapOutputWithContext(context.Context) ProtectionMapOutput 242 } 243 244 type ProtectionMap map[string]ProtectionInput 245 246 func (ProtectionMap) ElementType() reflect.Type { 247 return reflect.TypeOf((*map[string]*Protection)(nil)).Elem() 248 } 249 250 func (i ProtectionMap) ToProtectionMapOutput() ProtectionMapOutput { 251 return i.ToProtectionMapOutputWithContext(context.Background()) 252 } 253 254 func (i ProtectionMap) ToProtectionMapOutputWithContext(ctx context.Context) ProtectionMapOutput { 255 return pulumi.ToOutputWithContext(ctx, i).(ProtectionMapOutput) 256 } 257 258 type ProtectionOutput struct{ *pulumi.OutputState } 259 260 func (ProtectionOutput) ElementType() reflect.Type { 261 return reflect.TypeOf((**Protection)(nil)).Elem() 262 } 263 264 func (o ProtectionOutput) ToProtectionOutput() ProtectionOutput { 265 return o 266 } 267 268 func (o ProtectionOutput) ToProtectionOutputWithContext(ctx context.Context) ProtectionOutput { 269 return o 270 } 271 272 // The ARN of the Protection. 273 func (o ProtectionOutput) Arn() pulumi.StringOutput { 274 return o.ApplyT(func(v *Protection) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 275 } 276 277 // A friendly name for the Protection you are creating. 278 func (o ProtectionOutput) Name() pulumi.StringOutput { 279 return o.ApplyT(func(v *Protection) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput) 280 } 281 282 // The ARN (Amazon Resource Name) of the resource to be protected. 283 func (o ProtectionOutput) ResourceArn() pulumi.StringOutput { 284 return o.ApplyT(func(v *Protection) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput) 285 } 286 287 // Key-value map of resource tags. .If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. 288 func (o ProtectionOutput) Tags() pulumi.StringMapOutput { 289 return o.ApplyT(func(v *Protection) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 290 } 291 292 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 293 // 294 // Deprecated: Please use `tags` instead. 295 func (o ProtectionOutput) TagsAll() pulumi.StringMapOutput { 296 return o.ApplyT(func(v *Protection) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 297 } 298 299 type ProtectionArrayOutput struct{ *pulumi.OutputState } 300 301 func (ProtectionArrayOutput) ElementType() reflect.Type { 302 return reflect.TypeOf((*[]*Protection)(nil)).Elem() 303 } 304 305 func (o ProtectionArrayOutput) ToProtectionArrayOutput() ProtectionArrayOutput { 306 return o 307 } 308 309 func (o ProtectionArrayOutput) ToProtectionArrayOutputWithContext(ctx context.Context) ProtectionArrayOutput { 310 return o 311 } 312 313 func (o ProtectionArrayOutput) Index(i pulumi.IntInput) ProtectionOutput { 314 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Protection { 315 return vs[0].([]*Protection)[vs[1].(int)] 316 }).(ProtectionOutput) 317 } 318 319 type ProtectionMapOutput struct{ *pulumi.OutputState } 320 321 func (ProtectionMapOutput) ElementType() reflect.Type { 322 return reflect.TypeOf((*map[string]*Protection)(nil)).Elem() 323 } 324 325 func (o ProtectionMapOutput) ToProtectionMapOutput() ProtectionMapOutput { 326 return o 327 } 328 329 func (o ProtectionMapOutput) ToProtectionMapOutputWithContext(ctx context.Context) ProtectionMapOutput { 330 return o 331 } 332 333 func (o ProtectionMapOutput) MapIndex(k pulumi.StringInput) ProtectionOutput { 334 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Protection { 335 return vs[0].(map[string]*Protection)[vs[1].(string)] 336 }).(ProtectionOutput) 337 } 338 339 func init() { 340 pulumi.RegisterInputType(reflect.TypeOf((*ProtectionInput)(nil)).Elem(), &Protection{}) 341 pulumi.RegisterInputType(reflect.TypeOf((*ProtectionArrayInput)(nil)).Elem(), ProtectionArray{}) 342 pulumi.RegisterInputType(reflect.TypeOf((*ProtectionMapInput)(nil)).Elem(), ProtectionMap{}) 343 pulumi.RegisterOutputType(ProtectionOutput{}) 344 pulumi.RegisterOutputType(ProtectionArrayOutput{}) 345 pulumi.RegisterOutputType(ProtectionMapOutput{}) 346 }