@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
403 lines • 14.8 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleGroup = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Creates a WAFv2 Rule Group resource.
*
* ## Example Usage
*
* ### Simple
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.wafv2.RuleGroup("example", {
* name: "example-rule",
* scope: "REGIONAL",
* capacity: 2,
* rules: [{
* name: "rule-1",
* priority: 1,
* action: {
* allow: {},
* },
* statement: {
* geoMatchStatement: {
* countryCodes: [
* "US",
* "NL",
* ],
* },
* },
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "friendly-rule-metric-name",
* sampledRequestsEnabled: false,
* },
* }],
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "friendly-metric-name",
* sampledRequestsEnabled: false,
* },
* });
* ```
*
* ### Complex
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const test = new aws.wafv2.IpSet("test", {
* name: "test",
* scope: "REGIONAL",
* ipAddressVersion: "IPV4",
* addresses: [
* "1.1.1.1/32",
* "2.2.2.2/32",
* ],
* });
* const testRegexPatternSet = new aws.wafv2.RegexPatternSet("test", {
* name: "test",
* scope: "REGIONAL",
* regularExpressions: [{
* regexString: "one",
* }],
* });
* const example = new aws.wafv2.RuleGroup("example", {
* name: "complex-example",
* description: "An rule group containing all statements",
* scope: "REGIONAL",
* capacity: 500,
* rules: [
* {
* name: "rule-1",
* priority: 1,
* action: {
* block: {},
* },
* statement: {
* notStatement: {
* statements: [{
* andStatement: {
* statements: [
* {
* geoMatchStatement: {
* countryCodes: ["US"],
* },
* },
* {
* byteMatchStatement: {
* positionalConstraint: "CONTAINS",
* searchString: "word",
* fieldToMatch: {
* allQueryArguments: {},
* },
* textTransformations: [
* {
* priority: 5,
* type: "CMD_LINE",
* },
* {
* priority: 2,
* type: "LOWERCASE",
* },
* ],
* },
* },
* ],
* },
* }],
* },
* },
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "rule-1",
* sampledRequestsEnabled: false,
* },
* },
* {
* name: "rule-2",
* priority: 2,
* action: {
* count: {},
* },
* statement: {
* orStatement: {
* statements: [
* {
* regexMatchStatement: {
* regexString: "a-z?",
* fieldToMatch: {
* singleHeader: {
* name: "user-agent",
* },
* },
* textTransformations: [{
* priority: 6,
* type: "NONE",
* }],
* },
* },
* {
* sqliMatchStatement: {
* fieldToMatch: {
* body: {},
* },
* textTransformations: [
* {
* priority: 5,
* type: "URL_DECODE",
* },
* {
* priority: 4,
* type: "HTML_ENTITY_DECODE",
* },
* {
* priority: 3,
* type: "COMPRESS_WHITE_SPACE",
* },
* ],
* },
* },
* {
* xssMatchStatement: {
* fieldToMatch: {
* method: {},
* },
* textTransformations: [{
* priority: 2,
* type: "NONE",
* }],
* },
* },
* ],
* },
* },
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "rule-2",
* sampledRequestsEnabled: false,
* },
* captchaConfig: {
* immunityTimeProperty: {
* immunityTime: 240,
* },
* },
* },
* {
* name: "rule-3",
* priority: 3,
* action: {
* block: {},
* },
* statement: {
* sizeConstraintStatement: {
* comparisonOperator: "GT",
* size: 100,
* fieldToMatch: {
* singleQueryArgument: {
* name: "username",
* },
* },
* textTransformations: [{
* priority: 5,
* type: "NONE",
* }],
* },
* },
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "rule-3",
* sampledRequestsEnabled: false,
* },
* },
* {
* name: "rule-4",
* priority: 4,
* action: {
* block: {},
* },
* statement: {
* orStatement: {
* statements: [
* {
* ipSetReferenceStatement: {
* arn: test.arn,
* },
* },
* {
* regexPatternSetReferenceStatement: {
* arn: testRegexPatternSet.arn,
* fieldToMatch: {
* singleHeader: {
* name: "referer",
* },
* },
* textTransformations: [{
* priority: 2,
* type: "NONE",
* }],
* },
* },
* ],
* },
* },
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "rule-4",
* sampledRequestsEnabled: false,
* },
* },
* ],
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "friendly-metric-name",
* sampledRequestsEnabled: false,
* },
* captchaConfig: [{
* immunityTimeProperty: [{
* immunityTime: 120,
* }],
* }],
* tags: {
* Name: "example-and-statement",
* Code: "123456",
* },
* });
* ```
*
* ### Using rulesJson
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.wafv2.RuleGroup("example", {
* name: "example-rule-group",
* scope: "REGIONAL",
* capacity: 100,
* rulesJson: JSON.stringify([{
* Name: "rule-1",
* Priority: 1,
* Action: {
* Count: {},
* },
* Statement: {
* ByteMatchStatement: {
* SearchString: "badbot",
* FieldToMatch: {
* UriPath: {},
* },
* TextTransformations: [{
* Priority: 1,
* Type: "NONE",
* }],
* PositionalConstraint: "CONTAINS",
* },
* },
* VisibilityConfig: {
* CloudwatchMetricsEnabled: false,
* MetricName: "friendly-rule-metric-name",
* SampledRequestsEnabled: false,
* },
* }]),
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "friendly-metric-name",
* sampledRequestsEnabled: false,
* },
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import WAFv2 Rule Group using `ID/name/scope`. For example:
*
* ```sh
* $ pulumi import aws:wafv2/ruleGroup:RuleGroup example a1b2c3d4-d5f6-7777-8888-9999aaaabbbbcccc/example/REGIONAL
* ```
*/
class RuleGroup extends pulumi.CustomResource {
/**
* Get an existing RuleGroup resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new RuleGroup(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of RuleGroup. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === RuleGroup.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["capacity"] = state?.capacity;
resourceInputs["customResponseBodies"] = state?.customResponseBodies;
resourceInputs["description"] = state?.description;
resourceInputs["lockToken"] = state?.lockToken;
resourceInputs["name"] = state?.name;
resourceInputs["namePrefix"] = state?.namePrefix;
resourceInputs["region"] = state?.region;
resourceInputs["rules"] = state?.rules;
resourceInputs["rulesJson"] = state?.rulesJson;
resourceInputs["scope"] = state?.scope;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
resourceInputs["visibilityConfig"] = state?.visibilityConfig;
}
else {
const args = argsOrState;
if (args?.capacity === undefined && !opts.urn) {
throw new Error("Missing required property 'capacity'");
}
if (args?.scope === undefined && !opts.urn) {
throw new Error("Missing required property 'scope'");
}
if (args?.visibilityConfig === undefined && !opts.urn) {
throw new Error("Missing required property 'visibilityConfig'");
}
resourceInputs["capacity"] = args?.capacity;
resourceInputs["customResponseBodies"] = args?.customResponseBodies;
resourceInputs["description"] = args?.description;
resourceInputs["name"] = args?.name;
resourceInputs["namePrefix"] = args?.namePrefix;
resourceInputs["region"] = args?.region;
resourceInputs["rules"] = args?.rules;
resourceInputs["rulesJson"] = args?.rulesJson;
resourceInputs["scope"] = args?.scope;
resourceInputs["tags"] = args?.tags;
resourceInputs["visibilityConfig"] = args?.visibilityConfig;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["lockToken"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(RuleGroup.__pulumiType, name, resourceInputs, opts);
}
}
exports.RuleGroup = RuleGroup;
/** @internal */
RuleGroup.__pulumiType = 'aws:wafv2/ruleGroup:RuleGroup';
//# sourceMappingURL=ruleGroup.js.map