Akamai

v3.0.0 published on Monday, Jul 25, 2022 by Pulumi

AppSecRule

Scopes: Rule

Modifies a Kona Rule Set rule’s action, conditions, and exceptions.

Related API Endpoints: /appsec/v1/configs/{configId}/versions/{versionNumber}/security-policies/{policyId}/rules/{ruleId} and /appsec/v1/configs/{configId}/versions/{versionNumber}/security-policies/{policyId}/rules/{ruleId}/condition-exception

Example Usage

using System.IO;
using Pulumi;
using Akamai = Pulumi.Akamai;

class MyStack : Stack
{
    public MyStack()
    {
        var configuration = Output.Create(Akamai.GetAppSecConfiguration.InvokeAsync(new Akamai.GetAppSecConfigurationArgs
        {
            Name = "Documentation",
        }));
        var rule = new Akamai.AppSecRule("rule", new Akamai.AppSecRuleArgs
        {
            ConfigId = configuration.Apply(configuration => configuration.ConfigId),
            SecurityPolicyId = "gms1_134637",
            RuleId = 60029316,
            RuleAction = "deny",
            ConditionException = File.ReadAllText($"{path.Module}/condition_exception.json"),
        });
    }

}
package main

import (
	"fmt"
	"io/ioutil"

	"github.com/pulumi/pulumi-akamai/sdk/v3/go/akamai"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func readFileOrPanic(path string) pulumi.StringPtrInput {
	data, err := ioutil.ReadFile(path)
	if err != nil {
		panic(err.Error())
	}
	return pulumi.String(string(data))
}

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		configuration, err := akamai.LookupAppSecConfiguration(ctx, &GetAppSecConfigurationArgs{
			Name: pulumi.StringRef("Documentation"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = akamai.NewAppSecRule(ctx, "rule", &akamai.AppSecRuleArgs{
			ConfigId:           pulumi.Int(configuration.ConfigId),
			SecurityPolicyId:   pulumi.String("gms1_134637"),
			RuleId:             pulumi.Int(60029316),
			RuleAction:         pulumi.String("deny"),
			ConditionException: readFileOrPanic(fmt.Sprintf("%v/condition_exception.json", path.Module)),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.akamai.AkamaiFunctions;
import com.pulumi.akamai.inputs.GetAppSecConfigurationArgs;
import com.pulumi.akamai.AppSecRule;
import com.pulumi.akamai.AppSecRuleArgs;
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) {
        final var configuration = AkamaiFunctions.getAppSecConfiguration(GetAppSecConfigurationArgs.builder()
            .name("Documentation")
            .build());

        var rule = new AppSecRule("rule", AppSecRuleArgs.builder()        
            .configId(configuration.applyValue(getAppSecConfigurationResult -> getAppSecConfigurationResult.configId()))
            .securityPolicyId("gms1_134637")
            .ruleId(60029316)
            .ruleAction("deny")
            .conditionException(Files.readString(Paths.get(String.format("%s/condition_exception.json", path.module()))))
            .build());

    }
}
import pulumi
import pulumi_akamai as akamai

configuration = akamai.get_app_sec_configuration(name="Documentation")
rule = akamai.AppSecRule("rule",
    config_id=configuration.config_id,
    security_policy_id="gms1_134637",
    rule_id=60029316,
    rule_action="deny",
    condition_exception=(lambda path: open(path).read())(f"{path['module']}/condition_exception.json"))
import * as pulumi from "@pulumi/pulumi";
import * as akamai from "@pulumi/akamai";
import * as fs from "fs";

const configuration = akamai.getAppSecConfiguration({
    name: "Documentation",
});
const rule = new akamai.AppSecRule("rule", {
    configId: configuration.then(configuration => configuration.configId),
    securityPolicyId: "gms1_134637",
    ruleId: 60029316,
    ruleAction: "deny",
    conditionException: fs.readFileSync(`${path.module}/condition_exception.json`),
});

Coming soon!

Create a AppSecRule Resource

new AppSecRule(name: string, args: AppSecRuleArgs, opts?: CustomResourceOptions);
@overload
def AppSecRule(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               condition_exception: Optional[str] = None,
               config_id: Optional[int] = None,
               rule_action: Optional[str] = None,
               rule_id: Optional[int] = None,
               security_policy_id: Optional[str] = None)
@overload
def AppSecRule(resource_name: str,
               args: AppSecRuleArgs,
               opts: Optional[ResourceOptions] = None)
func NewAppSecRule(ctx *Context, name string, args AppSecRuleArgs, opts ...ResourceOption) (*AppSecRule, error)
public AppSecRule(string name, AppSecRuleArgs args, CustomResourceOptions? opts = null)
public AppSecRule(String name, AppSecRuleArgs args)
public AppSecRule(String name, AppSecRuleArgs args, CustomResourceOptions options)
type: akamai:AppSecRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args AppSecRuleArgs
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 AppSecRuleArgs
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 AppSecRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AppSecRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args AppSecRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

AppSecRule 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 AppSecRule resource accepts the following input properties:

ConfigId int

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

RuleId int

. Unique identifier of the rule being modified.

SecurityPolicyId string

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

ConditionException string

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

RuleAction string

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
ConfigId int

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

RuleId int

. Unique identifier of the rule being modified.

SecurityPolicyId string

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

ConditionException string

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

RuleAction string

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
configId Integer

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

ruleId Integer

. Unique identifier of the rule being modified.

securityPolicyId String

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

conditionException String

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

ruleAction String

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
configId number

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

ruleId number

. Unique identifier of the rule being modified.

securityPolicyId string

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

conditionException string

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

ruleAction string

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
config_id int

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

rule_id int

. Unique identifier of the rule being modified.

security_policy_id str

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

condition_exception str

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

rule_action str

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
configId Number

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

ruleId Number

. Unique identifier of the rule being modified.

securityPolicyId String

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

conditionException String

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

ruleAction String

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.

Outputs

All input properties are implicitly available as output properties. Additionally, the AppSecRule 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 an Existing AppSecRule Resource

Get an existing AppSecRule 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?: AppSecRuleState, opts?: CustomResourceOptions): AppSecRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        condition_exception: Optional[str] = None,
        config_id: Optional[int] = None,
        rule_action: Optional[str] = None,
        rule_id: Optional[int] = None,
        security_policy_id: Optional[str] = None) -> AppSecRule
func GetAppSecRule(ctx *Context, name string, id IDInput, state *AppSecRuleState, opts ...ResourceOption) (*AppSecRule, error)
public static AppSecRule Get(string name, Input<string> id, AppSecRuleState? state, CustomResourceOptions? opts = null)
public static AppSecRule get(String name, Output<String> id, AppSecRuleState 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.
The following state arguments are supported:
ConditionException string

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

ConfigId int

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

RuleAction string

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
RuleId int

. Unique identifier of the rule being modified.

SecurityPolicyId string

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

ConditionException string

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

ConfigId int

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

RuleAction string

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
RuleId int

. Unique identifier of the rule being modified.

SecurityPolicyId string

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

conditionException String

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

configId Integer

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

ruleAction String

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
ruleId Integer

. Unique identifier of the rule being modified.

securityPolicyId String

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

conditionException string

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

configId number

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

ruleAction string

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
ruleId number

. Unique identifier of the rule being modified.

securityPolicyId string

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

condition_exception str

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

config_id int

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

rule_action str

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
rule_id int

. Unique identifier of the rule being modified.

security_policy_id str

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

conditionException String

. Path to a JSON file containing a description of the conditions and exceptions to be associated with a rule. You can view a sample JSON file in the Modify the conditions and exceptions of a rule section of the Application Security API documentation.

configId Number

. Unique identifier of the security configuration associated with the Kona Rule Set rule being modified.

ruleAction String

Allowed values are:

  • alert. Record the event.
  • deny. Block the request.
  • **deny_custom_{custom_deny_id}**. Take the action specified by the custom deny.
  • none. Take no action. or none to take no action.
ruleId Number

. Unique identifier of the rule being modified.

securityPolicyId String

. Unique identifier of the security policy associated with the Kona Rule Set rule being modified.

Package Details

Repository
https://github.com/pulumi/pulumi-akamai
License
Apache-2.0
Notes

This Pulumi package is based on the akamai Terraform Provider.