All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.aws.bedrock.kotlin.Guardrail.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.aws.bedrock.kotlin

import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailContentPolicyConfig
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailContextualGroundingPolicyConfig
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailSensitiveInformationPolicyConfig
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailTimeouts
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailTopicPolicyConfig
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailWordPolicyConfig
import com.pulumi.core.Output
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.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailContentPolicyConfig.Companion.toKotlin as guardrailContentPolicyConfigToKotlin
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailContextualGroundingPolicyConfig.Companion.toKotlin as guardrailContextualGroundingPolicyConfigToKotlin
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailSensitiveInformationPolicyConfig.Companion.toKotlin as guardrailSensitiveInformationPolicyConfigToKotlin
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailTimeouts.Companion.toKotlin as guardrailTimeoutsToKotlin
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailTopicPolicyConfig.Companion.toKotlin as guardrailTopicPolicyConfigToKotlin
import com.pulumi.aws.bedrock.kotlin.outputs.GuardrailWordPolicyConfig.Companion.toKotlin as guardrailWordPolicyConfigToKotlin

/**
 * Builder for [Guardrail].
 */
@PulumiTagMarker
public class GuardrailResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: GuardrailArgs = GuardrailArgs()

    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 GuardrailArgsBuilder.() -> Unit) {
        val builder = GuardrailArgsBuilder()
        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(): Guardrail {
        val builtJavaResource = com.pulumi.aws.bedrock.Guardrail(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Guardrail(builtJavaResource)
    }
}

/**
 * Resource for managing an Amazon Bedrock Guardrail.
 * ## Example Usage
 * ### Basic Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const example = new aws.bedrock.Guardrail("example", {
 *     name: "example",
 *     blockedInputMessaging: "example",
 *     blockedOutputsMessaging: "example",
 *     description: "example",
 *     contentPolicyConfig: {
 *         filtersConfigs: [{
 *             inputStrength: "MEDIUM",
 *             outputStrength: "MEDIUM",
 *             type: "HATE",
 *         }],
 *     },
 *     sensitiveInformationPolicyConfig: {
 *         piiEntitiesConfigs: [{
 *             action: "BLOCK",
 *             type: "NAME",
 *         }],
 *         regexesConfigs: [{
 *             action: "BLOCK",
 *             description: "example regex",
 *             name: "regex_example",
 *             pattern: "^\\d{3}-\\d{2}-\\d{4}$",
 *         }],
 *     },
 *     topicPolicyConfig: {
 *         topicsConfigs: [{
 *             name: "investment_topic",
 *             examples: ["Where should I invest my money ?"],
 *             type: "DENY",
 *             definition: "Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .",
 *         }],
 *     },
 *     wordPolicyConfig: {
 *         managedWordListsConfigs: [{
 *             type: "PROFANITY",
 *         }],
 *         wordsConfigs: [{
 *             text: "HATE",
 *         }],
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * example = aws.bedrock.Guardrail("example",
 *     name="example",
 *     blocked_input_messaging="example",
 *     blocked_outputs_messaging="example",
 *     description="example",
 *     content_policy_config={
 *         "filters_configs": [{
 *             "input_strength": "MEDIUM",
 *             "output_strength": "MEDIUM",
 *             "type": "HATE",
 *         }],
 *     },
 *     sensitive_information_policy_config={
 *         "pii_entities_configs": [{
 *             "action": "BLOCK",
 *             "type": "NAME",
 *         }],
 *         "regexes_configs": [{
 *             "action": "BLOCK",
 *             "description": "example regex",
 *             "name": "regex_example",
 *             "pattern": "^\\d{3}-\\d{2}-\\d{4}$",
 *         }],
 *     },
 *     topic_policy_config={
 *         "topics_configs": [{
 *             "name": "investment_topic",
 *             "examples": ["Where should I invest my money ?"],
 *             "type": "DENY",
 *             "definition": "Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .",
 *         }],
 *     },
 *     word_policy_config={
 *         "managed_word_lists_configs": [{
 *             "type": "PROFANITY",
 *         }],
 *         "words_configs": [{
 *             "text": "HATE",
 *         }],
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Aws.Bedrock.Guardrail("example", new()
 *     {
 *         Name = "example",
 *         BlockedInputMessaging = "example",
 *         BlockedOutputsMessaging = "example",
 *         Description = "example",
 *         ContentPolicyConfig = new Aws.Bedrock.Inputs.GuardrailContentPolicyConfigArgs
 *         {
 *             FiltersConfigs = new[]
 *             {
 *                 new Aws.Bedrock.Inputs.GuardrailContentPolicyConfigFiltersConfigArgs
 *                 {
 *                     InputStrength = "MEDIUM",
 *                     OutputStrength = "MEDIUM",
 *                     Type = "HATE",
 *                 },
 *             },
 *         },
 *         SensitiveInformationPolicyConfig = new Aws.Bedrock.Inputs.GuardrailSensitiveInformationPolicyConfigArgs
 *         {
 *             PiiEntitiesConfigs = new[]
 *             {
 *                 new Aws.Bedrock.Inputs.GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArgs
 *                 {
 *                     Action = "BLOCK",
 *                     Type = "NAME",
 *                 },
 *             },
 *             RegexesConfigs = new[]
 *             {
 *                 new Aws.Bedrock.Inputs.GuardrailSensitiveInformationPolicyConfigRegexesConfigArgs
 *                 {
 *                     Action = "BLOCK",
 *                     Description = "example regex",
 *                     Name = "regex_example",
 *                     Pattern = "^\\d{3}-\\d{2}-\\d{4}$",
 *                 },
 *             },
 *         },
 *         TopicPolicyConfig = new Aws.Bedrock.Inputs.GuardrailTopicPolicyConfigArgs
 *         {
 *             TopicsConfigs = new[]
 *             {
 *                 new Aws.Bedrock.Inputs.GuardrailTopicPolicyConfigTopicsConfigArgs
 *                 {
 *                     Name = "investment_topic",
 *                     Examples = new[]
 *                     {
 *                         "Where should I invest my money ?",
 *                     },
 *                     Type = "DENY",
 *                     Definition = "Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .",
 *                 },
 *             },
 *         },
 *         WordPolicyConfig = new Aws.Bedrock.Inputs.GuardrailWordPolicyConfigArgs
 *         {
 *             ManagedWordListsConfigs = new[]
 *             {
 *                 new Aws.Bedrock.Inputs.GuardrailWordPolicyConfigManagedWordListsConfigArgs
 *                 {
 *                     Type = "PROFANITY",
 *                 },
 *             },
 *             WordsConfigs = new[]
 *             {
 *                 new Aws.Bedrock.Inputs.GuardrailWordPolicyConfigWordsConfigArgs
 *                 {
 *                     Text = "HATE",
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/bedrock"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := bedrock.NewGuardrail(ctx, "example", &bedrock.GuardrailArgs{
 * 			Name:                    pulumi.String("example"),
 * 			BlockedInputMessaging:   pulumi.String("example"),
 * 			BlockedOutputsMessaging: pulumi.String("example"),
 * 			Description:             pulumi.String("example"),
 * 			ContentPolicyConfig: &bedrock.GuardrailContentPolicyConfigArgs{
 * 				FiltersConfigs: bedrock.GuardrailContentPolicyConfigFiltersConfigArray{
 * 					&bedrock.GuardrailContentPolicyConfigFiltersConfigArgs{
 * 						InputStrength:  pulumi.String("MEDIUM"),
 * 						OutputStrength: pulumi.String("MEDIUM"),
 * 						Type:           pulumi.String("HATE"),
 * 					},
 * 				},
 * 			},
 * 			SensitiveInformationPolicyConfig: &bedrock.GuardrailSensitiveInformationPolicyConfigArgs{
 * 				PiiEntitiesConfigs: bedrock.GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArray{
 * 					&bedrock.GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArgs{
 * 						Action: pulumi.String("BLOCK"),
 * 						Type:   pulumi.String("NAME"),
 * 					},
 * 				},
 * 				RegexesConfigs: bedrock.GuardrailSensitiveInformationPolicyConfigRegexesConfigArray{
 * 					&bedrock.GuardrailSensitiveInformationPolicyConfigRegexesConfigArgs{
 * 						Action:      pulumi.String("BLOCK"),
 * 						Description: pulumi.String("example regex"),
 * 						Name:        pulumi.String("regex_example"),
 * 						Pattern:     pulumi.String("^\\d{3}-\\d{2}-\\d{4}$"),
 * 					},
 * 				},
 * 			},
 * 			TopicPolicyConfig: &bedrock.GuardrailTopicPolicyConfigArgs{
 * 				TopicsConfigs: bedrock.GuardrailTopicPolicyConfigTopicsConfigArray{
 * 					&bedrock.GuardrailTopicPolicyConfigTopicsConfigArgs{
 * 						Name: pulumi.String("investment_topic"),
 * 						Examples: pulumi.StringArray{
 * 							pulumi.String("Where should I invest my money ?"),
 * 						},
 * 						Type:       pulumi.String("DENY"),
 * 						Definition: pulumi.String("Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns ."),
 * 					},
 * 				},
 * 			},
 * 			WordPolicyConfig: &bedrock.GuardrailWordPolicyConfigArgs{
 * 				ManagedWordListsConfigs: bedrock.GuardrailWordPolicyConfigManagedWordListsConfigArray{
 * 					&bedrock.GuardrailWordPolicyConfigManagedWordListsConfigArgs{
 * 						Type: pulumi.String("PROFANITY"),
 * 					},
 * 				},
 * 				WordsConfigs: bedrock.GuardrailWordPolicyConfigWordsConfigArray{
 * 					&bedrock.GuardrailWordPolicyConfigWordsConfigArgs{
 * 						Text: pulumi.String("HATE"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.aws.bedrock.Guardrail;
 * import com.pulumi.aws.bedrock.GuardrailArgs;
 * import com.pulumi.aws.bedrock.inputs.GuardrailContentPolicyConfigArgs;
 * import com.pulumi.aws.bedrock.inputs.GuardrailSensitiveInformationPolicyConfigArgs;
 * import com.pulumi.aws.bedrock.inputs.GuardrailTopicPolicyConfigArgs;
 * import com.pulumi.aws.bedrock.inputs.GuardrailWordPolicyConfigArgs;
 * 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 example = new Guardrail("example", GuardrailArgs.builder()
 *             .name("example")
 *             .blockedInputMessaging("example")
 *             .blockedOutputsMessaging("example")
 *             .description("example")
 *             .contentPolicyConfig(GuardrailContentPolicyConfigArgs.builder()
 *                 .filtersConfigs(GuardrailContentPolicyConfigFiltersConfigArgs.builder()
 *                     .inputStrength("MEDIUM")
 *                     .outputStrength("MEDIUM")
 *                     .type("HATE")
 *                     .build())
 *                 .build())
 *             .sensitiveInformationPolicyConfig(GuardrailSensitiveInformationPolicyConfigArgs.builder()
 *                 .piiEntitiesConfigs(GuardrailSensitiveInformationPolicyConfigPiiEntitiesConfigArgs.builder()
 *                     .action("BLOCK")
 *                     .type("NAME")
 *                     .build())
 *                 .regexesConfigs(GuardrailSensitiveInformationPolicyConfigRegexesConfigArgs.builder()
 *                     .action("BLOCK")
 *                     .description("example regex")
 *                     .name("regex_example")
 *                     .pattern("^\\d{3}-\\d{2}-\\d{4}$")
 *                     .build())
 *                 .build())
 *             .topicPolicyConfig(GuardrailTopicPolicyConfigArgs.builder()
 *                 .topicsConfigs(GuardrailTopicPolicyConfigTopicsConfigArgs.builder()
 *                     .name("investment_topic")
 *                     .examples("Where should I invest my money ?")
 *                     .type("DENY")
 *                     .definition("Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .")
 *                     .build())
 *                 .build())
 *             .wordPolicyConfig(GuardrailWordPolicyConfigArgs.builder()
 *                 .managedWordListsConfigs(GuardrailWordPolicyConfigManagedWordListsConfigArgs.builder()
 *                     .type("PROFANITY")
 *                     .build())
 *                 .wordsConfigs(GuardrailWordPolicyConfigWordsConfigArgs.builder()
 *                     .text("HATE")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: aws:bedrock:Guardrail
 *     properties:
 *       name: example
 *       blockedInputMessaging: example
 *       blockedOutputsMessaging: example
 *       description: example
 *       contentPolicyConfig:
 *         filtersConfigs:
 *           - inputStrength: MEDIUM
 *             outputStrength: MEDIUM
 *             type: HATE
 *       sensitiveInformationPolicyConfig:
 *         piiEntitiesConfigs:
 *           - action: BLOCK
 *             type: NAME
 *         regexesConfigs:
 *           - action: BLOCK
 *             description: example regex
 *             name: regex_example
 *             pattern: ^\d{3}-\d{2}-\d{4}$
 *       topicPolicyConfig:
 *         topicsConfigs:
 *           - name: investment_topic
 *             examples:
 *               - Where should I invest my money ?
 *             type: DENY
 *             definition: Investment advice refers to inquiries, guidance, or recommendations regarding the management or allocation of funds or assets with the goal of generating returns .
 *       wordPolicyConfig:
 *         managedWordListsConfigs:
 *           - type: PROFANITY
 *         wordsConfigs:
 *           - text: HATE
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import Amazon Bedrock Guardrail using using a comma-delimited string of `guardrail_id` and `version`. For example:
 * ```sh
 * $ pulumi import aws:bedrock/guardrail:Guardrail example guardrail-id-12345678,DRAFT
 * ```
 */
public class Guardrail internal constructor(
    override val javaResource: com.pulumi.aws.bedrock.Guardrail,
) : KotlinCustomResource(javaResource, GuardrailMapper) {
    /**
     * Message to return when the guardrail blocks a prompt.
     */
    public val blockedInputMessaging: Output
        get() = javaResource.blockedInputMessaging().applyValue({ args0 -> args0 })

    /**
     * Message to return when the guardrail blocks a model response.
     */
    public val blockedOutputsMessaging: Output
        get() = javaResource.blockedOutputsMessaging().applyValue({ args0 -> args0 })

    /**
     * Content policy config for a guardrail. See Content Policy Config for more information.
     */
    public val contentPolicyConfig: Output?
        get() = javaResource.contentPolicyConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> guardrailContentPolicyConfigToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Contextual grounding policy config for a guardrail. See Contextual Grounding Policy Config for more information.
     */
    public val contextualGroundingPolicyConfig: Output?
        get() = javaResource.contextualGroundingPolicyConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    guardrailContextualGroundingPolicyConfigToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * Unix epoch timestamp in seconds for when the Guardrail was created.
     */
    public val createdAt: Output
        get() = javaResource.createdAt().applyValue({ args0 -> args0 })

    /**
     * Description of the guardrail or its version.
     */
    public val description: Output
        get() = javaResource.description().applyValue({ args0 -> args0 })

    /**
     * ARN of the Guardrail.
     */
    public val guardrailArn: Output
        get() = javaResource.guardrailArn().applyValue({ args0 -> args0 })

    /**
     * ID of the Guardrail.
     */
    public val guardrailId: Output
        get() = javaResource.guardrailId().applyValue({ args0 -> args0 })

    /**
     * The KMS key with which the guardrail was encrypted at rest.
     */
    public val kmsKeyArn: Output?
        get() = javaResource.kmsKeyArn().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Name of the guardrail.
     * The following arguments are optional:
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Sensitive information policy config for a guardrail. See Sensitive Information Policy Config for more information.
     */
    public val sensitiveInformationPolicyConfig: Output?
        get() = javaResource.sensitiveInformationPolicyConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    guardrailSensitiveInformationPolicyConfigToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * Status of the Bedrock Guardrail. One of `READY`, `FAILED`.
     */
    public val status: Output
        get() = javaResource.status().applyValue({ args0 -> args0 })

    /**
     * Key-value map of resource tags. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    @Deprecated(
        message = """
  Please use `tags` instead.
  """,
    )
    public val tagsAll: Output>
        get() = javaResource.tagsAll().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    public val timeouts: Output?
        get() = javaResource.timeouts().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    guardrailTimeoutsToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * Topic policy config for a guardrail. See Topic Policy Config for more information.
     */
    public val topicPolicyConfig: Output?
        get() = javaResource.topicPolicyConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> guardrailTopicPolicyConfigToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Version of the Guardrail.
     */
    public val version: Output
        get() = javaResource.version().applyValue({ args0 -> args0 })

    /**
     * Word policy config for a guardrail. See Word Policy Config for more information.
     */
    public val wordPolicyConfig: Output?
        get() = javaResource.wordPolicyConfig().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> guardrailWordPolicyConfigToKotlin(args0) })
            }).orElse(null)
        })
}

public object GuardrailMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.bedrock.Guardrail::class == javaResource::class

    override fun map(javaResource: Resource): Guardrail = Guardrail(
        javaResource as
            com.pulumi.aws.bedrock.Guardrail,
    )
}

/**
 * @see [Guardrail].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Guardrail].
 */
public suspend fun guardrail(name: String, block: suspend GuardrailResourceBuilder.() -> Unit): Guardrail {
    val builder = GuardrailResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Guardrail].
 * @param name The _unique_ name of the resulting resource.
 */
public fun guardrail(name: String): Guardrail {
    val builder = GuardrailResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy