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

com.pulumi.aws.verifiedpermissions.kotlin.Policy.kt Maven / Gradle / Ivy

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

package com.pulumi.aws.verifiedpermissions.kotlin

import com.pulumi.aws.verifiedpermissions.kotlin.outputs.PolicyDefinition
import com.pulumi.aws.verifiedpermissions.kotlin.outputs.PolicyDefinition.Companion.toKotlin
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.String
import kotlin.Suppress
import kotlin.Unit

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

    public var args: PolicyArgs = PolicyArgs()

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

/**
 * Resource for managing an AWS Verified Permissions Policy.
 * ## Example Usage
 * ### Basic Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const test = new aws.verifiedpermissions.Policy("test", {
 *     policyStoreId: testAwsVerifiedpermissionsPolicyStore.id,
 *     definition: {
 *         static: {
 *             statement: "permit (principal, action == Action::\"view\", resource in Album:: \"test_album\");",
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * test = aws.verifiedpermissions.Policy("test",
 *     policy_store_id=test_aws_verifiedpermissions_policy_store["id"],
 *     definition={
 *         "static": {
 *             "statement": "permit (principal, action == Action::\"view\", resource in Album:: \"test_album\");",
 *         },
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var test = new Aws.VerifiedPermissions.Policy("test", new()
 *     {
 *         PolicyStoreId = testAwsVerifiedpermissionsPolicyStore.Id,
 *         Definition = new Aws.VerifiedPermissions.Inputs.PolicyDefinitionArgs
 *         {
 *             Static = new Aws.VerifiedPermissions.Inputs.PolicyDefinitionStaticArgs
 *             {
 *                 Statement = "permit (principal, action == Action::\"view\", resource in Album:: \"test_album\");",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/verifiedpermissions"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := verifiedpermissions.NewPolicy(ctx, "test", &verifiedpermissions.PolicyArgs{
 * 			PolicyStoreId: pulumi.Any(testAwsVerifiedpermissionsPolicyStore.Id),
 * 			Definition: &verifiedpermissions.PolicyDefinitionArgs{
 * 				Static: &verifiedpermissions.PolicyDefinitionStaticArgs{
 * 					Statement: pulumi.String("permit (principal, action == Action::\"view\", resource in Album:: \"test_album\");"),
 * 				},
 * 			},
 * 		})
 * 		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.verifiedpermissions.Policy;
 * import com.pulumi.aws.verifiedpermissions.PolicyArgs;
 * import com.pulumi.aws.verifiedpermissions.inputs.PolicyDefinitionArgs;
 * import com.pulumi.aws.verifiedpermissions.inputs.PolicyDefinitionStaticArgs;
 * 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 test = new Policy("test", PolicyArgs.builder()
 *             .policyStoreId(testAwsVerifiedpermissionsPolicyStore.id())
 *             .definition(PolicyDefinitionArgs.builder()
 *                 .static_(PolicyDefinitionStaticArgs.builder()
 *                     .statement("permit (principal, action == Action::\"view\", resource in Album:: \"test_album\");")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   test:
 *     type: aws:verifiedpermissions:Policy
 *     properties:
 *       policyStoreId: ${testAwsVerifiedpermissionsPolicyStore.id}
 *       definition:
 *         static:
 *           statement: 'permit (principal, action == Action::"view", resource in Album:: "test_album");'
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import Verified Permissions Policy using the `policy_id,policy_store_id`. For example:
 * ```sh
 * $ pulumi import aws:verifiedpermissions/policy:Policy example policy-id-12345678,policy-store-id-12345678
 * ```
 */
public class Policy internal constructor(
    override val javaResource: com.pulumi.aws.verifiedpermissions.Policy,
) : KotlinCustomResource(javaResource, PolicyMapper) {
    /**
     * The date the policy was created.
     */
    public val createdDate: Output
        get() = javaResource.createdDate().applyValue({ args0 -> args0 })

    /**
     * The definition of the policy. See Definition below.
     */
    public val definition: Output?
        get() = javaResource.definition().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The Policy ID of the policy.
     */
    public val policyId: Output
        get() = javaResource.policyId().applyValue({ args0 -> args0 })

    /**
     * The Policy Store ID of the policy store.
     */
    public val policyStoreId: Output
        get() = javaResource.policyStoreId().applyValue({ args0 -> args0 })
}

public object PolicyMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.verifiedpermissions.Policy::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy