github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/wafregional/webAclAssociation.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 wafregional 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 // Manages an association with WAF Regional Web ACL. 16 // 17 // > **Note:** An Application Load Balancer can only be associated with one WAF Regional WebACL. 18 // 19 // ## Example Usage 20 // 21 // ### Application Load Balancer Association 22 // 23 // <!--Start PulumiCodeChooser --> 24 // ```go 25 // package main 26 // 27 // import ( 28 // 29 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws" 30 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/alb" 31 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2" 32 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafregional" 33 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 34 // 35 // ) 36 // 37 // func main() { 38 // pulumi.Run(func(ctx *pulumi.Context) error { 39 // ipset, err := wafregional.NewIpSet(ctx, "ipset", &wafregional.IpSetArgs{ 40 // Name: pulumi.String("tfIPSet"), 41 // IpSetDescriptors: wafregional.IpSetIpSetDescriptorArray{ 42 // &wafregional.IpSetIpSetDescriptorArgs{ 43 // Type: pulumi.String("IPV4"), 44 // Value: pulumi.String("192.0.7.0/24"), 45 // }, 46 // }, 47 // }) 48 // if err != nil { 49 // return err 50 // } 51 // foo, err := wafregional.NewRule(ctx, "foo", &wafregional.RuleArgs{ 52 // Name: pulumi.String("tfWAFRule"), 53 // MetricName: pulumi.String("tfWAFRule"), 54 // Predicates: wafregional.RulePredicateArray{ 55 // &wafregional.RulePredicateArgs{ 56 // DataId: ipset.ID(), 57 // Negated: pulumi.Bool(false), 58 // Type: pulumi.String("IPMatch"), 59 // }, 60 // }, 61 // }) 62 // if err != nil { 63 // return err 64 // } 65 // fooWebAcl, err := wafregional.NewWebAcl(ctx, "foo", &wafregional.WebAclArgs{ 66 // Name: pulumi.String("foo"), 67 // MetricName: pulumi.String("foo"), 68 // DefaultAction: &wafregional.WebAclDefaultActionArgs{ 69 // Type: pulumi.String("ALLOW"), 70 // }, 71 // Rules: wafregional.WebAclRuleArray{ 72 // &wafregional.WebAclRuleArgs{ 73 // Action: &wafregional.WebAclRuleActionArgs{ 74 // Type: pulumi.String("BLOCK"), 75 // }, 76 // Priority: pulumi.Int(1), 77 // RuleId: foo.ID(), 78 // }, 79 // }, 80 // }) 81 // if err != nil { 82 // return err 83 // } 84 // fooVpc, err := ec2.NewVpc(ctx, "foo", &ec2.VpcArgs{ 85 // CidrBlock: pulumi.String("10.1.0.0/16"), 86 // }) 87 // if err != nil { 88 // return err 89 // } 90 // available, err := aws.GetAvailabilityZones(ctx, nil, nil) 91 // if err != nil { 92 // return err 93 // } 94 // fooSubnet, err := ec2.NewSubnet(ctx, "foo", &ec2.SubnetArgs{ 95 // VpcId: fooVpc.ID(), 96 // CidrBlock: pulumi.String("10.1.1.0/24"), 97 // AvailabilityZone: pulumi.String(available.Names[0]), 98 // }) 99 // if err != nil { 100 // return err 101 // } 102 // bar, err := ec2.NewSubnet(ctx, "bar", &ec2.SubnetArgs{ 103 // VpcId: fooVpc.ID(), 104 // CidrBlock: pulumi.String("10.1.2.0/24"), 105 // AvailabilityZone: pulumi.String(available.Names[1]), 106 // }) 107 // if err != nil { 108 // return err 109 // } 110 // fooLoadBalancer, err := alb.NewLoadBalancer(ctx, "foo", &alb.LoadBalancerArgs{ 111 // Internal: pulumi.Bool(true), 112 // Subnets: pulumi.StringArray{ 113 // fooSubnet.ID(), 114 // bar.ID(), 115 // }, 116 // }) 117 // if err != nil { 118 // return err 119 // } 120 // _, err = wafregional.NewWebAclAssociation(ctx, "foo", &wafregional.WebAclAssociationArgs{ 121 // ResourceArn: fooLoadBalancer.Arn, 122 // WebAclId: fooWebAcl.ID(), 123 // }) 124 // if err != nil { 125 // return err 126 // } 127 // return nil 128 // }) 129 // } 130 // 131 // ``` 132 // <!--End PulumiCodeChooser --> 133 // 134 // ## Import 135 // 136 // Using `pulumi import`, import WAF Regional Web ACL Association using their `web_acl_id:resource_arn`. For example: 137 // 138 // ```sh 139 // $ pulumi import aws:wafregional/webAclAssociation:WebAclAssociation foo web_acl_id:resource_arn 140 // ``` 141 type WebAclAssociation struct { 142 pulumi.CustomResourceState 143 144 // ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage. 145 ResourceArn pulumi.StringOutput `pulumi:"resourceArn"` 146 // The ID of the WAF Regional WebACL to create an association. 147 WebAclId pulumi.StringOutput `pulumi:"webAclId"` 148 } 149 150 // NewWebAclAssociation registers a new resource with the given unique name, arguments, and options. 151 func NewWebAclAssociation(ctx *pulumi.Context, 152 name string, args *WebAclAssociationArgs, opts ...pulumi.ResourceOption) (*WebAclAssociation, error) { 153 if args == nil { 154 return nil, errors.New("missing one or more required arguments") 155 } 156 157 if args.ResourceArn == nil { 158 return nil, errors.New("invalid value for required argument 'ResourceArn'") 159 } 160 if args.WebAclId == nil { 161 return nil, errors.New("invalid value for required argument 'WebAclId'") 162 } 163 opts = internal.PkgResourceDefaultOpts(opts) 164 var resource WebAclAssociation 165 err := ctx.RegisterResource("aws:wafregional/webAclAssociation:WebAclAssociation", name, args, &resource, opts...) 166 if err != nil { 167 return nil, err 168 } 169 return &resource, nil 170 } 171 172 // GetWebAclAssociation gets an existing WebAclAssociation resource's state with the given name, ID, and optional 173 // state properties that are used to uniquely qualify the lookup (nil if not required). 174 func GetWebAclAssociation(ctx *pulumi.Context, 175 name string, id pulumi.IDInput, state *WebAclAssociationState, opts ...pulumi.ResourceOption) (*WebAclAssociation, error) { 176 var resource WebAclAssociation 177 err := ctx.ReadResource("aws:wafregional/webAclAssociation:WebAclAssociation", name, id, state, &resource, opts...) 178 if err != nil { 179 return nil, err 180 } 181 return &resource, nil 182 } 183 184 // Input properties used for looking up and filtering WebAclAssociation resources. 185 type webAclAssociationState struct { 186 // ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage. 187 ResourceArn *string `pulumi:"resourceArn"` 188 // The ID of the WAF Regional WebACL to create an association. 189 WebAclId *string `pulumi:"webAclId"` 190 } 191 192 type WebAclAssociationState struct { 193 // ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage. 194 ResourceArn pulumi.StringPtrInput 195 // The ID of the WAF Regional WebACL to create an association. 196 WebAclId pulumi.StringPtrInput 197 } 198 199 func (WebAclAssociationState) ElementType() reflect.Type { 200 return reflect.TypeOf((*webAclAssociationState)(nil)).Elem() 201 } 202 203 type webAclAssociationArgs struct { 204 // ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage. 205 ResourceArn string `pulumi:"resourceArn"` 206 // The ID of the WAF Regional WebACL to create an association. 207 WebAclId string `pulumi:"webAclId"` 208 } 209 210 // The set of arguments for constructing a WebAclAssociation resource. 211 type WebAclAssociationArgs struct { 212 // ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage. 213 ResourceArn pulumi.StringInput 214 // The ID of the WAF Regional WebACL to create an association. 215 WebAclId pulumi.StringInput 216 } 217 218 func (WebAclAssociationArgs) ElementType() reflect.Type { 219 return reflect.TypeOf((*webAclAssociationArgs)(nil)).Elem() 220 } 221 222 type WebAclAssociationInput interface { 223 pulumi.Input 224 225 ToWebAclAssociationOutput() WebAclAssociationOutput 226 ToWebAclAssociationOutputWithContext(ctx context.Context) WebAclAssociationOutput 227 } 228 229 func (*WebAclAssociation) ElementType() reflect.Type { 230 return reflect.TypeOf((**WebAclAssociation)(nil)).Elem() 231 } 232 233 func (i *WebAclAssociation) ToWebAclAssociationOutput() WebAclAssociationOutput { 234 return i.ToWebAclAssociationOutputWithContext(context.Background()) 235 } 236 237 func (i *WebAclAssociation) ToWebAclAssociationOutputWithContext(ctx context.Context) WebAclAssociationOutput { 238 return pulumi.ToOutputWithContext(ctx, i).(WebAclAssociationOutput) 239 } 240 241 // WebAclAssociationArrayInput is an input type that accepts WebAclAssociationArray and WebAclAssociationArrayOutput values. 242 // You can construct a concrete instance of `WebAclAssociationArrayInput` via: 243 // 244 // WebAclAssociationArray{ WebAclAssociationArgs{...} } 245 type WebAclAssociationArrayInput interface { 246 pulumi.Input 247 248 ToWebAclAssociationArrayOutput() WebAclAssociationArrayOutput 249 ToWebAclAssociationArrayOutputWithContext(context.Context) WebAclAssociationArrayOutput 250 } 251 252 type WebAclAssociationArray []WebAclAssociationInput 253 254 func (WebAclAssociationArray) ElementType() reflect.Type { 255 return reflect.TypeOf((*[]*WebAclAssociation)(nil)).Elem() 256 } 257 258 func (i WebAclAssociationArray) ToWebAclAssociationArrayOutput() WebAclAssociationArrayOutput { 259 return i.ToWebAclAssociationArrayOutputWithContext(context.Background()) 260 } 261 262 func (i WebAclAssociationArray) ToWebAclAssociationArrayOutputWithContext(ctx context.Context) WebAclAssociationArrayOutput { 263 return pulumi.ToOutputWithContext(ctx, i).(WebAclAssociationArrayOutput) 264 } 265 266 // WebAclAssociationMapInput is an input type that accepts WebAclAssociationMap and WebAclAssociationMapOutput values. 267 // You can construct a concrete instance of `WebAclAssociationMapInput` via: 268 // 269 // WebAclAssociationMap{ "key": WebAclAssociationArgs{...} } 270 type WebAclAssociationMapInput interface { 271 pulumi.Input 272 273 ToWebAclAssociationMapOutput() WebAclAssociationMapOutput 274 ToWebAclAssociationMapOutputWithContext(context.Context) WebAclAssociationMapOutput 275 } 276 277 type WebAclAssociationMap map[string]WebAclAssociationInput 278 279 func (WebAclAssociationMap) ElementType() reflect.Type { 280 return reflect.TypeOf((*map[string]*WebAclAssociation)(nil)).Elem() 281 } 282 283 func (i WebAclAssociationMap) ToWebAclAssociationMapOutput() WebAclAssociationMapOutput { 284 return i.ToWebAclAssociationMapOutputWithContext(context.Background()) 285 } 286 287 func (i WebAclAssociationMap) ToWebAclAssociationMapOutputWithContext(ctx context.Context) WebAclAssociationMapOutput { 288 return pulumi.ToOutputWithContext(ctx, i).(WebAclAssociationMapOutput) 289 } 290 291 type WebAclAssociationOutput struct{ *pulumi.OutputState } 292 293 func (WebAclAssociationOutput) ElementType() reflect.Type { 294 return reflect.TypeOf((**WebAclAssociation)(nil)).Elem() 295 } 296 297 func (o WebAclAssociationOutput) ToWebAclAssociationOutput() WebAclAssociationOutput { 298 return o 299 } 300 301 func (o WebAclAssociationOutput) ToWebAclAssociationOutputWithContext(ctx context.Context) WebAclAssociationOutput { 302 return o 303 } 304 305 // ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage. 306 func (o WebAclAssociationOutput) ResourceArn() pulumi.StringOutput { 307 return o.ApplyT(func(v *WebAclAssociation) pulumi.StringOutput { return v.ResourceArn }).(pulumi.StringOutput) 308 } 309 310 // The ID of the WAF Regional WebACL to create an association. 311 func (o WebAclAssociationOutput) WebAclId() pulumi.StringOutput { 312 return o.ApplyT(func(v *WebAclAssociation) pulumi.StringOutput { return v.WebAclId }).(pulumi.StringOutput) 313 } 314 315 type WebAclAssociationArrayOutput struct{ *pulumi.OutputState } 316 317 func (WebAclAssociationArrayOutput) ElementType() reflect.Type { 318 return reflect.TypeOf((*[]*WebAclAssociation)(nil)).Elem() 319 } 320 321 func (o WebAclAssociationArrayOutput) ToWebAclAssociationArrayOutput() WebAclAssociationArrayOutput { 322 return o 323 } 324 325 func (o WebAclAssociationArrayOutput) ToWebAclAssociationArrayOutputWithContext(ctx context.Context) WebAclAssociationArrayOutput { 326 return o 327 } 328 329 func (o WebAclAssociationArrayOutput) Index(i pulumi.IntInput) WebAclAssociationOutput { 330 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *WebAclAssociation { 331 return vs[0].([]*WebAclAssociation)[vs[1].(int)] 332 }).(WebAclAssociationOutput) 333 } 334 335 type WebAclAssociationMapOutput struct{ *pulumi.OutputState } 336 337 func (WebAclAssociationMapOutput) ElementType() reflect.Type { 338 return reflect.TypeOf((*map[string]*WebAclAssociation)(nil)).Elem() 339 } 340 341 func (o WebAclAssociationMapOutput) ToWebAclAssociationMapOutput() WebAclAssociationMapOutput { 342 return o 343 } 344 345 func (o WebAclAssociationMapOutput) ToWebAclAssociationMapOutputWithContext(ctx context.Context) WebAclAssociationMapOutput { 346 return o 347 } 348 349 func (o WebAclAssociationMapOutput) MapIndex(k pulumi.StringInput) WebAclAssociationOutput { 350 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *WebAclAssociation { 351 return vs[0].(map[string]*WebAclAssociation)[vs[1].(string)] 352 }).(WebAclAssociationOutput) 353 } 354 355 func init() { 356 pulumi.RegisterInputType(reflect.TypeOf((*WebAclAssociationInput)(nil)).Elem(), &WebAclAssociation{}) 357 pulumi.RegisterInputType(reflect.TypeOf((*WebAclAssociationArrayInput)(nil)).Elem(), WebAclAssociationArray{}) 358 pulumi.RegisterInputType(reflect.TypeOf((*WebAclAssociationMapInput)(nil)).Elem(), WebAclAssociationMap{}) 359 pulumi.RegisterOutputType(WebAclAssociationOutput{}) 360 pulumi.RegisterOutputType(WebAclAssociationArrayOutput{}) 361 pulumi.RegisterOutputType(WebAclAssociationMapOutput{}) 362 }