AuthzPolicy class
AuthzPolicy is a resource that allows to forward traffic to a callout backend designed to scan the traffic for security purposes.
To get more information about AuthzPolicy, see:
Example Usage
Network Security Authz Policy Mcp
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const project = gcp.organizations.getProject({});
const _default = new gcp.networksecurity.AuthzPolicy("default", {
name: "my-mcp-policy",
location: "us-west1",
target: {
resources: [project.then(project => `projects/${project.projectId}/locations/us-west1/agentGateways/gateway1`)],
},
policyProfile: "REQUEST_AUTHZ",
action: "ALLOW",
httpRules: [{
to: {
operations: [{
mcp: {
baseProtocolMethodsOption: "MATCH_BASE_PROTOCOL_METHODS",
methods: [
{
name: "tools",
},
{
name: "tools/call",
params: [{
exact: "foo",
}],
},
],
},
}],
},
}],
});
import pulumi
import pulumi_gcp as gcp
project = gcp.organizations.get_project()
default = gcp.networksecurity.AuthzPolicy("default",
name="my-mcp-policy",
location="us-west1",
target={
"resources": [f"projects/{project.project_id}/locations/us-west1/agentGateways/gateway1"],
},
policy_profile="REQUEST_AUTHZ",
action="ALLOW",
http_rules=[{
"to": {
"operations": [{
"mcp": {
"base_protocol_methods_option": "MATCH_BASE_PROTOCOL_METHODS",
"methods": [
{
"name": "tools",
},
{
"name": "tools/call",
"params": [{
"exact": "foo",
}],
},
],
},
}],
},
}])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var project = Gcp.Organizations.GetProject.Invoke();
var @default = new Gcp.NetworkSecurity.AuthzPolicy("default", new()
{
Name = "my-mcp-policy",
Location = "us-west1",
Target = new Gcp.NetworkSecurity.Inputs.AuthzPolicyTargetArgs
{
Resources = new[]
{
$"projects/{project.Apply(getProjectResult => getProjectResult.ProjectId)}/locations/us-west1/agentGateways/gateway1",
},
},
PolicyProfile = "REQUEST_AUTHZ",
Action = "ALLOW",
HttpRules = new[]
{
new Gcp.NetworkSecurity.Inputs.AuthzPolicyHttpRuleArgs
{
To = new Gcp.NetworkSecurity.Inputs.AuthzPolicyHttpRuleToArgs
{
Operations = new[]
{
new Gcp.NetworkSecurity.Inputs.AuthzPolicyHttpRuleToOperationArgs
{
Mcp = new Gcp.NetworkSecurity.Inputs.AuthzPolicyHttpRuleToOperationMcpArgs
{
BaseProtocolMethodsOption = "MATCH_BASE_PROTOCOL_METHODS",
Methods = new[]
{
new Gcp.NetworkSecurity.Inputs.AuthzPolicyHttpRuleToOperationMcpMethodArgs
{
Name = "tools",
},
new Gcp.NetworkSecurity.Inputs.AuthzPolicyHttpRuleToOperationMcpMethodArgs
{
Name = "tools/call",
Params = new[]
{
new Gcp.NetworkSecurity.Inputs.AuthzPolicyHttpRuleToOperationMcpMethodParamArgs
{
Exact = "foo",
},
},
},
},
},
},
},
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/networksecurity"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
project, err := organizations.LookupProject(ctx, &organizations.LookupProjectArgs{}, nil)
if err != nil {
return err
}
_, err = networksecurity.NewAuthzPolicy(ctx, "default", &networksecurity.AuthzPolicyArgs{
Name: pulumi.String("my-mcp-policy"),
Location: pulumi.String("us-west1"),
Target: &networksecurity.AuthzPolicyTargetArgs{
Resources: pulumi.StringArray{
pulumi.Sprintf("projects/%v/locations/us-west1/agentGateways/gateway1", project.ProjectId),
},
},
PolicyProfile: pulumi.String("REQUEST_AUTHZ"),
Action: pulumi.String("ALLOW"),
HttpRules: networksecurity.AuthzPolicyHttpRuleArray{
&networksecurity.AuthzPolicyHttpRuleArgs{
To: &networksecurity.AuthzPolicyHttpRuleToArgs{
Operations: networksecurity.AuthzPolicyHttpRuleToOperationArray{
&networksecurity.AuthzPolicyHttpRuleToOperationArgs{
Mcp: &networksecurity.AuthzPolicyHttpRuleToOperationMcpArgs{
BaseProtocolMethodsOption: pulumi.String("MATCH_BASE_PROTOCOL_METHODS"),
Methods: networksecurity.AuthzPolicyHttpRuleToOperationMcpMethodArray{
&networksecurity.AuthzPolicyHttpRuleToOperationMcpMethodArgs{
Name: pulumi.String("tools"),
},
&networksecurity.AuthzPolicyHttpRuleToOperationMcpMethodArgs{
Name: pulumi.String("tools/call"),
Params: networksecurity.AuthzPolicyHttpRuleToOperationMcpMethodParamArray{
&networksecurity.AuthzPolicyHttpRuleToOperationMcpMethodParamArgs{
Exact: pulumi.String("foo"),
},
},
},
},
},
},
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
data "gcp_organizations_getproject" "project" {
}
resource "gcp_networksecurity_authzpolicy" "default" {
name = "my-mcp-policy"
location = "us-west1"
target = {
resources = ["projects/${data.gcp_organizations_getproject.project.project_id}/locations/us-west1/agentGateways/gateway1"]
}
policy_profile = "REQUEST_AUTHZ"
action = "ALLOW"
http_rules {
to = {
operations = [{
"mcp" = {
"baseProtocolMethodsOption" = "MATCH_BASE_PROTOCOL_METHODS"
"methods" = [{
"name" = "tools"
}, {
"name" = "tools/call"
"params" = [{
"exact" = "foo"
}]
}]
}
}]
}
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
import com.pulumi.gcp.networksecurity.AuthzPolicy;
import com.pulumi.gcp.networksecurity.AuthzPolicyArgs;
import com.pulumi.gcp.networksecurity.inputs.AuthzPolicyTargetArgs;
import com.pulumi.gcp.networksecurity.inputs.AuthzPolicyHttpRuleArgs;
import com.pulumi.gcp.networksecurity.inputs.AuthzPolicyHttpRuleToArgs;
import com.pulumi.gcp.networksecurity.inputs.AuthzPolicyHttpRuleToOperationArgs;
import com.pulumi.gcp.networksecurity.inputs.AuthzPolicyHttpRuleToOperationMcpArgs;
import com.pulumi.gcp.networksecurity.inputs.AuthzPolicyHttpRuleToOperationMcpMethodArgs;
import com.pulumi.gcp.networksecurity.inputs.AuthzPolicyHttpRuleToOperationMcpMethodParamArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 project = OrganizationsFunctions.getProject(GetProjectArgs.builder()
.build());
var default_ = new AuthzPolicy("default", AuthzPolicyArgs.builder()
.name("my-mcp-policy")
.location("us-west1")
.target(AuthzPolicyTargetArgs.builder()
.resources(String.format("projects/%s/locations/us-west1/agentGateways/gateway1", project.projectId()))
.build())
.policyProfile("REQUEST_AUTHZ")
.action("ALLOW")
.httpRules(AuthzPolicyHttpRuleArgs.builder()
.to(AuthzPolicyHttpRuleToArgs.builder()
.operations(AuthzPolicyHttpRuleToOperationArgs.builder()
.mcp(AuthzPolicyHttpRuleToOperationMcpArgs.builder()
.baseProtocolMethodsOption("MATCH_BASE_PROTOCOL_METHODS")
.methods(
AuthzPolicyHttpRuleToOperationMcpMethodArgs.builder()
.name("tools")
.build(),
AuthzPolicyHttpRuleToOperationMcpMethodArgs.builder()
.name("tools/call")
.params(AuthzPolicyHttpRuleToOperationMcpMethodParamArgs.builder()
.exact("foo")
.build())
.build())
.build())
.build())
.build())
.build())
.build());
}
}
resources:
default:
type: gcp:networksecurity:AuthzPolicy
properties:
name: my-mcp-policy
location: us-west1
target:
resources:
- projects/${project.projectId}/locations/us-west1/agentGateways/gateway1
policyProfile: REQUEST_AUTHZ
action: ALLOW
httpRules:
- to:
operations:
- mcp:
baseProtocolMethodsOption: MATCH_BASE_PROTOCOL_METHODS
methods:
- name: tools
- name: tools/call
params:
- exact: foo
variables:
project:
fn::invoke:
function: gcp:organizations:getProject
arguments: {}
Import
AuthzPolicy can be imported using any of these accepted formats:
projects/{{project}}/locations/{{location}}/authzPolicies/{{name}}{{project}}/{{location}}/{{name}}{{location}}/{{name}}{{name}}
When using the pulumi import command, AuthzPolicy can be imported using one of the formats above. For example:
$ pulumi import gcp:networksecurity/authzPolicy:AuthzPolicy default projects/{{project}}/locations/{{location}}/authzPolicies/{{name}}
$ pulumi import gcp:networksecurity/authzPolicy:AuthzPolicy default {{project}}/{{location}}/{{name}}
$ pulumi import gcp:networksecurity/authzPolicy:AuthzPolicy default {{location}}/{{name}}
$ pulumi import gcp:networksecurity/authzPolicy:AuthzPolicy default {{name}}
Constructors
- AuthzPolicy(String name, {AuthzPolicyArgs? args, CustomResourceOptions? options})
-
Creates a new AuthzPolicy.
nameThe Pulumi resource name.argsArguments used to configure this AuthzPolicy. The set of arguments for AuthzPolicy.optionsResource options controlling this resource's behavior. - AuthzPolicy.reference(String urn)
- Creates a typed reference to an existing AuthzPolicy resource.
Properties
-
action
↔ Output<
String> -
When the action is CUSTOM, customProvider must be specified.
When the action is ALLOW, only requests matching the policy will be allowed.
When the action is DENY, only requests matching the policy will be denied.
When a request arrives, the policies are evaluated in the following order:
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
createTime
↔ Output<
String> -
The timestamp when the resource was created.
latefinal
-
customProvider
↔ Output<
AuthzPolicyCustomProvider?> -
Required if the action is CUSTOM. Allows delegating authorization decisions to Cloud IAP or to Service Extensions. One of cloudIap or authzExtension must be specified.
Structure is documented below.
latefinal
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
description
↔ Output<
String?> -
A human-readable description of the resource.
latefinal
-
effectiveLabels
↔ Output<
Map< String, String> > -
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
httpRules
↔ Output<
List< AuthzPolicyHttpRule> ?> -
A list of authorization HTTP rules to match against the incoming request.A policy match occurs when at least one HTTP rule matches the request or when no HTTP rules are specified in the policy. At least one HTTP Rule is required for Allow or Deny Action.
Limited to 5 rules.
Structure is documented below.
latefinal
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
labels
↔ Output<
Map< String, String> ?> -
Set of labels associated with the AuthzExtension resource.
latefinal
-
location
↔ Output<
String> -
The location of the resource.
latefinal
-
name
↔ Output<
String> -
Identifier. Name of the AuthzPolicy resource.
latefinal
-
networkRules
↔ Output<
List< AuthzPolicyNetworkRule> ?> -
A list of authorization HTTP rules to match against the incoming request.A policy match occurs when at least one HTTP rule matches the request or when no HTTP rules are specified in the policy. At least one HTTP Rule is required for Allow or Deny Action.
Limited to 5 rules.
Structure is documented below.
latefinal
-
policyProfile
↔ Output<
String> -
Defines the type of authorization being performed.
REQUEST_AUTHZapplies to request authorization. CUSTOM authorization policies with Authz extensions will be allowed with extAuthz or extProc protocols. Extensions are invoked only once when the request headers arrive.CONTENT_AUTHZapplies to content security, sanitization, etc. Only CUSTOM action is allowed in this policy profile. AuthzExtensions in the custom provider must support extProc protocol and be capable of receiving all extProc events (REQUEST_HEADERS, REQUEST_BODY, REQUEST_TRAILERS, RESPONSE_HEADERS, RESPONSE_BODY, RESPONSE_TRAILERS) with FULL_DUPLEX_STREAMED body send mode. Possible values are:REQUEST_AUTHZ,CONTENT_AUTHZ.latefinal -
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
pulumiLabels
↔ Output<
Map< String, String> > -
The combination of labels configured directly on the resource
and default labels configured on the provider.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
target
↔ Output<
AuthzPolicyTarget> -
Specifies the set of resources to which this policy should be applied to.
Structure is documented below.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
updateTime
↔ Output<
String> -
The timestamp when the resource was updated.
latefinal
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {AuthzPolicyState? state, CustomResourceOptions? options}) → AuthzPolicy -
Gets an existing AuthzPolicy resource's state with the given
nameandid.