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

com.pulumi.aws.s3.kotlin.BucketServerSideEncryptionConfigurationV2.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 6.57.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.aws.s3.kotlin

import com.pulumi.aws.s3.kotlin.outputs.BucketServerSideEncryptionConfigurationV2Rule
import com.pulumi.aws.s3.kotlin.outputs.BucketServerSideEncryptionConfigurationV2Rule.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
import kotlin.collections.List

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

    public var args: BucketServerSideEncryptionConfigurationV2Args =
        BucketServerSideEncryptionConfigurationV2Args()

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

/**
 * Provides a S3 bucket server-side encryption configuration resource.
 * > **NOTE:** Destroying an `aws.s3.BucketServerSideEncryptionConfigurationV2` resource resets the bucket to [Amazon S3 bucket default encryption](https://docs.aws.amazon.com/AmazonS3/latest/userguide/default-encryption-faq.html).
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const mykey = new aws.kms.Key("mykey", {
 *     description: "This key is used to encrypt bucket objects",
 *     deletionWindowInDays: 10,
 * });
 * const mybucket = new aws.s3.BucketV2("mybucket", {bucket: "mybucket"});
 * const example = new aws.s3.BucketServerSideEncryptionConfigurationV2("example", {
 *     bucket: mybucket.id,
 *     rules: [{
 *         applyServerSideEncryptionByDefault: {
 *             kmsMasterKeyId: mykey.arn,
 *             sseAlgorithm: "aws:kms",
 *         },
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * mykey = aws.kms.Key("mykey",
 *     description="This key is used to encrypt bucket objects",
 *     deletion_window_in_days=10)
 * mybucket = aws.s3.BucketV2("mybucket", bucket="mybucket")
 * example = aws.s3.BucketServerSideEncryptionConfigurationV2("example",
 *     bucket=mybucket.id,
 *     rules=[{
 *         "apply_server_side_encryption_by_default": {
 *             "kms_master_key_id": mykey.arn,
 *             "sse_algorithm": "aws:kms",
 *         },
 *     }])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var mykey = new Aws.Kms.Key("mykey", new()
 *     {
 *         Description = "This key is used to encrypt bucket objects",
 *         DeletionWindowInDays = 10,
 *     });
 *     var mybucket = new Aws.S3.BucketV2("mybucket", new()
 *     {
 *         Bucket = "mybucket",
 *     });
 *     var example = new Aws.S3.BucketServerSideEncryptionConfigurationV2("example", new()
 *     {
 *         Bucket = mybucket.Id,
 *         Rules = new[]
 *         {
 *             new Aws.S3.Inputs.BucketServerSideEncryptionConfigurationV2RuleArgs
 *             {
 *                 ApplyServerSideEncryptionByDefault = new Aws.S3.Inputs.BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs
 *                 {
 *                     KmsMasterKeyId = mykey.Arn,
 *                     SseAlgorithm = "aws:kms",
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		mykey, err := kms.NewKey(ctx, "mykey", &kms.KeyArgs{
 * 			Description:          pulumi.String("This key is used to encrypt bucket objects"),
 * 			DeletionWindowInDays: pulumi.Int(10),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		mybucket, err := s3.NewBucketV2(ctx, "mybucket", &s3.BucketV2Args{
 * 			Bucket: pulumi.String("mybucket"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = s3.NewBucketServerSideEncryptionConfigurationV2(ctx, "example", &s3.BucketServerSideEncryptionConfigurationV2Args{
 * 			Bucket: mybucket.ID(),
 * 			Rules: s3.BucketServerSideEncryptionConfigurationV2RuleArray{
 * 				&s3.BucketServerSideEncryptionConfigurationV2RuleArgs{
 * 					ApplyServerSideEncryptionByDefault: &s3.BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs{
 * 						KmsMasterKeyId: mykey.Arn,
 * 						SseAlgorithm:   pulumi.String("aws:kms"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.kms.Key;
 * import com.pulumi.aws.kms.KeyArgs;
 * import com.pulumi.aws.s3.BucketV2;
 * import com.pulumi.aws.s3.BucketV2Args;
 * import com.pulumi.aws.s3.BucketServerSideEncryptionConfigurationV2;
 * import com.pulumi.aws.s3.BucketServerSideEncryptionConfigurationV2Args;
 * import com.pulumi.aws.s3.inputs.BucketServerSideEncryptionConfigurationV2RuleArgs;
 * import com.pulumi.aws.s3.inputs.BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs;
 * 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 mykey = new Key("mykey", KeyArgs.builder()
 *             .description("This key is used to encrypt bucket objects")
 *             .deletionWindowInDays(10)
 *             .build());
 *         var mybucket = new BucketV2("mybucket", BucketV2Args.builder()
 *             .bucket("mybucket")
 *             .build());
 *         var example = new BucketServerSideEncryptionConfigurationV2("example", BucketServerSideEncryptionConfigurationV2Args.builder()
 *             .bucket(mybucket.id())
 *             .rules(BucketServerSideEncryptionConfigurationV2RuleArgs.builder()
 *                 .applyServerSideEncryptionByDefault(BucketServerSideEncryptionConfigurationV2RuleApplyServerSideEncryptionByDefaultArgs.builder()
 *                     .kmsMasterKeyId(mykey.arn())
 *                     .sseAlgorithm("aws:kms")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   mykey:
 *     type: aws:kms:Key
 *     properties:
 *       description: This key is used to encrypt bucket objects
 *       deletionWindowInDays: 10
 *   mybucket:
 *     type: aws:s3:BucketV2
 *     properties:
 *       bucket: mybucket
 *   example:
 *     type: aws:s3:BucketServerSideEncryptionConfigurationV2
 *     properties:
 *       bucket: ${mybucket.id}
 *       rules:
 *         - applyServerSideEncryptionByDefault:
 *             kmsMasterKeyId: ${mykey.arn}
 *             sseAlgorithm: aws:kms
 * ```
 * 
 * ## Import
 * If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
 * __Using `pulumi import` to import__ S3 bucket server-side encryption configuration using the `bucket` or using the `bucket` and `expected_bucket_owner` separated by a comma (`,`). For example:
 * If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the `bucket`:
 * ```sh
 * $ pulumi import aws:s3/bucketServerSideEncryptionConfigurationV2:BucketServerSideEncryptionConfigurationV2 example bucket-name
 * ```
 * If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`):
 * ```sh
 * $ pulumi import aws:s3/bucketServerSideEncryptionConfigurationV2:BucketServerSideEncryptionConfigurationV2 example bucket-name,123456789012
 * ```
 */
public class BucketServerSideEncryptionConfigurationV2 internal constructor(
    override val javaResource: com.pulumi.aws.s3.BucketServerSideEncryptionConfigurationV2,
) : KotlinCustomResource(javaResource, BucketServerSideEncryptionConfigurationV2Mapper) {
    /**
     * ID (name) of the bucket.
     */
    public val bucket: Output
        get() = javaResource.bucket().applyValue({ args0 -> args0 })

    /**
     * Account ID of the expected bucket owner.
     */
    public val expectedBucketOwner: Output?
        get() = javaResource.expectedBucketOwner().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Set of server-side encryption configuration rules. See below. Currently, only a single rule is supported.
     */
    public val rules: Output>
        get() = javaResource.rules().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            })
        })
}

public object BucketServerSideEncryptionConfigurationV2Mapper :
    ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.s3.BucketServerSideEncryptionConfigurationV2::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy