Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.gcp.networksecurity.kotlin.AuthorizationPolicy.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.gcp.networksecurity.kotlin
import com.pulumi.core.Output
import com.pulumi.gcp.networksecurity.kotlin.outputs.AuthorizationPolicyRule
import com.pulumi.gcp.networksecurity.kotlin.outputs.AuthorizationPolicyRule.Companion.toKotlin
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
/**
* Builder for [AuthorizationPolicy].
*/
@PulumiTagMarker
public class AuthorizationPolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: AuthorizationPolicyArgs = AuthorizationPolicyArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend AuthorizationPolicyArgsBuilder.() -> Unit) {
val builder = AuthorizationPolicyArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): AuthorizationPolicy {
val builtJavaResource =
com.pulumi.gcp.networksecurity.AuthorizationPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return AuthorizationPolicy(builtJavaResource)
}
}
/**
* ## Example Usage
* ### Network Security Authorization Policy Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.networksecurity.AuthorizationPolicy("default", {
* name: "my-authorization-policy",
* labels: {
* foo: "bar",
* },
* description: "my description",
* action: "ALLOW",
* rules: [{
* sources: [{
* principals: ["namespace/*"],
* ipBlocks: ["1.2.3.0/24"],
* }],
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.networksecurity.AuthorizationPolicy("default",
* name="my-authorization-policy",
* labels={
* "foo": "bar",
* },
* description="my description",
* action="ALLOW",
* rules=[{
* "sources": [{
* "principals": ["namespace/*"],
* "ip_blocks": ["1.2.3.0/24"],
* }],
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.NetworkSecurity.AuthorizationPolicy("default", new()
* {
* Name = "my-authorization-policy",
* Labels =
* {
* { "foo", "bar" },
* },
* Description = "my description",
* Action = "ALLOW",
* Rules = new[]
* {
* new Gcp.NetworkSecurity.Inputs.AuthorizationPolicyRuleArgs
* {
* Sources = new[]
* {
* new Gcp.NetworkSecurity.Inputs.AuthorizationPolicyRuleSourceArgs
* {
* Principals = new[]
* {
* "namespace/*",
* },
* IpBlocks = new[]
* {
* "1.2.3.0/24",
* },
* },
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networksecurity"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := networksecurity.NewAuthorizationPolicy(ctx, "default", &networksecurity.AuthorizationPolicyArgs{
* Name: pulumi.String("my-authorization-policy"),
* Labels: pulumi.StringMap{
* "foo": pulumi.String("bar"),
* },
* Description: pulumi.String("my description"),
* Action: pulumi.String("ALLOW"),
* Rules: networksecurity.AuthorizationPolicyRuleArray{
* &networksecurity.AuthorizationPolicyRuleArgs{
* Sources: networksecurity.AuthorizationPolicyRuleSourceArray{
* &networksecurity.AuthorizationPolicyRuleSourceArgs{
* Principals: pulumi.StringArray{
* pulumi.String("namespace/*"),
* },
* IpBlocks: pulumi.StringArray{
* pulumi.String("1.2.3.0/24"),
* },
* },
* },
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.networksecurity.AuthorizationPolicy;
* import com.pulumi.gcp.networksecurity.AuthorizationPolicyArgs;
* import com.pulumi.gcp.networksecurity.inputs.AuthorizationPolicyRuleArgs;
* 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 default_ = new AuthorizationPolicy("default", AuthorizationPolicyArgs.builder()
* .name("my-authorization-policy")
* .labels(Map.of("foo", "bar"))
* .description("my description")
* .action("ALLOW")
* .rules(AuthorizationPolicyRuleArgs.builder()
* .sources(AuthorizationPolicyRuleSourceArgs.builder()
* .principals("namespace/*")
* .ipBlocks("1.2.3.0/24")
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:networksecurity:AuthorizationPolicy
* properties:
* name: my-authorization-policy
* labels:
* foo: bar
* description: my description
* action: ALLOW
* rules:
* - sources:
* - principals:
* - namespace/*
* ipBlocks:
* - 1.2.3.0/24
* ```
*
* ### Network Security Authorization Policy Destinations
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* const _default = new gcp.networksecurity.AuthorizationPolicy("default", {
* name: "my-authorization-policy",
* labels: {
* foo: "bar",
* },
* description: "my description",
* action: "ALLOW",
* rules: [{
* sources: [{
* principals: ["namespace/*"],
* ipBlocks: ["1.2.3.0/24"],
* }],
* destinations: [{
* hosts: ["mydomain.*"],
* ports: [8080],
* methods: ["GET"],
* httpHeaderMatch: {
* headerName: ":method",
* regexMatch: "GET",
* },
* }],
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_gcp as gcp
* default = gcp.networksecurity.AuthorizationPolicy("default",
* name="my-authorization-policy",
* labels={
* "foo": "bar",
* },
* description="my description",
* action="ALLOW",
* rules=[{
* "sources": [{
* "principals": ["namespace/*"],
* "ip_blocks": ["1.2.3.0/24"],
* }],
* "destinations": [{
* "hosts": ["mydomain.*"],
* "ports": [8080],
* "methods": ["GET"],
* "http_header_match": {
* "header_name": ":method",
* "regex_match": "GET",
* },
* }],
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Gcp = Pulumi.Gcp;
* return await Deployment.RunAsync(() =>
* {
* var @default = new Gcp.NetworkSecurity.AuthorizationPolicy("default", new()
* {
* Name = "my-authorization-policy",
* Labels =
* {
* { "foo", "bar" },
* },
* Description = "my description",
* Action = "ALLOW",
* Rules = new[]
* {
* new Gcp.NetworkSecurity.Inputs.AuthorizationPolicyRuleArgs
* {
* Sources = new[]
* {
* new Gcp.NetworkSecurity.Inputs.AuthorizationPolicyRuleSourceArgs
* {
* Principals = new[]
* {
* "namespace/*",
* },
* IpBlocks = new[]
* {
* "1.2.3.0/24",
* },
* },
* },
* Destinations = new[]
* {
* new Gcp.NetworkSecurity.Inputs.AuthorizationPolicyRuleDestinationArgs
* {
* Hosts = new[]
* {
* "mydomain.*",
* },
* Ports = new[]
* {
* 8080,
* },
* Methods = new[]
* {
* "GET",
* },
* HttpHeaderMatch = new Gcp.NetworkSecurity.Inputs.AuthorizationPolicyRuleDestinationHttpHeaderMatchArgs
* {
* HeaderName = ":method",
* RegexMatch = "GET",
* },
* },
* },
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networksecurity"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := networksecurity.NewAuthorizationPolicy(ctx, "default", &networksecurity.AuthorizationPolicyArgs{
* Name: pulumi.String("my-authorization-policy"),
* Labels: pulumi.StringMap{
* "foo": pulumi.String("bar"),
* },
* Description: pulumi.String("my description"),
* Action: pulumi.String("ALLOW"),
* Rules: networksecurity.AuthorizationPolicyRuleArray{
* &networksecurity.AuthorizationPolicyRuleArgs{
* Sources: networksecurity.AuthorizationPolicyRuleSourceArray{
* &networksecurity.AuthorizationPolicyRuleSourceArgs{
* Principals: pulumi.StringArray{
* pulumi.String("namespace/*"),
* },
* IpBlocks: pulumi.StringArray{
* pulumi.String("1.2.3.0/24"),
* },
* },
* },
* Destinations: networksecurity.AuthorizationPolicyRuleDestinationArray{
* &networksecurity.AuthorizationPolicyRuleDestinationArgs{
* Hosts: pulumi.StringArray{
* pulumi.String("mydomain.*"),
* },
* Ports: pulumi.IntArray{
* pulumi.Int(8080),
* },
* Methods: pulumi.StringArray{
* pulumi.String("GET"),
* },
* HttpHeaderMatch: &networksecurity.AuthorizationPolicyRuleDestinationHttpHeaderMatchArgs{
* HeaderName: pulumi.String(":method"),
* RegexMatch: pulumi.String("GET"),
* },
* },
* },
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.gcp.networksecurity.AuthorizationPolicy;
* import com.pulumi.gcp.networksecurity.AuthorizationPolicyArgs;
* import com.pulumi.gcp.networksecurity.inputs.AuthorizationPolicyRuleArgs;
* 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 default_ = new AuthorizationPolicy("default", AuthorizationPolicyArgs.builder()
* .name("my-authorization-policy")
* .labels(Map.of("foo", "bar"))
* .description("my description")
* .action("ALLOW")
* .rules(AuthorizationPolicyRuleArgs.builder()
* .sources(AuthorizationPolicyRuleSourceArgs.builder()
* .principals("namespace/*")
* .ipBlocks("1.2.3.0/24")
* .build())
* .destinations(AuthorizationPolicyRuleDestinationArgs.builder()
* .hosts("mydomain.*")
* .ports(8080)
* .methods("GET")
* .httpHeaderMatch(AuthorizationPolicyRuleDestinationHttpHeaderMatchArgs.builder()
* .headerName(":method")
* .regexMatch("GET")
* .build())
* .build())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* default:
* type: gcp:networksecurity:AuthorizationPolicy
* properties:
* name: my-authorization-policy
* labels:
* foo: bar
* description: my description
* action: ALLOW
* rules:
* - sources:
* - principals:
* - namespace/*
* ipBlocks:
* - 1.2.3.0/24
* destinations:
* - hosts:
* - mydomain.*
* ports:
* - 8080
* methods:
* - GET
* httpHeaderMatch:
* headerName: :method
* regexMatch: GET
* ```
*
* ## Import
* AuthorizationPolicy can be imported using any of these accepted formats:
* * `projects/{{project}}/locations/{{location}}/authorizationPolicies/{{name}}`
* * `{{project}}/{{location}}/{{name}}`
* * `{{location}}/{{name}}`
* When using the `pulumi import` command, AuthorizationPolicy can be imported using one of the formats above. For example:
* ```sh
* $ pulumi import gcp:networksecurity/authorizationPolicy:AuthorizationPolicy default projects/{{project}}/locations/{{location}}/authorizationPolicies/{{name}}
* ```
* ```sh
* $ pulumi import gcp:networksecurity/authorizationPolicy:AuthorizationPolicy default {{project}}/{{location}}/{{name}}
* ```
* ```sh
* $ pulumi import gcp:networksecurity/authorizationPolicy:AuthorizationPolicy default {{location}}/{{name}}
* ```
* */*/*/*/*/*/*/*/*/*/*/*/
*/
public class AuthorizationPolicy internal constructor(
override val javaResource: com.pulumi.gcp.networksecurity.AuthorizationPolicy,
) : KotlinCustomResource(javaResource, AuthorizationPolicyMapper) {
/**
* The action to take when a rule match is found. Possible values are "ALLOW" or "DENY".
* Possible values are: `ALLOW`, `DENY`.
*/
public val action: Output
get() = javaResource.action().applyValue({ args0 -> args0 })
/**
* Time the AuthorizationPolicy was created in UTC.
*/
public val createTime: Output
get() = javaResource.createTime().applyValue({ args0 -> args0 })
/**
* A free-text description of the resource. Max length 1024 characters.
*/
public val description: Output?
get() = javaResource.description().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
*/
public val effectiveLabels: Output>
get() = javaResource.effectiveLabels().applyValue({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
})
/**
* Set of label tags associated with the AuthorizationPolicy resource.
* **Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
* Please refer to the field `effective_labels` for all of the labels present on the resource.
*/
public val labels: Output>?
get() = javaResource.labels().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
}).orElse(null)
})
/**
* The location of the authorization policy.
* The default value is `global`.
*/
public val location: Output?
get() = javaResource.location().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* Name of the AuthorizationPolicy resource.
* - - -
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The ID of the project in which the resource belongs.
* If it is not provided, the provider project is used.
*/
public val project: Output
get() = javaResource.project().applyValue({ args0 -> args0 })
/**
* The combination of labels configured directly on the resource
* and default labels configured on the provider.
*/
public val pulumiLabels: Output>
get() = javaResource.pulumiLabels().applyValue({ args0 ->
args0.map({ args0 ->
args0.key.to(args0.value)
}).toMap()
})
/**
* List of rules to match. Note that at least one of the rules must match in order for the action specified in the 'action' field to be taken.
* A rule is a match if there is a matching source and destination. If left blank, the action specified in the action field will be applied on every request.
* Structure is documented below.
*/
public val rules: Output>?
get() = javaResource.rules().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> toKotlin(args0) })
})
}).orElse(null)
})
/**
* Time the AuthorizationPolicy was updated in UTC.
*/
public val updateTime: Output
get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}
public object AuthorizationPolicyMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.gcp.networksecurity.AuthorizationPolicy::class == javaResource::class
override fun map(javaResource: Resource): AuthorizationPolicy = AuthorizationPolicy(
javaResource
as com.pulumi.gcp.networksecurity.AuthorizationPolicy,
)
}
/**
* @see [AuthorizationPolicy].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [AuthorizationPolicy].
*/
public suspend fun authorizationPolicy(
name: String,
block: suspend AuthorizationPolicyResourceBuilder.() -> Unit,
): AuthorizationPolicy {
val builder = AuthorizationPolicyResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [AuthorizationPolicy].
* @param name The _unique_ name of the resulting resource.
*/
public fun authorizationPolicy(name: String): AuthorizationPolicy {
val builder = AuthorizationPolicyResourceBuilder()
builder.name(name)
return builder.build()
}