github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/shield/protectionGroup.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 // Creates a grouping of protected resources so they can be handled as a collective. 16 // This resource grouping improves the accuracy of detection and reduces false positives. For more information see 17 // [Managing AWS Shield Advanced protection groups](https://docs.aws.amazon.com/waf/latest/developerguide/manage-protection-group.html) 18 // 19 // ## Example Usage 20 // 21 // ### Create protection group for all resources 22 // 23 // <!--Start PulumiCodeChooser --> 24 // ```go 25 // package main 26 // 27 // import ( 28 // 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/shield" 30 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 31 // 32 // ) 33 // 34 // func main() { 35 // pulumi.Run(func(ctx *pulumi.Context) error { 36 // _, err := shield.NewProtectionGroup(ctx, "example", &shield.ProtectionGroupArgs{ 37 // ProtectionGroupId: pulumi.String("example"), 38 // Aggregation: pulumi.String("MAX"), 39 // Pattern: pulumi.String("ALL"), 40 // }) 41 // if err != nil { 42 // return err 43 // } 44 // return nil 45 // }) 46 // } 47 // 48 // ``` 49 // <!--End PulumiCodeChooser --> 50 // 51 // ### Create protection group for arbitrary number of resources 52 // 53 // <!--Start PulumiCodeChooser --> 54 // ```go 55 // package main 56 // 57 // import ( 58 // 59 // "fmt" 60 // 61 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 62 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 63 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/shield" 64 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 65 // 66 // ) 67 // 68 // func main() { 69 // pulumi.Run(func(ctx *pulumi.Context) error { 70 // current, err := aws.GetRegion(ctx, nil, nil) 71 // if err != nil { 72 // return err 73 // } 74 // currentGetCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil) 75 // if err != nil { 76 // return err 77 // } 78 // example, err := ec2.NewEip(ctx, "example", &ec2.EipArgs{ 79 // Domain: pulumi.String("vpc"), 80 // }) 81 // if err != nil { 82 // return err 83 // } 84 // exampleProtection, err := shield.NewProtection(ctx, "example", &shield.ProtectionArgs{ 85 // Name: pulumi.String("example"), 86 // ResourceArn: example.ID().ApplyT(func(id string) (string, error) { 87 // return fmt.Sprintf("arn:aws:ec2:%v:%v:eip-allocation/%v", current.Name, currentGetCallerIdentity.AccountId, id), nil 88 // }).(pulumi.StringOutput), 89 // }) 90 // if err != nil { 91 // return err 92 // } 93 // _, err = shield.NewProtectionGroup(ctx, "example", &shield.ProtectionGroupArgs{ 94 // ProtectionGroupId: pulumi.String("example"), 95 // Aggregation: pulumi.String("MEAN"), 96 // Pattern: pulumi.String("ARBITRARY"), 97 // Members: pulumi.StringArray{ 98 // example.ID().ApplyT(func(id string) (string, error) { 99 // return fmt.Sprintf("arn:aws:ec2:%v:%v:eip-allocation/%v", current.Name, currentGetCallerIdentity.AccountId, id), nil 100 // }).(pulumi.StringOutput), 101 // }, 102 // }, pulumi.DependsOn([]pulumi.Resource{ 103 // exampleProtection, 104 // })) 105 // if err != nil { 106 // return err 107 // } 108 // return nil 109 // }) 110 // } 111 // 112 // ``` 113 // <!--End PulumiCodeChooser --> 114 // 115 // ### Create protection group for a type of resource 116 // 117 // <!--Start PulumiCodeChooser --> 118 // ```go 119 // package main 120 // 121 // import ( 122 // 123 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/shield" 124 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 125 // 126 // ) 127 // 128 // func main() { 129 // pulumi.Run(func(ctx *pulumi.Context) error { 130 // _, err := shield.NewProtectionGroup(ctx, "example", &shield.ProtectionGroupArgs{ 131 // ProtectionGroupId: pulumi.String("example"), 132 // Aggregation: pulumi.String("SUM"), 133 // Pattern: pulumi.String("BY_RESOURCE_TYPE"), 134 // ResourceType: pulumi.String("ELASTIC_IP_ALLOCATION"), 135 // }) 136 // if err != nil { 137 // return err 138 // } 139 // return nil 140 // }) 141 // } 142 // 143 // ``` 144 // <!--End PulumiCodeChooser --> 145 // 146 // ## Import 147 // 148 // Using `pulumi import`, import Shield protection group resources using their protection group id. For example: 149 // 150 // ```sh 151 // $ pulumi import aws:shield/protectionGroup:ProtectionGroup example example 152 // ``` 153 type ProtectionGroup struct { 154 pulumi.CustomResourceState 155 156 // Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events. 157 Aggregation pulumi.StringOutput `pulumi:"aggregation"` 158 // 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. 159 Members pulumi.StringArrayOutput `pulumi:"members"` 160 // The criteria to use to choose the protected resources for inclusion in the group. 161 Pattern pulumi.StringOutput `pulumi:"pattern"` 162 // The ARN (Amazon Resource Name) of the protection group. 163 ProtectionGroupArn pulumi.StringOutput `pulumi:"protectionGroupArn"` 164 // The name of the protection group. 165 ProtectionGroupId pulumi.StringOutput `pulumi:"protectionGroupId"` 166 // The resource type to include 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. 167 ResourceType pulumi.StringPtrOutput `pulumi:"resourceType"` 168 // 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. 169 Tags pulumi.StringMapOutput `pulumi:"tags"` 170 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 171 // 172 // Deprecated: Please use `tags` instead. 173 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 174 } 175 176 // NewProtectionGroup registers a new resource with the given unique name, arguments, and options. 177 func NewProtectionGroup(ctx *pulumi.Context, 178 name string, args *ProtectionGroupArgs, opts ...pulumi.ResourceOption) (*ProtectionGroup, error) { 179 if args == nil { 180 return nil, errors.New("missing one or more required arguments") 181 } 182 183 if args.Aggregation == nil { 184 return nil, errors.New("invalid value for required argument 'Aggregation'") 185 } 186 if args.Pattern == nil { 187 return nil, errors.New("invalid value for required argument 'Pattern'") 188 } 189 if args.ProtectionGroupId == nil { 190 return nil, errors.New("invalid value for required argument 'ProtectionGroupId'") 191 } 192 opts = internal.PkgResourceDefaultOpts(opts) 193 var resource ProtectionGroup 194 err := ctx.RegisterResource("aws:shield/protectionGroup:ProtectionGroup", name, args, &resource, opts...) 195 if err != nil { 196 return nil, err 197 } 198 return &resource, nil 199 } 200 201 // GetProtectionGroup gets an existing ProtectionGroup resource's state with the given name, ID, and optional 202 // state properties that are used to uniquely qualify the lookup (nil if not required). 203 func GetProtectionGroup(ctx *pulumi.Context, 204 name string, id pulumi.IDInput, state *ProtectionGroupState, opts ...pulumi.ResourceOption) (*ProtectionGroup, error) { 205 var resource ProtectionGroup 206 err := ctx.ReadResource("aws:shield/protectionGroup:ProtectionGroup", name, id, state, &resource, opts...) 207 if err != nil { 208 return nil, err 209 } 210 return &resource, nil 211 } 212 213 // Input properties used for looking up and filtering ProtectionGroup resources. 214 type protectionGroupState struct { 215 // Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events. 216 Aggregation *string `pulumi:"aggregation"` 217 // 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. 218 Members []string `pulumi:"members"` 219 // The criteria to use to choose the protected resources for inclusion in the group. 220 Pattern *string `pulumi:"pattern"` 221 // The ARN (Amazon Resource Name) of the protection group. 222 ProtectionGroupArn *string `pulumi:"protectionGroupArn"` 223 // The name of the protection group. 224 ProtectionGroupId *string `pulumi:"protectionGroupId"` 225 // The resource type to include 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. 226 ResourceType *string `pulumi:"resourceType"` 227 // 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. 228 Tags map[string]string `pulumi:"tags"` 229 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 230 // 231 // Deprecated: Please use `tags` instead. 232 TagsAll map[string]string `pulumi:"tagsAll"` 233 } 234 235 type ProtectionGroupState struct { 236 // Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events. 237 Aggregation pulumi.StringPtrInput 238 // 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. 239 Members pulumi.StringArrayInput 240 // The criteria to use to choose the protected resources for inclusion in the group. 241 Pattern pulumi.StringPtrInput 242 // The ARN (Amazon Resource Name) of the protection group. 243 ProtectionGroupArn pulumi.StringPtrInput 244 // The name of the protection group. 245 ProtectionGroupId pulumi.StringPtrInput 246 // The resource type to include 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. 247 ResourceType pulumi.StringPtrInput 248 // 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. 249 Tags pulumi.StringMapInput 250 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 251 // 252 // Deprecated: Please use `tags` instead. 253 TagsAll pulumi.StringMapInput 254 } 255 256 func (ProtectionGroupState) ElementType() reflect.Type { 257 return reflect.TypeOf((*protectionGroupState)(nil)).Elem() 258 } 259 260 type protectionGroupArgs struct { 261 // Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events. 262 Aggregation string `pulumi:"aggregation"` 263 // 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. 264 Members []string `pulumi:"members"` 265 // The criteria to use to choose the protected resources for inclusion in the group. 266 Pattern string `pulumi:"pattern"` 267 // The name of the protection group. 268 ProtectionGroupId string `pulumi:"protectionGroupId"` 269 // The resource type to include 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. 270 ResourceType *string `pulumi:"resourceType"` 271 // 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. 272 Tags map[string]string `pulumi:"tags"` 273 } 274 275 // The set of arguments for constructing a ProtectionGroup resource. 276 type ProtectionGroupArgs struct { 277 // Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events. 278 Aggregation pulumi.StringInput 279 // 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. 280 Members pulumi.StringArrayInput 281 // The criteria to use to choose the protected resources for inclusion in the group. 282 Pattern pulumi.StringInput 283 // The name of the protection group. 284 ProtectionGroupId pulumi.StringInput 285 // The resource type to include 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. 286 ResourceType pulumi.StringPtrInput 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 Tags pulumi.StringMapInput 289 } 290 291 func (ProtectionGroupArgs) ElementType() reflect.Type { 292 return reflect.TypeOf((*protectionGroupArgs)(nil)).Elem() 293 } 294 295 type ProtectionGroupInput interface { 296 pulumi.Input 297 298 ToProtectionGroupOutput() ProtectionGroupOutput 299 ToProtectionGroupOutputWithContext(ctx context.Context) ProtectionGroupOutput 300 } 301 302 func (*ProtectionGroup) ElementType() reflect.Type { 303 return reflect.TypeOf((**ProtectionGroup)(nil)).Elem() 304 } 305 306 func (i *ProtectionGroup) ToProtectionGroupOutput() ProtectionGroupOutput { 307 return i.ToProtectionGroupOutputWithContext(context.Background()) 308 } 309 310 func (i *ProtectionGroup) ToProtectionGroupOutputWithContext(ctx context.Context) ProtectionGroupOutput { 311 return pulumi.ToOutputWithContext(ctx, i).(ProtectionGroupOutput) 312 } 313 314 // ProtectionGroupArrayInput is an input type that accepts ProtectionGroupArray and ProtectionGroupArrayOutput values. 315 // You can construct a concrete instance of `ProtectionGroupArrayInput` via: 316 // 317 // ProtectionGroupArray{ ProtectionGroupArgs{...} } 318 type ProtectionGroupArrayInput interface { 319 pulumi.Input 320 321 ToProtectionGroupArrayOutput() ProtectionGroupArrayOutput 322 ToProtectionGroupArrayOutputWithContext(context.Context) ProtectionGroupArrayOutput 323 } 324 325 type ProtectionGroupArray []ProtectionGroupInput 326 327 func (ProtectionGroupArray) ElementType() reflect.Type { 328 return reflect.TypeOf((*[]*ProtectionGroup)(nil)).Elem() 329 } 330 331 func (i ProtectionGroupArray) ToProtectionGroupArrayOutput() ProtectionGroupArrayOutput { 332 return i.ToProtectionGroupArrayOutputWithContext(context.Background()) 333 } 334 335 func (i ProtectionGroupArray) ToProtectionGroupArrayOutputWithContext(ctx context.Context) ProtectionGroupArrayOutput { 336 return pulumi.ToOutputWithContext(ctx, i).(ProtectionGroupArrayOutput) 337 } 338 339 // ProtectionGroupMapInput is an input type that accepts ProtectionGroupMap and ProtectionGroupMapOutput values. 340 // You can construct a concrete instance of `ProtectionGroupMapInput` via: 341 // 342 // ProtectionGroupMap{ "key": ProtectionGroupArgs{...} } 343 type ProtectionGroupMapInput interface { 344 pulumi.Input 345 346 ToProtectionGroupMapOutput() ProtectionGroupMapOutput 347 ToProtectionGroupMapOutputWithContext(context.Context) ProtectionGroupMapOutput 348 } 349 350 type ProtectionGroupMap map[string]ProtectionGroupInput 351 352 func (ProtectionGroupMap) ElementType() reflect.Type { 353 return reflect.TypeOf((*map[string]*ProtectionGroup)(nil)).Elem() 354 } 355 356 func (i ProtectionGroupMap) ToProtectionGroupMapOutput() ProtectionGroupMapOutput { 357 return i.ToProtectionGroupMapOutputWithContext(context.Background()) 358 } 359 360 func (i ProtectionGroupMap) ToProtectionGroupMapOutputWithContext(ctx context.Context) ProtectionGroupMapOutput { 361 return pulumi.ToOutputWithContext(ctx, i).(ProtectionGroupMapOutput) 362 } 363 364 type ProtectionGroupOutput struct{ *pulumi.OutputState } 365 366 func (ProtectionGroupOutput) ElementType() reflect.Type { 367 return reflect.TypeOf((**ProtectionGroup)(nil)).Elem() 368 } 369 370 func (o ProtectionGroupOutput) ToProtectionGroupOutput() ProtectionGroupOutput { 371 return o 372 } 373 374 func (o ProtectionGroupOutput) ToProtectionGroupOutputWithContext(ctx context.Context) ProtectionGroupOutput { 375 return o 376 } 377 378 // Defines how AWS Shield combines resource data for the group in order to detect, mitigate, and report events. 379 func (o ProtectionGroupOutput) Aggregation() pulumi.StringOutput { 380 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringOutput { return v.Aggregation }).(pulumi.StringOutput) 381 } 382 383 // 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. 384 func (o ProtectionGroupOutput) Members() pulumi.StringArrayOutput { 385 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringArrayOutput { return v.Members }).(pulumi.StringArrayOutput) 386 } 387 388 // The criteria to use to choose the protected resources for inclusion in the group. 389 func (o ProtectionGroupOutput) Pattern() pulumi.StringOutput { 390 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringOutput { return v.Pattern }).(pulumi.StringOutput) 391 } 392 393 // The ARN (Amazon Resource Name) of the protection group. 394 func (o ProtectionGroupOutput) ProtectionGroupArn() pulumi.StringOutput { 395 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringOutput { return v.ProtectionGroupArn }).(pulumi.StringOutput) 396 } 397 398 // The name of the protection group. 399 func (o ProtectionGroupOutput) ProtectionGroupId() pulumi.StringOutput { 400 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringOutput { return v.ProtectionGroupId }).(pulumi.StringOutput) 401 } 402 403 // The resource type to include 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. 404 func (o ProtectionGroupOutput) ResourceType() pulumi.StringPtrOutput { 405 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringPtrOutput { return v.ResourceType }).(pulumi.StringPtrOutput) 406 } 407 408 // 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. 409 func (o ProtectionGroupOutput) Tags() pulumi.StringMapOutput { 410 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 411 } 412 413 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 414 // 415 // Deprecated: Please use `tags` instead. 416 func (o ProtectionGroupOutput) TagsAll() pulumi.StringMapOutput { 417 return o.ApplyT(func(v *ProtectionGroup) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 418 } 419 420 type ProtectionGroupArrayOutput struct{ *pulumi.OutputState } 421 422 func (ProtectionGroupArrayOutput) ElementType() reflect.Type { 423 return reflect.TypeOf((*[]*ProtectionGroup)(nil)).Elem() 424 } 425 426 func (o ProtectionGroupArrayOutput) ToProtectionGroupArrayOutput() ProtectionGroupArrayOutput { 427 return o 428 } 429 430 func (o ProtectionGroupArrayOutput) ToProtectionGroupArrayOutputWithContext(ctx context.Context) ProtectionGroupArrayOutput { 431 return o 432 } 433 434 func (o ProtectionGroupArrayOutput) Index(i pulumi.IntInput) ProtectionGroupOutput { 435 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ProtectionGroup { 436 return vs[0].([]*ProtectionGroup)[vs[1].(int)] 437 }).(ProtectionGroupOutput) 438 } 439 440 type ProtectionGroupMapOutput struct{ *pulumi.OutputState } 441 442 func (ProtectionGroupMapOutput) ElementType() reflect.Type { 443 return reflect.TypeOf((*map[string]*ProtectionGroup)(nil)).Elem() 444 } 445 446 func (o ProtectionGroupMapOutput) ToProtectionGroupMapOutput() ProtectionGroupMapOutput { 447 return o 448 } 449 450 func (o ProtectionGroupMapOutput) ToProtectionGroupMapOutputWithContext(ctx context.Context) ProtectionGroupMapOutput { 451 return o 452 } 453 454 func (o ProtectionGroupMapOutput) MapIndex(k pulumi.StringInput) ProtectionGroupOutput { 455 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ProtectionGroup { 456 return vs[0].(map[string]*ProtectionGroup)[vs[1].(string)] 457 }).(ProtectionGroupOutput) 458 } 459 460 func init() { 461 pulumi.RegisterInputType(reflect.TypeOf((*ProtectionGroupInput)(nil)).Elem(), &ProtectionGroup{}) 462 pulumi.RegisterInputType(reflect.TypeOf((*ProtectionGroupArrayInput)(nil)).Elem(), ProtectionGroupArray{}) 463 pulumi.RegisterInputType(reflect.TypeOf((*ProtectionGroupMapInput)(nil)).Elem(), ProtectionGroupMap{}) 464 pulumi.RegisterOutputType(ProtectionGroupOutput{}) 465 pulumi.RegisterOutputType(ProtectionGroupArrayOutput{}) 466 pulumi.RegisterOutputType(ProtectionGroupMapOutput{}) 467 }