Try AWS Native preview for resources not in the classic version.
aws.wafregional.WebAclAssociation
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
Manages an association with WAF Regional Web ACL.
Note: An Application Load Balancer can only be associated with one WAF Regional WebACL.
Example Usage
Application Load Balancer Association
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const ipset = new aws.wafregional.IpSet("ipset", {
name: "tfIPSet",
ipSetDescriptors: [{
type: "IPV4",
value: "192.0.7.0/24",
}],
});
const foo = new aws.wafregional.Rule("foo", {
name: "tfWAFRule",
metricName: "tfWAFRule",
predicates: [{
dataId: ipset.id,
negated: false,
type: "IPMatch",
}],
});
const fooWebAcl = new aws.wafregional.WebAcl("foo", {
name: "foo",
metricName: "foo",
defaultAction: {
type: "ALLOW",
},
rules: [{
action: {
type: "BLOCK",
},
priority: 1,
ruleId: foo.id,
}],
});
const fooVpc = new aws.ec2.Vpc("foo", {cidrBlock: "10.1.0.0/16"});
const available = aws.getAvailabilityZones({});
const fooSubnet = new aws.ec2.Subnet("foo", {
vpcId: fooVpc.id,
cidrBlock: "10.1.1.0/24",
availabilityZone: available.then(available => available.names?.[0]),
});
const bar = new aws.ec2.Subnet("bar", {
vpcId: fooVpc.id,
cidrBlock: "10.1.2.0/24",
availabilityZone: available.then(available => available.names?.[1]),
});
const fooLoadBalancer = new aws.alb.LoadBalancer("foo", {
internal: true,
subnets: [
fooSubnet.id,
bar.id,
],
});
const fooWebAclAssociation = new aws.wafregional.WebAclAssociation("foo", {
resourceArn: fooLoadBalancer.arn,
webAclId: fooWebAcl.id,
});
import pulumi
import pulumi_aws as aws
ipset = aws.wafregional.IpSet("ipset",
name="tfIPSet",
ip_set_descriptors=[aws.wafregional.IpSetIpSetDescriptorArgs(
type="IPV4",
value="192.0.7.0/24",
)])
foo = aws.wafregional.Rule("foo",
name="tfWAFRule",
metric_name="tfWAFRule",
predicates=[aws.wafregional.RulePredicateArgs(
data_id=ipset.id,
negated=False,
type="IPMatch",
)])
foo_web_acl = aws.wafregional.WebAcl("foo",
name="foo",
metric_name="foo",
default_action=aws.wafregional.WebAclDefaultActionArgs(
type="ALLOW",
),
rules=[aws.wafregional.WebAclRuleArgs(
action=aws.wafregional.WebAclRuleActionArgs(
type="BLOCK",
),
priority=1,
rule_id=foo.id,
)])
foo_vpc = aws.ec2.Vpc("foo", cidr_block="10.1.0.0/16")
available = aws.get_availability_zones()
foo_subnet = aws.ec2.Subnet("foo",
vpc_id=foo_vpc.id,
cidr_block="10.1.1.0/24",
availability_zone=available.names[0])
bar = aws.ec2.Subnet("bar",
vpc_id=foo_vpc.id,
cidr_block="10.1.2.0/24",
availability_zone=available.names[1])
foo_load_balancer = aws.alb.LoadBalancer("foo",
internal=True,
subnets=[
foo_subnet.id,
bar.id,
])
foo_web_acl_association = aws.wafregional.WebAclAssociation("foo",
resource_arn=foo_load_balancer.arn,
web_acl_id=foo_web_acl.id)
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/alb"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafregional"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ipset, err := wafregional.NewIpSet(ctx, "ipset", &wafregional.IpSetArgs{
Name: pulumi.String("tfIPSet"),
IpSetDescriptors: wafregional.IpSetIpSetDescriptorArray{
&wafregional.IpSetIpSetDescriptorArgs{
Type: pulumi.String("IPV4"),
Value: pulumi.String("192.0.7.0/24"),
},
},
})
if err != nil {
return err
}
foo, err := wafregional.NewRule(ctx, "foo", &wafregional.RuleArgs{
Name: pulumi.String("tfWAFRule"),
MetricName: pulumi.String("tfWAFRule"),
Predicates: wafregional.RulePredicateArray{
&wafregional.RulePredicateArgs{
DataId: ipset.ID(),
Negated: pulumi.Bool(false),
Type: pulumi.String("IPMatch"),
},
},
})
if err != nil {
return err
}
fooWebAcl, err := wafregional.NewWebAcl(ctx, "foo", &wafregional.WebAclArgs{
Name: pulumi.String("foo"),
MetricName: pulumi.String("foo"),
DefaultAction: &wafregional.WebAclDefaultActionArgs{
Type: pulumi.String("ALLOW"),
},
Rules: wafregional.WebAclRuleArray{
&wafregional.WebAclRuleArgs{
Action: &wafregional.WebAclRuleActionArgs{
Type: pulumi.String("BLOCK"),
},
Priority: pulumi.Int(1),
RuleId: foo.ID(),
},
},
})
if err != nil {
return err
}
fooVpc, err := ec2.NewVpc(ctx, "foo", &ec2.VpcArgs{
CidrBlock: pulumi.String("10.1.0.0/16"),
})
if err != nil {
return err
}
available, err := aws.GetAvailabilityZones(ctx, nil, nil)
if err != nil {
return err
}
fooSubnet, err := ec2.NewSubnet(ctx, "foo", &ec2.SubnetArgs{
VpcId: fooVpc.ID(),
CidrBlock: pulumi.String("10.1.1.0/24"),
AvailabilityZone: pulumi.String(available.Names[0]),
})
if err != nil {
return err
}
bar, err := ec2.NewSubnet(ctx, "bar", &ec2.SubnetArgs{
VpcId: fooVpc.ID(),
CidrBlock: pulumi.String("10.1.2.0/24"),
AvailabilityZone: pulumi.String(available.Names[1]),
})
if err != nil {
return err
}
fooLoadBalancer, err := alb.NewLoadBalancer(ctx, "foo", &alb.LoadBalancerArgs{
Internal: pulumi.Bool(true),
Subnets: pulumi.StringArray{
fooSubnet.ID(),
bar.ID(),
},
})
if err != nil {
return err
}
_, err = wafregional.NewWebAclAssociation(ctx, "foo", &wafregional.WebAclAssociationArgs{
ResourceArn: fooLoadBalancer.Arn,
WebAclId: fooWebAcl.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var ipset = new Aws.WafRegional.IpSet("ipset", new()
{
Name = "tfIPSet",
IpSetDescriptors = new[]
{
new Aws.WafRegional.Inputs.IpSetIpSetDescriptorArgs
{
Type = "IPV4",
Value = "192.0.7.0/24",
},
},
});
var foo = new Aws.WafRegional.Rule("foo", new()
{
Name = "tfWAFRule",
MetricName = "tfWAFRule",
Predicates = new[]
{
new Aws.WafRegional.Inputs.RulePredicateArgs
{
DataId = ipset.Id,
Negated = false,
Type = "IPMatch",
},
},
});
var fooWebAcl = new Aws.WafRegional.WebAcl("foo", new()
{
Name = "foo",
MetricName = "foo",
DefaultAction = new Aws.WafRegional.Inputs.WebAclDefaultActionArgs
{
Type = "ALLOW",
},
Rules = new[]
{
new Aws.WafRegional.Inputs.WebAclRuleArgs
{
Action = new Aws.WafRegional.Inputs.WebAclRuleActionArgs
{
Type = "BLOCK",
},
Priority = 1,
RuleId = foo.Id,
},
},
});
var fooVpc = new Aws.Ec2.Vpc("foo", new()
{
CidrBlock = "10.1.0.0/16",
});
var available = Aws.GetAvailabilityZones.Invoke();
var fooSubnet = new Aws.Ec2.Subnet("foo", new()
{
VpcId = fooVpc.Id,
CidrBlock = "10.1.1.0/24",
AvailabilityZone = available.Apply(getAvailabilityZonesResult => getAvailabilityZonesResult.Names[0]),
});
var bar = new Aws.Ec2.Subnet("bar", new()
{
VpcId = fooVpc.Id,
CidrBlock = "10.1.2.0/24",
AvailabilityZone = available.Apply(getAvailabilityZonesResult => getAvailabilityZonesResult.Names[1]),
});
var fooLoadBalancer = new Aws.Alb.LoadBalancer("foo", new()
{
Internal = true,
Subnets = new[]
{
fooSubnet.Id,
bar.Id,
},
});
var fooWebAclAssociation = new Aws.WafRegional.WebAclAssociation("foo", new()
{
ResourceArn = fooLoadBalancer.Arn,
WebAclId = fooWebAcl.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.wafregional.IpSet;
import com.pulumi.aws.wafregional.IpSetArgs;
import com.pulumi.aws.wafregional.inputs.IpSetIpSetDescriptorArgs;
import com.pulumi.aws.wafregional.Rule;
import com.pulumi.aws.wafregional.RuleArgs;
import com.pulumi.aws.wafregional.inputs.RulePredicateArgs;
import com.pulumi.aws.wafregional.WebAcl;
import com.pulumi.aws.wafregional.WebAclArgs;
import com.pulumi.aws.wafregional.inputs.WebAclDefaultActionArgs;
import com.pulumi.aws.wafregional.inputs.WebAclRuleArgs;
import com.pulumi.aws.wafregional.inputs.WebAclRuleActionArgs;
import com.pulumi.aws.ec2.Vpc;
import com.pulumi.aws.ec2.VpcArgs;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetAvailabilityZonesArgs;
import com.pulumi.aws.ec2.Subnet;
import com.pulumi.aws.ec2.SubnetArgs;
import com.pulumi.aws.alb.LoadBalancer;
import com.pulumi.aws.alb.LoadBalancerArgs;
import com.pulumi.aws.wafregional.WebAclAssociation;
import com.pulumi.aws.wafregional.WebAclAssociationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var ipset = new IpSet("ipset", IpSetArgs.builder()
.name("tfIPSet")
.ipSetDescriptors(IpSetIpSetDescriptorArgs.builder()
.type("IPV4")
.value("192.0.7.0/24")
.build())
.build());
var foo = new Rule("foo", RuleArgs.builder()
.name("tfWAFRule")
.metricName("tfWAFRule")
.predicates(RulePredicateArgs.builder()
.dataId(ipset.id())
.negated(false)
.type("IPMatch")
.build())
.build());
var fooWebAcl = new WebAcl("fooWebAcl", WebAclArgs.builder()
.name("foo")
.metricName("foo")
.defaultAction(WebAclDefaultActionArgs.builder()
.type("ALLOW")
.build())
.rules(WebAclRuleArgs.builder()
.action(WebAclRuleActionArgs.builder()
.type("BLOCK")
.build())
.priority(1)
.ruleId(foo.id())
.build())
.build());
var fooVpc = new Vpc("fooVpc", VpcArgs.builder()
.cidrBlock("10.1.0.0/16")
.build());
final var available = AwsFunctions.getAvailabilityZones();
var fooSubnet = new Subnet("fooSubnet", SubnetArgs.builder()
.vpcId(fooVpc.id())
.cidrBlock("10.1.1.0/24")
.availabilityZone(available.applyValue(getAvailabilityZonesResult -> getAvailabilityZonesResult.names()[0]))
.build());
var bar = new Subnet("bar", SubnetArgs.builder()
.vpcId(fooVpc.id())
.cidrBlock("10.1.2.0/24")
.availabilityZone(available.applyValue(getAvailabilityZonesResult -> getAvailabilityZonesResult.names()[1]))
.build());
var fooLoadBalancer = new LoadBalancer("fooLoadBalancer", LoadBalancerArgs.builder()
.internal(true)
.subnets(
fooSubnet.id(),
bar.id())
.build());
var fooWebAclAssociation = new WebAclAssociation("fooWebAclAssociation", WebAclAssociationArgs.builder()
.resourceArn(fooLoadBalancer.arn())
.webAclId(fooWebAcl.id())
.build());
}
}
resources:
ipset:
type: aws:wafregional:IpSet
properties:
name: tfIPSet
ipSetDescriptors:
- type: IPV4
value: 192.0.7.0/24
foo:
type: aws:wafregional:Rule
properties:
name: tfWAFRule
metricName: tfWAFRule
predicates:
- dataId: ${ipset.id}
negated: false
type: IPMatch
fooWebAcl:
type: aws:wafregional:WebAcl
name: foo
properties:
name: foo
metricName: foo
defaultAction:
type: ALLOW
rules:
- action:
type: BLOCK
priority: 1
ruleId: ${foo.id}
fooVpc:
type: aws:ec2:Vpc
name: foo
properties:
cidrBlock: 10.1.0.0/16
fooSubnet:
type: aws:ec2:Subnet
name: foo
properties:
vpcId: ${fooVpc.id}
cidrBlock: 10.1.1.0/24
availabilityZone: ${available.names[0]}
bar:
type: aws:ec2:Subnet
properties:
vpcId: ${fooVpc.id}
cidrBlock: 10.1.2.0/24
availabilityZone: ${available.names[1]}
fooLoadBalancer:
type: aws:alb:LoadBalancer
name: foo
properties:
internal: true
subnets:
- ${fooSubnet.id}
- ${bar.id}
fooWebAclAssociation:
type: aws:wafregional:WebAclAssociation
name: foo
properties:
resourceArn: ${fooLoadBalancer.arn}
webAclId: ${fooWebAcl.id}
variables:
available:
fn::invoke:
Function: aws:getAvailabilityZones
Arguments: {}
API Gateway Association
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as std from "@pulumi/std";
const ipset = new aws.wafregional.IpSet("ipset", {
name: "tfIPSet",
ipSetDescriptors: [{
type: "IPV4",
value: "192.0.7.0/24",
}],
});
const foo = new aws.wafregional.Rule("foo", {
name: "tfWAFRule",
metricName: "tfWAFRule",
predicates: [{
dataId: ipset.id,
negated: false,
type: "IPMatch",
}],
});
const fooWebAcl = new aws.wafregional.WebAcl("foo", {
name: "foo",
metricName: "foo",
defaultAction: {
type: "ALLOW",
},
rules: [{
action: {
type: "BLOCK",
},
priority: 1,
ruleId: foo.id,
}],
});
const example = new aws.apigateway.RestApi("example", {
body: JSON.stringify({
openapi: "3.0.1",
info: {
title: "example",
version: "1.0",
},
paths: {
"/path1": {
get: {
"x-amazon-apigateway-integration": {
httpMethod: "GET",
payloadFormatVersion: "1.0",
type: "HTTP_PROXY",
uri: "https://ip-ranges.amazonaws.com/ip-ranges.json",
},
},
},
},
}),
name: "example",
});
const exampleDeployment = new aws.apigateway.Deployment("example", {
restApi: example.id,
triggers: {
redeployment: std.sha1Output({
input: pulumi.jsonStringify(example.body),
}).apply(invoke => invoke.result),
},
});
const exampleStage = new aws.apigateway.Stage("example", {
deployment: exampleDeployment.id,
restApi: example.id,
stageName: "example",
});
const association = new aws.wafregional.WebAclAssociation("association", {
resourceArn: exampleStage.arn,
webAclId: fooWebAcl.id,
});
import pulumi
import json
import pulumi_aws as aws
import pulumi_std as std
ipset = aws.wafregional.IpSet("ipset",
name="tfIPSet",
ip_set_descriptors=[aws.wafregional.IpSetIpSetDescriptorArgs(
type="IPV4",
value="192.0.7.0/24",
)])
foo = aws.wafregional.Rule("foo",
name="tfWAFRule",
metric_name="tfWAFRule",
predicates=[aws.wafregional.RulePredicateArgs(
data_id=ipset.id,
negated=False,
type="IPMatch",
)])
foo_web_acl = aws.wafregional.WebAcl("foo",
name="foo",
metric_name="foo",
default_action=aws.wafregional.WebAclDefaultActionArgs(
type="ALLOW",
),
rules=[aws.wafregional.WebAclRuleArgs(
action=aws.wafregional.WebAclRuleActionArgs(
type="BLOCK",
),
priority=1,
rule_id=foo.id,
)])
example = aws.apigateway.RestApi("example",
body=json.dumps({
"openapi": "3.0.1",
"info": {
"title": "example",
"version": "1.0",
},
"paths": {
"/path1": {
"get": {
"x-amazon-apigateway-integration": {
"httpMethod": "GET",
"payloadFormatVersion": "1.0",
"type": "HTTP_PROXY",
"uri": "https://ip-ranges.amazonaws.com/ip-ranges.json",
},
},
},
},
}),
name="example")
example_deployment = aws.apigateway.Deployment("example",
rest_api=example.id,
triggers={
"redeployment": std.sha1_output(input=pulumi.Output.json_dumps(example.body)).apply(lambda invoke: invoke.result),
})
example_stage = aws.apigateway.Stage("example",
deployment=example_deployment.id,
rest_api=example.id,
stage_name="example")
association = aws.wafregional.WebAclAssociation("association",
resource_arn=example_stage.arn,
web_acl_id=foo_web_acl.id)
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/wafregional"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ipset, err := wafregional.NewIpSet(ctx, "ipset", &wafregional.IpSetArgs{
Name: pulumi.String("tfIPSet"),
IpSetDescriptors: wafregional.IpSetIpSetDescriptorArray{
&wafregional.IpSetIpSetDescriptorArgs{
Type: pulumi.String("IPV4"),
Value: pulumi.String("192.0.7.0/24"),
},
},
})
if err != nil {
return err
}
foo, err := wafregional.NewRule(ctx, "foo", &wafregional.RuleArgs{
Name: pulumi.String("tfWAFRule"),
MetricName: pulumi.String("tfWAFRule"),
Predicates: wafregional.RulePredicateArray{
&wafregional.RulePredicateArgs{
DataId: ipset.ID(),
Negated: pulumi.Bool(false),
Type: pulumi.String("IPMatch"),
},
},
})
if err != nil {
return err
}
fooWebAcl, err := wafregional.NewWebAcl(ctx, "foo", &wafregional.WebAclArgs{
Name: pulumi.String("foo"),
MetricName: pulumi.String("foo"),
DefaultAction: &wafregional.WebAclDefaultActionArgs{
Type: pulumi.String("ALLOW"),
},
Rules: wafregional.WebAclRuleArray{
&wafregional.WebAclRuleArgs{
Action: &wafregional.WebAclRuleActionArgs{
Type: pulumi.String("BLOCK"),
},
Priority: pulumi.Int(1),
RuleId: foo.ID(),
},
},
})
if err != nil {
return err
}
tmpJSON0, err := json.Marshal(map[string]interface{}{
"openapi": "3.0.1",
"info": map[string]interface{}{
"title": "example",
"version": "1.0",
},
"paths": map[string]interface{}{
"/path1": map[string]interface{}{
"get": map[string]interface{}{
"x-amazon-apigateway-integration": map[string]interface{}{
"httpMethod": "GET",
"payloadFormatVersion": "1.0",
"type": "HTTP_PROXY",
"uri": "https://ip-ranges.amazonaws.com/ip-ranges.json",
},
},
},
},
})
if err != nil {
return err
}
json0 := string(tmpJSON0)
example, err := apigateway.NewRestApi(ctx, "example", &apigateway.RestApiArgs{
Body: pulumi.String(json0),
Name: pulumi.String("example"),
})
if err != nil {
return err
}
exampleDeployment, err := apigateway.NewDeployment(ctx, "example", &apigateway.DeploymentArgs{
RestApi: example.ID(),
Triggers: pulumi.StringMap{
"redeployment": std.Sha1Output(ctx, std.Sha1OutputArgs{
Input: example.Body.ApplyT(func(body *string) (pulumi.String, error) {
var _zero pulumi.String
tmpJSON1, err := json.Marshal(body)
if err != nil {
return _zero, err
}
json1 := string(tmpJSON1)
return pulumi.String(json1), nil
}).(pulumi.StringOutput),
}, nil).ApplyT(func(invoke std.Sha1Result) (*string, error) {
return invoke.Result, nil
}).(pulumi.StringPtrOutput),
},
})
if err != nil {
return err
}
exampleStage, err := apigateway.NewStage(ctx, "example", &apigateway.StageArgs{
Deployment: exampleDeployment.ID(),
RestApi: example.ID(),
StageName: pulumi.String("example"),
})
if err != nil {
return err
}
_, err = wafregional.NewWebAclAssociation(ctx, "association", &wafregional.WebAclAssociationArgs{
ResourceArn: exampleStage.Arn,
WebAclId: fooWebAcl.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var ipset = new Aws.WafRegional.IpSet("ipset", new()
{
Name = "tfIPSet",
IpSetDescriptors = new[]
{
new Aws.WafRegional.Inputs.IpSetIpSetDescriptorArgs
{
Type = "IPV4",
Value = "192.0.7.0/24",
},
},
});
var foo = new Aws.WafRegional.Rule("foo", new()
{
Name = "tfWAFRule",
MetricName = "tfWAFRule",
Predicates = new[]
{
new Aws.WafRegional.Inputs.RulePredicateArgs
{
DataId = ipset.Id,
Negated = false,
Type = "IPMatch",
},
},
});
var fooWebAcl = new Aws.WafRegional.WebAcl("foo", new()
{
Name = "foo",
MetricName = "foo",
DefaultAction = new Aws.WafRegional.Inputs.WebAclDefaultActionArgs
{
Type = "ALLOW",
},
Rules = new[]
{
new Aws.WafRegional.Inputs.WebAclRuleArgs
{
Action = new Aws.WafRegional.Inputs.WebAclRuleActionArgs
{
Type = "BLOCK",
},
Priority = 1,
RuleId = foo.Id,
},
},
});
var example = new Aws.ApiGateway.RestApi("example", new()
{
Body = JsonSerializer.Serialize(new Dictionary<string, object?>
{
["openapi"] = "3.0.1",
["info"] = new Dictionary<string, object?>
{
["title"] = "example",
["version"] = "1.0",
},
["paths"] = new Dictionary<string, object?>
{
["/path1"] = new Dictionary<string, object?>
{
["get"] = new Dictionary<string, object?>
{
["x-amazon-apigateway-integration"] = new Dictionary<string, object?>
{
["httpMethod"] = "GET",
["payloadFormatVersion"] = "1.0",
["type"] = "HTTP_PROXY",
["uri"] = "https://ip-ranges.amazonaws.com/ip-ranges.json",
},
},
},
},
}),
Name = "example",
});
var exampleDeployment = new Aws.ApiGateway.Deployment("example", new()
{
RestApi = example.Id,
Triggers =
{
{ "redeployment", Std.Sha1.Invoke(new()
{
Input = Output.JsonSerialize(Output.Create(example.Body)),
}).Apply(invoke => invoke.Result) },
},
});
var exampleStage = new Aws.ApiGateway.Stage("example", new()
{
Deployment = exampleDeployment.Id,
RestApi = example.Id,
StageName = "example",
});
var association = new Aws.WafRegional.WebAclAssociation("association", new()
{
ResourceArn = exampleStage.Arn,
WebAclId = fooWebAcl.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.wafregional.IpSet;
import com.pulumi.aws.wafregional.IpSetArgs;
import com.pulumi.aws.wafregional.inputs.IpSetIpSetDescriptorArgs;
import com.pulumi.aws.wafregional.Rule;
import com.pulumi.aws.wafregional.RuleArgs;
import com.pulumi.aws.wafregional.inputs.RulePredicateArgs;
import com.pulumi.aws.wafregional.WebAcl;
import com.pulumi.aws.wafregional.WebAclArgs;
import com.pulumi.aws.wafregional.inputs.WebAclDefaultActionArgs;
import com.pulumi.aws.wafregional.inputs.WebAclRuleArgs;
import com.pulumi.aws.wafregional.inputs.WebAclRuleActionArgs;
import com.pulumi.aws.apigateway.RestApi;
import com.pulumi.aws.apigateway.RestApiArgs;
import com.pulumi.aws.apigateway.Deployment;
import com.pulumi.aws.apigateway.DeploymentArgs;
import com.pulumi.aws.apigateway.Stage;
import com.pulumi.aws.apigateway.StageArgs;
import com.pulumi.aws.wafregional.WebAclAssociation;
import com.pulumi.aws.wafregional.WebAclAssociationArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var ipset = new IpSet("ipset", IpSetArgs.builder()
.name("tfIPSet")
.ipSetDescriptors(IpSetIpSetDescriptorArgs.builder()
.type("IPV4")
.value("192.0.7.0/24")
.build())
.build());
var foo = new Rule("foo", RuleArgs.builder()
.name("tfWAFRule")
.metricName("tfWAFRule")
.predicates(RulePredicateArgs.builder()
.dataId(ipset.id())
.negated(false)
.type("IPMatch")
.build())
.build());
var fooWebAcl = new WebAcl("fooWebAcl", WebAclArgs.builder()
.name("foo")
.metricName("foo")
.defaultAction(WebAclDefaultActionArgs.builder()
.type("ALLOW")
.build())
.rules(WebAclRuleArgs.builder()
.action(WebAclRuleActionArgs.builder()
.type("BLOCK")
.build())
.priority(1)
.ruleId(foo.id())
.build())
.build());
var example = new RestApi("example", RestApiArgs.builder()
.body(serializeJson(
jsonObject(
jsonProperty("openapi", "3.0.1"),
jsonProperty("info", jsonObject(
jsonProperty("title", "example"),
jsonProperty("version", "1.0")
)),
jsonProperty("paths", jsonObject(
jsonProperty("/path1", jsonObject(
jsonProperty("get", jsonObject(
jsonProperty("x-amazon-apigateway-integration", jsonObject(
jsonProperty("httpMethod", "GET"),
jsonProperty("payloadFormatVersion", "1.0"),
jsonProperty("type", "HTTP_PROXY"),
jsonProperty("uri", "https://ip-ranges.amazonaws.com/ip-ranges.json")
))
))
))
))
)))
.name("example")
.build());
var exampleDeployment = new Deployment("exampleDeployment", DeploymentArgs.builder()
.restApi(example.id())
.triggers(Map.of("redeployment", StdFunctions.sha1().applyValue(invoke -> invoke.result())))
.build());
var exampleStage = new Stage("exampleStage", StageArgs.builder()
.deployment(exampleDeployment.id())
.restApi(example.id())
.stageName("example")
.build());
var association = new WebAclAssociation("association", WebAclAssociationArgs.builder()
.resourceArn(exampleStage.arn())
.webAclId(fooWebAcl.id())
.build());
}
}
resources:
ipset:
type: aws:wafregional:IpSet
properties:
name: tfIPSet
ipSetDescriptors:
- type: IPV4
value: 192.0.7.0/24
foo:
type: aws:wafregional:Rule
properties:
name: tfWAFRule
metricName: tfWAFRule
predicates:
- dataId: ${ipset.id}
negated: false
type: IPMatch
fooWebAcl:
type: aws:wafregional:WebAcl
name: foo
properties:
name: foo
metricName: foo
defaultAction:
type: ALLOW
rules:
- action:
type: BLOCK
priority: 1
ruleId: ${foo.id}
example:
type: aws:apigateway:RestApi
properties:
body:
fn::toJSON:
openapi: 3.0.1
info:
title: example
version: '1.0'
paths:
/path1:
get:
x-amazon-apigateway-integration:
httpMethod: GET
payloadFormatVersion: '1.0'
type: HTTP_PROXY
uri: https://ip-ranges.amazonaws.com/ip-ranges.json
name: example
exampleDeployment:
type: aws:apigateway:Deployment
name: example
properties:
restApi: ${example.id}
triggers:
redeployment:
fn::invoke:
Function: std:sha1
Arguments:
input:
fn::toJSON: ${example.body}
Return: result
exampleStage:
type: aws:apigateway:Stage
name: example
properties:
deployment: ${exampleDeployment.id}
restApi: ${example.id}
stageName: example
association:
type: aws:wafregional:WebAclAssociation
properties:
resourceArn: ${exampleStage.arn}
webAclId: ${fooWebAcl.id}
Create WebAclAssociation Resource
new WebAclAssociation(name: string, args: WebAclAssociationArgs, opts?: CustomResourceOptions);
@overload
def WebAclAssociation(resource_name: str,
opts: Optional[ResourceOptions] = None,
resource_arn: Optional[str] = None,
web_acl_id: Optional[str] = None)
@overload
def WebAclAssociation(resource_name: str,
args: WebAclAssociationArgs,
opts: Optional[ResourceOptions] = None)
func NewWebAclAssociation(ctx *Context, name string, args WebAclAssociationArgs, opts ...ResourceOption) (*WebAclAssociation, error)
public WebAclAssociation(string name, WebAclAssociationArgs args, CustomResourceOptions? opts = null)
public WebAclAssociation(String name, WebAclAssociationArgs args)
public WebAclAssociation(String name, WebAclAssociationArgs args, CustomResourceOptions options)
type: aws:wafregional:WebAclAssociation
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args WebAclAssociationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args WebAclAssociationArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args WebAclAssociationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args WebAclAssociationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args WebAclAssociationArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
WebAclAssociation Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The WebAclAssociation resource accepts the following input properties:
- Resource
Arn string - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- Web
Acl stringId - The ID of the WAF Regional WebACL to create an association.
- Resource
Arn string - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- Web
Acl stringId - The ID of the WAF Regional WebACL to create an association.
- resource
Arn String - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web
Acl StringId - The ID of the WAF Regional WebACL to create an association.
- resource
Arn string - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web
Acl stringId - The ID of the WAF Regional WebACL to create an association.
- resource_
arn str - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web_
acl_ strid - The ID of the WAF Regional WebACL to create an association.
- resource
Arn String - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web
Acl StringId - The ID of the WAF Regional WebACL to create an association.
Outputs
All input properties are implicitly available as output properties. Additionally, the WebAclAssociation resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing WebAclAssociation Resource
Get an existing WebAclAssociation 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?: WebAclAssociationState, opts?: CustomResourceOptions): WebAclAssociation
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
resource_arn: Optional[str] = None,
web_acl_id: Optional[str] = None) -> WebAclAssociation
func GetWebAclAssociation(ctx *Context, name string, id IDInput, state *WebAclAssociationState, opts ...ResourceOption) (*WebAclAssociation, error)
public static WebAclAssociation Get(string name, Input<string> id, WebAclAssociationState? state, CustomResourceOptions? opts = null)
public static WebAclAssociation get(String name, Output<String> id, WebAclAssociationState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- 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
Arn string - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- Web
Acl stringId - The ID of the WAF Regional WebACL to create an association.
- Resource
Arn string - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- Web
Acl stringId - The ID of the WAF Regional WebACL to create an association.
- resource
Arn String - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web
Acl StringId - The ID of the WAF Regional WebACL to create an association.
- resource
Arn string - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web
Acl stringId - The ID of the WAF Regional WebACL to create an association.
- resource_
arn str - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web_
acl_ strid - The ID of the WAF Regional WebACL to create an association.
- resource
Arn String - ARN of the resource to associate with. For example, an Application Load Balancer or API Gateway Stage.
- web
Acl StringId - The ID of the WAF Regional WebACL to create an association.
Import
Using pulumi import
, import WAF Regional Web ACL Association using their web_acl_id:resource_arn
. For example:
$ pulumi import aws:wafregional/webAclAssociation:WebAclAssociation foo web_acl_id:resource_arn
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.