github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/xray/samplingRule.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 xray 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 and manages an AWS XRay Sampling Rule. 16 // 17 // ## Example Usage 18 // 19 // <!--Start PulumiCodeChooser --> 20 // ```go 21 // package main 22 // 23 // import ( 24 // 25 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/xray" 26 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 27 // 28 // ) 29 // 30 // func main() { 31 // pulumi.Run(func(ctx *pulumi.Context) error { 32 // _, err := xray.NewSamplingRule(ctx, "example", &xray.SamplingRuleArgs{ 33 // RuleName: pulumi.String("example"), 34 // Priority: pulumi.Int(9999), 35 // Version: pulumi.Int(1), 36 // ReservoirSize: pulumi.Int(1), 37 // FixedRate: pulumi.Float64(0.05), 38 // UrlPath: pulumi.String("*"), 39 // Host: pulumi.String("*"), 40 // HttpMethod: pulumi.String("*"), 41 // ServiceType: pulumi.String("*"), 42 // ServiceName: pulumi.String("*"), 43 // ResourceArn: pulumi.String("*"), 44 // Attributes: pulumi.StringMap{ 45 // "Hello": pulumi.String("Tris"), 46 // }, 47 // }) 48 // if err != nil { 49 // return err 50 // } 51 // return nil 52 // }) 53 // } 54 // 55 // ``` 56 // <!--End PulumiCodeChooser --> 57 // 58 // ## Import 59 // 60 // Using `pulumi import`, import XRay Sampling Rules using the name. For example: 61 // 62 // ```sh 63 // $ pulumi import aws:xray/samplingRule:SamplingRule example example 64 // ``` 65 type SamplingRule struct { 66 pulumi.CustomResourceState 67 68 // The ARN of the sampling rule. 69 Arn pulumi.StringOutput `pulumi:"arn"` 70 // Matches attributes derived from the request. 71 Attributes pulumi.StringMapOutput `pulumi:"attributes"` 72 // The percentage of matching requests to instrument, after the reservoir is exhausted. 73 FixedRate pulumi.Float64Output `pulumi:"fixedRate"` 74 // Matches the hostname from a request URL. 75 Host pulumi.StringOutput `pulumi:"host"` 76 // Matches the HTTP method of a request. 77 HttpMethod pulumi.StringOutput `pulumi:"httpMethod"` 78 // The priority of the sampling rule. 79 Priority pulumi.IntOutput `pulumi:"priority"` 80 // A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively. 81 ReservoirSize pulumi.IntOutput `pulumi:"reservoirSize"` 82 // Matches the ARN of the AWS resource on which the service runs. 83 ResourceArn pulumi.StringOutput `pulumi:"resourceArn"` 84 // The name of the sampling rule. 85 RuleName pulumi.StringPtrOutput `pulumi:"ruleName"` 86 // Matches the `name` that the service uses to identify itself in segments. 87 ServiceName pulumi.StringOutput `pulumi:"serviceName"` 88 // Matches the `origin` that the service uses to identify its type in segments. 89 ServiceType pulumi.StringOutput `pulumi:"serviceType"` 90 // Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level 91 Tags pulumi.StringMapOutput `pulumi:"tags"` 92 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 93 // 94 // Deprecated: Please use `tags` instead. 95 TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"` 96 // Matches the path from a request URL. 97 UrlPath pulumi.StringOutput `pulumi:"urlPath"` 98 // The version of the sampling rule format (`1` ) 99 Version pulumi.IntOutput `pulumi:"version"` 100 } 101 102 // NewSamplingRule registers a new resource with the given unique name, arguments, and options. 103 func NewSamplingRule(ctx *pulumi.Context, 104 name string, args *SamplingRuleArgs, opts ...pulumi.ResourceOption) (*SamplingRule, error) { 105 if args == nil { 106 return nil, errors.New("missing one or more required arguments") 107 } 108 109 if args.FixedRate == nil { 110 return nil, errors.New("invalid value for required argument 'FixedRate'") 111 } 112 if args.Host == nil { 113 return nil, errors.New("invalid value for required argument 'Host'") 114 } 115 if args.HttpMethod == nil { 116 return nil, errors.New("invalid value for required argument 'HttpMethod'") 117 } 118 if args.Priority == nil { 119 return nil, errors.New("invalid value for required argument 'Priority'") 120 } 121 if args.ReservoirSize == nil { 122 return nil, errors.New("invalid value for required argument 'ReservoirSize'") 123 } 124 if args.ResourceArn == nil { 125 return nil, errors.New("invalid value for required argument 'ResourceArn'") 126 } 127 if args.ServiceName == nil { 128 return nil, errors.New("invalid value for required argument 'ServiceName'") 129 } 130 if args.ServiceType == nil { 131 return nil, errors.New("invalid value for required argument 'ServiceType'") 132 } 133 if args.UrlPath == nil { 134 return nil, errors.New("invalid value for required argument 'UrlPath'") 135 } 136 if args.Version == nil { 137 return nil, errors.New("invalid value for required argument 'Version'") 138 } 139 opts = internal.PkgResourceDefaultOpts(opts) 140 var resource SamplingRule 141 err := ctx.RegisterResource("aws:xray/samplingRule:SamplingRule", name, args, &resource, opts...) 142 if err != nil { 143 return nil, err 144 } 145 return &resource, nil 146 } 147 148 // GetSamplingRule gets an existing SamplingRule resource's state with the given name, ID, and optional 149 // state properties that are used to uniquely qualify the lookup (nil if not required). 150 func GetSamplingRule(ctx *pulumi.Context, 151 name string, id pulumi.IDInput, state *SamplingRuleState, opts ...pulumi.ResourceOption) (*SamplingRule, error) { 152 var resource SamplingRule 153 err := ctx.ReadResource("aws:xray/samplingRule:SamplingRule", name, id, state, &resource, opts...) 154 if err != nil { 155 return nil, err 156 } 157 return &resource, nil 158 } 159 160 // Input properties used for looking up and filtering SamplingRule resources. 161 type samplingRuleState struct { 162 // The ARN of the sampling rule. 163 Arn *string `pulumi:"arn"` 164 // Matches attributes derived from the request. 165 Attributes map[string]string `pulumi:"attributes"` 166 // The percentage of matching requests to instrument, after the reservoir is exhausted. 167 FixedRate *float64 `pulumi:"fixedRate"` 168 // Matches the hostname from a request URL. 169 Host *string `pulumi:"host"` 170 // Matches the HTTP method of a request. 171 HttpMethod *string `pulumi:"httpMethod"` 172 // The priority of the sampling rule. 173 Priority *int `pulumi:"priority"` 174 // A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively. 175 ReservoirSize *int `pulumi:"reservoirSize"` 176 // Matches the ARN of the AWS resource on which the service runs. 177 ResourceArn *string `pulumi:"resourceArn"` 178 // The name of the sampling rule. 179 RuleName *string `pulumi:"ruleName"` 180 // Matches the `name` that the service uses to identify itself in segments. 181 ServiceName *string `pulumi:"serviceName"` 182 // Matches the `origin` that the service uses to identify its type in segments. 183 ServiceType *string `pulumi:"serviceType"` 184 // Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level 185 Tags map[string]string `pulumi:"tags"` 186 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 187 // 188 // Deprecated: Please use `tags` instead. 189 TagsAll map[string]string `pulumi:"tagsAll"` 190 // Matches the path from a request URL. 191 UrlPath *string `pulumi:"urlPath"` 192 // The version of the sampling rule format (`1` ) 193 Version *int `pulumi:"version"` 194 } 195 196 type SamplingRuleState struct { 197 // The ARN of the sampling rule. 198 Arn pulumi.StringPtrInput 199 // Matches attributes derived from the request. 200 Attributes pulumi.StringMapInput 201 // The percentage of matching requests to instrument, after the reservoir is exhausted. 202 FixedRate pulumi.Float64PtrInput 203 // Matches the hostname from a request URL. 204 Host pulumi.StringPtrInput 205 // Matches the HTTP method of a request. 206 HttpMethod pulumi.StringPtrInput 207 // The priority of the sampling rule. 208 Priority pulumi.IntPtrInput 209 // A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively. 210 ReservoirSize pulumi.IntPtrInput 211 // Matches the ARN of the AWS resource on which the service runs. 212 ResourceArn pulumi.StringPtrInput 213 // The name of the sampling rule. 214 RuleName pulumi.StringPtrInput 215 // Matches the `name` that the service uses to identify itself in segments. 216 ServiceName pulumi.StringPtrInput 217 // Matches the `origin` that the service uses to identify its type in segments. 218 ServiceType pulumi.StringPtrInput 219 // Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level 220 Tags pulumi.StringMapInput 221 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 222 // 223 // Deprecated: Please use `tags` instead. 224 TagsAll pulumi.StringMapInput 225 // Matches the path from a request URL. 226 UrlPath pulumi.StringPtrInput 227 // The version of the sampling rule format (`1` ) 228 Version pulumi.IntPtrInput 229 } 230 231 func (SamplingRuleState) ElementType() reflect.Type { 232 return reflect.TypeOf((*samplingRuleState)(nil)).Elem() 233 } 234 235 type samplingRuleArgs struct { 236 // Matches attributes derived from the request. 237 Attributes map[string]string `pulumi:"attributes"` 238 // The percentage of matching requests to instrument, after the reservoir is exhausted. 239 FixedRate float64 `pulumi:"fixedRate"` 240 // Matches the hostname from a request URL. 241 Host string `pulumi:"host"` 242 // Matches the HTTP method of a request. 243 HttpMethod string `pulumi:"httpMethod"` 244 // The priority of the sampling rule. 245 Priority int `pulumi:"priority"` 246 // A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively. 247 ReservoirSize int `pulumi:"reservoirSize"` 248 // Matches the ARN of the AWS resource on which the service runs. 249 ResourceArn string `pulumi:"resourceArn"` 250 // The name of the sampling rule. 251 RuleName *string `pulumi:"ruleName"` 252 // Matches the `name` that the service uses to identify itself in segments. 253 ServiceName string `pulumi:"serviceName"` 254 // Matches the `origin` that the service uses to identify its type in segments. 255 ServiceType string `pulumi:"serviceType"` 256 // Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level 257 Tags map[string]string `pulumi:"tags"` 258 // Matches the path from a request URL. 259 UrlPath string `pulumi:"urlPath"` 260 // The version of the sampling rule format (`1` ) 261 Version int `pulumi:"version"` 262 } 263 264 // The set of arguments for constructing a SamplingRule resource. 265 type SamplingRuleArgs struct { 266 // Matches attributes derived from the request. 267 Attributes pulumi.StringMapInput 268 // The percentage of matching requests to instrument, after the reservoir is exhausted. 269 FixedRate pulumi.Float64Input 270 // Matches the hostname from a request URL. 271 Host pulumi.StringInput 272 // Matches the HTTP method of a request. 273 HttpMethod pulumi.StringInput 274 // The priority of the sampling rule. 275 Priority pulumi.IntInput 276 // A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively. 277 ReservoirSize pulumi.IntInput 278 // Matches the ARN of the AWS resource on which the service runs. 279 ResourceArn pulumi.StringInput 280 // The name of the sampling rule. 281 RuleName pulumi.StringPtrInput 282 // Matches the `name` that the service uses to identify itself in segments. 283 ServiceName pulumi.StringInput 284 // Matches the `origin` that the service uses to identify its type in segments. 285 ServiceType pulumi.StringInput 286 // Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level 287 Tags pulumi.StringMapInput 288 // Matches the path from a request URL. 289 UrlPath pulumi.StringInput 290 // The version of the sampling rule format (`1` ) 291 Version pulumi.IntInput 292 } 293 294 func (SamplingRuleArgs) ElementType() reflect.Type { 295 return reflect.TypeOf((*samplingRuleArgs)(nil)).Elem() 296 } 297 298 type SamplingRuleInput interface { 299 pulumi.Input 300 301 ToSamplingRuleOutput() SamplingRuleOutput 302 ToSamplingRuleOutputWithContext(ctx context.Context) SamplingRuleOutput 303 } 304 305 func (*SamplingRule) ElementType() reflect.Type { 306 return reflect.TypeOf((**SamplingRule)(nil)).Elem() 307 } 308 309 func (i *SamplingRule) ToSamplingRuleOutput() SamplingRuleOutput { 310 return i.ToSamplingRuleOutputWithContext(context.Background()) 311 } 312 313 func (i *SamplingRule) ToSamplingRuleOutputWithContext(ctx context.Context) SamplingRuleOutput { 314 return pulumi.ToOutputWithContext(ctx, i).(SamplingRuleOutput) 315 } 316 317 // SamplingRuleArrayInput is an input type that accepts SamplingRuleArray and SamplingRuleArrayOutput values. 318 // You can construct a concrete instance of `SamplingRuleArrayInput` via: 319 // 320 // SamplingRuleArray{ SamplingRuleArgs{...} } 321 type SamplingRuleArrayInput interface { 322 pulumi.Input 323 324 ToSamplingRuleArrayOutput() SamplingRuleArrayOutput 325 ToSamplingRuleArrayOutputWithContext(context.Context) SamplingRuleArrayOutput 326 } 327 328 type SamplingRuleArray []SamplingRuleInput 329 330 func (SamplingRuleArray) ElementType() reflect.Type { 331 return reflect.TypeOf((*[]*SamplingRule)(nil)).Elem() 332 } 333 334 func (i SamplingRuleArray) ToSamplingRuleArrayOutput() SamplingRuleArrayOutput { 335 return i.ToSamplingRuleArrayOutputWithContext(context.Background()) 336 } 337 338 func (i SamplingRuleArray) ToSamplingRuleArrayOutputWithContext(ctx context.Context) SamplingRuleArrayOutput { 339 return pulumi.ToOutputWithContext(ctx, i).(SamplingRuleArrayOutput) 340 } 341 342 // SamplingRuleMapInput is an input type that accepts SamplingRuleMap and SamplingRuleMapOutput values. 343 // You can construct a concrete instance of `SamplingRuleMapInput` via: 344 // 345 // SamplingRuleMap{ "key": SamplingRuleArgs{...} } 346 type SamplingRuleMapInput interface { 347 pulumi.Input 348 349 ToSamplingRuleMapOutput() SamplingRuleMapOutput 350 ToSamplingRuleMapOutputWithContext(context.Context) SamplingRuleMapOutput 351 } 352 353 type SamplingRuleMap map[string]SamplingRuleInput 354 355 func (SamplingRuleMap) ElementType() reflect.Type { 356 return reflect.TypeOf((*map[string]*SamplingRule)(nil)).Elem() 357 } 358 359 func (i SamplingRuleMap) ToSamplingRuleMapOutput() SamplingRuleMapOutput { 360 return i.ToSamplingRuleMapOutputWithContext(context.Background()) 361 } 362 363 func (i SamplingRuleMap) ToSamplingRuleMapOutputWithContext(ctx context.Context) SamplingRuleMapOutput { 364 return pulumi.ToOutputWithContext(ctx, i).(SamplingRuleMapOutput) 365 } 366 367 type SamplingRuleOutput struct{ *pulumi.OutputState } 368 369 func (SamplingRuleOutput) ElementType() reflect.Type { 370 return reflect.TypeOf((**SamplingRule)(nil)).Elem() 371 } 372 373 func (o SamplingRuleOutput) ToSamplingRuleOutput() SamplingRuleOutput { 374 return o 375 } 376 377 func (o SamplingRuleOutput) ToSamplingRuleOutputWithContext(ctx context.Context) SamplingRuleOutput { 378 return o 379 } 380 381 // The ARN of the sampling rule. 382 func (o SamplingRuleOutput) Arn() pulumi.StringOutput { 383 return o.ApplyT(func(v *SamplingRule) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput) 384 } 385 386 // Matches attributes derived from the request. 387 func (o SamplingRuleOutput) Attributes() pulumi.StringMapOutput { 388 return o.ApplyT(func(v *SamplingRule) pulumi.StringMapOutput { return v.Attributes }).(pulumi.StringMapOutput) 389 } 390 391 // The percentage of matching requests to instrument, after the reservoir is exhausted. 392 func (o SamplingRuleOutput) FixedRate() pulumi.Float64Output { 393 return o.ApplyT(func(v *SamplingRule) pulumi.Float64Output { return v.FixedRate }).(pulumi.Float64Output) 394 } 395 396 // Matches the hostname from a request URL. 397 func (o SamplingRuleOutput) Host() pulumi.StringOutput { 398 return o.ApplyT(func(v *SamplingRule) pulumi.StringOutput { return v.Host }).(pulumi.StringOutput) 399 } 400 401 // Matches the HTTP method of a request. 402 func (o SamplingRuleOutput) HttpMethod() pulumi.StringOutput { 403 return o.ApplyT(func(v *SamplingRule) pulumi.StringOutput { return v.HttpMethod }).(pulumi.StringOutput) 404 } 405 406 // The priority of the sampling rule. 407 func (o SamplingRuleOutput) Priority() pulumi.IntOutput { 408 return o.ApplyT(func(v *SamplingRule) pulumi.IntOutput { return v.Priority }).(pulumi.IntOutput) 409 } 410 411 // A fixed number of matching requests to instrument per second, prior to applying the fixed rate. The reservoir is not used directly by services, but applies to all services using the rule collectively. 412 func (o SamplingRuleOutput) ReservoirSize() pulumi.IntOutput { 413 return o.ApplyT(func(v *SamplingRule) pulumi.IntOutput { return v.ReservoirSize }).(pulumi.IntOutput) 414 } 415 416 // Matches the ARN of the AWS resource on which the service runs. 417 func (o SamplingRuleOutput) ResourceArn() pulumi.StringOutput { 418 return o.ApplyT(func(v *SamplingRule) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput) 419 } 420 421 // The name of the sampling rule. 422 func (o SamplingRuleOutput) RuleName() pulumi.StringPtrOutput { 423 return o.ApplyT(func(v *SamplingRule) pulumi.StringPtrOutput { return v.RuleName }).(pulumi.StringPtrOutput) 424 } 425 426 // Matches the `name` that the service uses to identify itself in segments. 427 func (o SamplingRuleOutput) ServiceName() pulumi.StringOutput { 428 return o.ApplyT(func(v *SamplingRule) pulumi.StringOutput { return v.ServiceName }).(pulumi.StringOutput) 429 } 430 431 // Matches the `origin` that the service uses to identify its type in segments. 432 func (o SamplingRuleOutput) ServiceType() pulumi.StringOutput { 433 return o.ApplyT(func(v *SamplingRule) pulumi.StringOutput { return v.ServiceType }).(pulumi.StringOutput) 434 } 435 436 // Key-value mapping of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level 437 func (o SamplingRuleOutput) Tags() pulumi.StringMapOutput { 438 return o.ApplyT(func(v *SamplingRule) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput) 439 } 440 441 // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. 442 // 443 // Deprecated: Please use `tags` instead. 444 func (o SamplingRuleOutput) TagsAll() pulumi.StringMapOutput { 445 return o.ApplyT(func(v *SamplingRule) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput) 446 } 447 448 // Matches the path from a request URL. 449 func (o SamplingRuleOutput) UrlPath() pulumi.StringOutput { 450 return o.ApplyT(func(v *SamplingRule) pulumi.StringOutput { return v.UrlPath }).(pulumi.StringOutput) 451 } 452 453 // The version of the sampling rule format (`1` ) 454 func (o SamplingRuleOutput) Version() pulumi.IntOutput { 455 return o.ApplyT(func(v *SamplingRule) pulumi.IntOutput { return v.Version }).(pulumi.IntOutput) 456 } 457 458 type SamplingRuleArrayOutput struct{ *pulumi.OutputState } 459 460 func (SamplingRuleArrayOutput) ElementType() reflect.Type { 461 return reflect.TypeOf((*[]*SamplingRule)(nil)).Elem() 462 } 463 464 func (o SamplingRuleArrayOutput) ToSamplingRuleArrayOutput() SamplingRuleArrayOutput { 465 return o 466 } 467 468 func (o SamplingRuleArrayOutput) ToSamplingRuleArrayOutputWithContext(ctx context.Context) SamplingRuleArrayOutput { 469 return o 470 } 471 472 func (o SamplingRuleArrayOutput) Index(i pulumi.IntInput) SamplingRuleOutput { 473 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SamplingRule { 474 return vs[0].([]*SamplingRule)[vs[1].(int)] 475 }).(SamplingRuleOutput) 476 } 477 478 type SamplingRuleMapOutput struct{ *pulumi.OutputState } 479 480 func (SamplingRuleMapOutput) ElementType() reflect.Type { 481 return reflect.TypeOf((*map[string]*SamplingRule)(nil)).Elem() 482 } 483 484 func (o SamplingRuleMapOutput) ToSamplingRuleMapOutput() SamplingRuleMapOutput { 485 return o 486 } 487 488 func (o SamplingRuleMapOutput) ToSamplingRuleMapOutputWithContext(ctx context.Context) SamplingRuleMapOutput { 489 return o 490 } 491 492 func (o SamplingRuleMapOutput) MapIndex(k pulumi.StringInput) SamplingRuleOutput { 493 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SamplingRule { 494 return vs[0].(map[string]*SamplingRule)[vs[1].(string)] 495 }).(SamplingRuleOutput) 496 } 497 498 func init() { 499 pulumi.RegisterInputType(reflect.TypeOf((*SamplingRuleInput)(nil)).Elem(), &SamplingRule{}) 500 pulumi.RegisterInputType(reflect.TypeOf((*SamplingRuleArrayInput)(nil)).Elem(), SamplingRuleArray{}) 501 pulumi.RegisterInputType(reflect.TypeOf((*SamplingRuleMapInput)(nil)).Elem(), SamplingRuleMap{}) 502 pulumi.RegisterOutputType(SamplingRuleOutput{}) 503 pulumi.RegisterOutputType(SamplingRuleArrayOutput{}) 504 pulumi.RegisterOutputType(SamplingRuleMapOutput{}) 505 }