Represent WAAP Policy
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gcore from "@pulumi/gcore";
const cdnResource = new gcore.CdnResource("cdn_resource", {
cname: "api.example.com",
origin: "origin.example.com",
options: {
waap: {
value: true,
},
},
});
const domain = new gcore.WaapDomain("domain", {
name: cdnResource.cname,
status: "monitor",
});
const invalidUserAgent = domain.waapDomainId.apply(waapDomainId => gcore.getWaapDomainPolicyOutput({
domainId: waapDomainId,
name: "Invalid user agent",
group: "PROTOCOL",
}));
const wafSqlInjection = domain.waapDomainId.apply(waapDomainId => gcore.getWaapDomainPolicyOutput({
domainId: waapDomainId,
name: "SQL injection",
group: "WAF",
}));
const domainPolicy = new gcore.WaapPolicy("domain_policy", {
domainId: domain.waapDomainId,
policies: pulumi.all([invalidUserAgent, wafSqlInjection]).apply(([invalidUserAgent, wafSqlInjection]) => {
[invalidUserAgent.id]: false,
[wafSqlInjection.id]: true,
S55075105: true,
S55075106: true,
S55075107: true,
}),
});
import pulumi
import pulumi_gcore as gcore
cdn_resource = gcore.CdnResource("cdn_resource",
cname="api.example.com",
origin="origin.example.com",
options={
"waap": {
"value": True,
},
})
domain = gcore.WaapDomain("domain",
name=cdn_resource.cname,
status="monitor")
invalid_user_agent = domain.waap_domain_id.apply(lambda waap_domain_id: gcore.get_waap_domain_policy_output(domain_id=waap_domain_id,
name="Invalid user agent",
group="PROTOCOL"))
waf_sql_injection = domain.waap_domain_id.apply(lambda waap_domain_id: gcore.get_waap_domain_policy_output(domain_id=waap_domain_id,
name="SQL injection",
group="WAF"))
domain_policy = gcore.WaapPolicy("domain_policy",
domain_id=domain.waap_domain_id,
policies=pulumi.Output.all(
invalid_user_agent=invalid_user_agent,
waf_sql_injection=waf_sql_injection
).apply(lambda resolved_outputs: {
resolved_outputs['invalid_user_agent']: False,
resolved_outputs['waf_sql_injection']: True,
"S55075105": True,
"S55075106": True,
"S55075107": True,
})
)
Example coming soon!
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcore = Pulumi.Gcore;
return await Deployment.RunAsync(() =>
{
var cdnResource = new Gcore.CdnResource("cdn_resource", new()
{
Cname = "api.example.com",
Origin = "origin.example.com",
Options = new Gcore.Inputs.CdnResourceOptionsArgs
{
Waap = new Gcore.Inputs.CdnResourceOptionsWaapArgs
{
Value = true,
},
},
});
var domain = new Gcore.WaapDomain("domain", new()
{
Name = cdnResource.Cname,
Status = "monitor",
});
var invalidUserAgent = Gcore.GetWaapDomainPolicy.Invoke(new()
{
DomainId = domain.WaapDomainId,
Name = "Invalid user agent",
Group = "PROTOCOL",
});
var wafSqlInjection = Gcore.GetWaapDomainPolicy.Invoke(new()
{
DomainId = domain.WaapDomainId,
Name = "SQL injection",
Group = "WAF",
});
var domainPolicy = new Gcore.WaapPolicy("domain_policy", new()
{
DomainId = domain.WaapDomainId,
Policies = Output.Tuple(invalidUserAgent, wafSqlInjection).Apply(values =>
{
var invalidUserAgent = values.Item1;
var wafSqlInjection = values.Item2;
return
{
{ invalidUserAgent.Apply(getWaapDomainPolicyResult => getWaapDomainPolicyResult.Id), false },
{ wafSqlInjection.Apply(getWaapDomainPolicyResult => getWaapDomainPolicyResult.Id), true },
{ "S55075105", true },
{ "S55075106", true },
{ "S55075107", true },
};
}),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcore.CdnResource;
import com.pulumi.gcore.CdnResourceArgs;
import com.pulumi.gcore.inputs.CdnResourceOptionsArgs;
import com.pulumi.gcore.inputs.CdnResourceOptionsWaapArgs;
import com.pulumi.gcore.WaapDomain;
import com.pulumi.gcore.WaapDomainArgs;
import com.pulumi.gcore.GcoreFunctions;
import com.pulumi.gcore.inputs.GetWaapDomainPolicyArgs;
import com.pulumi.gcore.WaapPolicy;
import com.pulumi.gcore.WaapPolicyArgs;
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 cdnResource = new CdnResource("cdnResource", CdnResourceArgs.builder()
.cname("api.example.com")
.origin("origin.example.com")
.options(CdnResourceOptionsArgs.builder()
.waap(CdnResourceOptionsWaapArgs.builder()
.value(true)
.build())
.build())
.build());
var domain = new WaapDomain("domain", WaapDomainArgs.builder()
.name(cdnResource.cname())
.status("monitor")
.build());
final var invalidUserAgent = domain.waapDomainId().applyValue(_waapDomainId -> GcoreFunctions.getWaapDomainPolicy(GetWaapDomainPolicyArgs.builder()
.domainId(_waapDomainId)
.name("Invalid user agent")
.group("PROTOCOL")
.build()));
final var wafSqlInjection = domain.waapDomainId().applyValue(_waapDomainId -> GcoreFunctions.getWaapDomainPolicy(GetWaapDomainPolicyArgs.builder()
.domainId(_waapDomainId)
.name("SQL injection")
.group("WAF")
.build()));
var domainPolicy = new WaapPolicy("domainPolicy", WaapPolicyArgs.builder()
.domainId(domain.waapDomainId())
.policies(Output.tuple(invalidUserAgent, wafSqlInjection).applyValue(values -> {
var invalidUserAgent = values.t1;
var wafSqlInjection = values.t2;
return Map.ofEntries(
Map.entry(invalidUserAgent.id(), false),
Map.entry(wafSqlInjection.id(), true),
Map.entry("S55075105", true),
Map.entry("S55075106", true),
Map.entry("S55075107", true)
);
}))
.build());
}
}
resources:
cdnResource:
type: gcore:CdnResource
name: cdn_resource
properties:
cname: api.example.com
origin: origin.example.com
options:
waap:
value: true
domain:
type: gcore:WaapDomain
properties:
name: ${cdnResource.cname}
status: monitor
domainPolicy:
type: gcore:WaapPolicy
name: domain_policy
properties:
domainId: ${domain.waapDomainId}
policies:
${invalidUserAgent.id}: false
${wafSqlInjection.id}: true
S55075105: true
S55075106: true
S55075107: true
variables:
invalidUserAgent:
fn::invoke:
function: gcore:getWaapDomainPolicy
arguments:
domainId: ${domain.waapDomainId}
name: Invalid user agent
group: PROTOCOL
wafSqlInjection:
fn::invoke:
function: gcore:getWaapDomainPolicy
arguments:
domainId: ${domain.waapDomainId}
name: SQL injection
group: WAF
Create WaapPolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new WaapPolicy(name: string, args: WaapPolicyArgs, opts?: CustomResourceOptions);@overload
def WaapPolicy(resource_name: str,
args: WaapPolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def WaapPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
domain_id: Optional[str] = None,
policies: Optional[Mapping[str, bool]] = None,
waap_policy_id: Optional[str] = None)func NewWaapPolicy(ctx *Context, name string, args WaapPolicyArgs, opts ...ResourceOption) (*WaapPolicy, error)public WaapPolicy(string name, WaapPolicyArgs args, CustomResourceOptions? opts = null)
public WaapPolicy(String name, WaapPolicyArgs args)
public WaapPolicy(String name, WaapPolicyArgs args, CustomResourceOptions options)
type: gcore:WaapPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args WaapPolicyArgs
- 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 WaapPolicyArgs
- 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 WaapPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args WaapPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args WaapPolicyArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var waapPolicyResource = new Gcore.WaapPolicy("waapPolicyResource", new()
{
DomainId = "string",
Policies =
{
{ "string", false },
},
WaapPolicyId = "string",
});
example, err := gcore.NewWaapPolicy(ctx, "waapPolicyResource", &gcore.WaapPolicyArgs{
DomainId: pulumi.String("string"),
Policies: pulumi.BoolMap{
"string": pulumi.Bool(false),
},
WaapPolicyId: pulumi.String("string"),
})
var waapPolicyResource = new WaapPolicy("waapPolicyResource", WaapPolicyArgs.builder()
.domainId("string")
.policies(Map.of("string", false))
.waapPolicyId("string")
.build());
waap_policy_resource = gcore.WaapPolicy("waapPolicyResource",
domain_id="string",
policies={
"string": False,
},
waap_policy_id="string")
const waapPolicyResource = new gcore.WaapPolicy("waapPolicyResource", {
domainId: "string",
policies: {
string: false,
},
waapPolicyId: "string",
});
type: gcore:WaapPolicy
properties:
domainId: string
policies:
string: false
waapPolicyId: string
WaapPolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The WaapPolicy resource accepts the following input properties:
- Domain
Id string - The WAAP domain ID for which the Policy is configured.
- Policies Dictionary<string, bool>
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- Waap
Policy stringId - The ID of this resource.
- Domain
Id string - The WAAP domain ID for which the Policy is configured.
- Policies map[string]bool
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- Waap
Policy stringId - The ID of this resource.
- domain
Id String - The WAAP domain ID for which the Policy is configured.
- policies Map<String,Boolean>
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap
Policy StringId - The ID of this resource.
- domain
Id string - The WAAP domain ID for which the Policy is configured.
- policies {[key: string]: boolean}
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap
Policy stringId - The ID of this resource.
- domain_
id str - The WAAP domain ID for which the Policy is configured.
- policies Mapping[str, bool]
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap_
policy_ strid - The ID of this resource.
- domain
Id String - The WAAP domain ID for which the Policy is configured.
- policies Map<Boolean>
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap
Policy StringId - The ID of this resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the WaapPolicy 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 WaapPolicy Resource
Get an existing WaapPolicy 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?: WaapPolicyState, opts?: CustomResourceOptions): WaapPolicy@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
domain_id: Optional[str] = None,
policies: Optional[Mapping[str, bool]] = None,
waap_policy_id: Optional[str] = None) -> WaapPolicyfunc GetWaapPolicy(ctx *Context, name string, id IDInput, state *WaapPolicyState, opts ...ResourceOption) (*WaapPolicy, error)public static WaapPolicy Get(string name, Input<string> id, WaapPolicyState? state, CustomResourceOptions? opts = null)public static WaapPolicy get(String name, Output<String> id, WaapPolicyState state, CustomResourceOptions options)resources: _: type: gcore:WaapPolicy get: id: ${id}- 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.
- Domain
Id string - The WAAP domain ID for which the Policy is configured.
- Policies Dictionary<string, bool>
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- Waap
Policy stringId - The ID of this resource.
- Domain
Id string - The WAAP domain ID for which the Policy is configured.
- Policies map[string]bool
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- Waap
Policy stringId - The ID of this resource.
- domain
Id String - The WAAP domain ID for which the Policy is configured.
- policies Map<String,Boolean>
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap
Policy StringId - The ID of this resource.
- domain
Id string - The WAAP domain ID for which the Policy is configured.
- policies {[key: string]: boolean}
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap
Policy stringId - The ID of this resource.
- domain_
id str - The WAAP domain ID for which the Policy is configured.
- policies Mapping[str, bool]
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap_
policy_ strid - The ID of this resource.
- domain
Id String - The WAAP domain ID for which the Policy is configured.
- policies Map<Boolean>
- A map of policies where each key is a policy ID and the value is a boolean indicating whether the policy is enabled (true) or disabled (false). Policy IDs can be obtained from the API endpoint /v1/domains/{domainid}/rule-sets (the 'rules' field) or you can use the gcorewaapdomainpolicy data source.
- waap
Policy StringId - The ID of this resource.
Package Details
- Repository
- gcore g-core/terraform-provider-gcore
- License
- Notes
- This Pulumi package is based on the
gcoreTerraform Provider.
