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

com.pulumi.aws.secretsmanager.kotlin.SecretRotationArgs.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.secretsmanager.kotlin

import com.pulumi.aws.secretsmanager.SecretRotationArgs.builder
import com.pulumi.aws.secretsmanager.kotlin.inputs.SecretRotationRotationRulesArgs
import com.pulumi.aws.secretsmanager.kotlin.inputs.SecretRotationRotationRulesArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.jvm.JvmName

/**
 * Provides a resource to manage AWS Secrets Manager secret rotation. To manage a secret, see the `aws.secretsmanager.Secret` resource. To manage a secret value, see the `aws.secretsmanager.SecretVersion` resource.
 * ## Example Usage
 * ### Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const example = new aws.secretsmanager.SecretRotation("example", {
 *     secretId: exampleAwsSecretsmanagerSecret.id,
 *     rotationLambdaArn: exampleAwsLambdaFunction.arn,
 *     rotationRules: {
 *         automaticallyAfterDays: 30,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * example = aws.secretsmanager.SecretRotation("example",
 *     secret_id=example_aws_secretsmanager_secret["id"],
 *     rotation_lambda_arn=example_aws_lambda_function["arn"],
 *     rotation_rules={
 *         "automatically_after_days": 30,
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Aws.SecretsManager.SecretRotation("example", new()
 *     {
 *         SecretId = exampleAwsSecretsmanagerSecret.Id,
 *         RotationLambdaArn = exampleAwsLambdaFunction.Arn,
 *         RotationRules = new Aws.SecretsManager.Inputs.SecretRotationRotationRulesArgs
 *         {
 *             AutomaticallyAfterDays = 30,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/secretsmanager"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := secretsmanager.NewSecretRotation(ctx, "example", &secretsmanager.SecretRotationArgs{
 * 			SecretId:          pulumi.Any(exampleAwsSecretsmanagerSecret.Id),
 * 			RotationLambdaArn: pulumi.Any(exampleAwsLambdaFunction.Arn),
 * 			RotationRules: &secretsmanager.SecretRotationRotationRulesArgs{
 * 				AutomaticallyAfterDays: pulumi.Int(30),
 * 			},
 * 		})
 * 		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.secretsmanager.SecretRotation;
 * import com.pulumi.aws.secretsmanager.SecretRotationArgs;
 * import com.pulumi.aws.secretsmanager.inputs.SecretRotationRotationRulesArgs;
 * 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 SecretRotation("example", SecretRotationArgs.builder()
 *             .secretId(exampleAwsSecretsmanagerSecret.id())
 *             .rotationLambdaArn(exampleAwsLambdaFunction.arn())
 *             .rotationRules(SecretRotationRotationRulesArgs.builder()
 *                 .automaticallyAfterDays(30)
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: aws:secretsmanager:SecretRotation
 *     properties:
 *       secretId: ${exampleAwsSecretsmanagerSecret.id}
 *       rotationLambdaArn: ${exampleAwsLambdaFunction.arn}
 *       rotationRules:
 *         automaticallyAfterDays: 30
 * ```
 * 
 * ### Rotation Configuration
 * To enable automatic secret rotation, the Secrets Manager service requires usage of a Lambda function. The [Rotate Secrets section in the Secrets Manager User Guide](https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotating-secrets.html) provides additional information about deploying a prebuilt Lambda functions for supported credential rotation (e.g., RDS) or deploying a custom Lambda function.
 * > **NOTE:** Configuring rotation causes the secret to rotate once as soon as you enable rotation. Before you do this, you must ensure that all of your applications that use the credentials stored in the secret are updated to retrieve the secret from AWS Secrets Manager. The old credentials might no longer be usable after the initial rotation and any applications that you fail to update will break as soon as the old credentials are no longer valid.
 * > **NOTE:** If you cancel a rotation that is in progress (by removing the `rotation` configuration), it can leave the VersionStage labels in an unexpected state. Depending on what step of the rotation was in progress, you might need to remove the staging label AWSPENDING from the partially created version, specified by the SecretVersionId response value. You should also evaluate the partially rotated new version to see if it should be deleted, which you can do by removing all staging labels from the new version's VersionStage field.
 * ## Import
 * Using `pulumi import`, import `aws_secretsmanager_secret_rotation` using the secret Amazon Resource Name (ARN). For example:
 * ```sh
 * $ pulumi import aws:secretsmanager/secretRotation:SecretRotation example arn:aws:secretsmanager:us-east-1:123456789012:secret:example-123456
 * ```
 * @property rotateImmediately Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window. The rotation schedule is defined in `rotation_rules`. For secrets that use a Lambda rotation function to rotate, if you don't immediately rotate the secret, Secrets Manager tests the rotation configuration by running the testSecret step (https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_how.html) of the Lambda rotation function. The test creates an AWSPENDING version of the secret and then removes it. Defaults to `true`.
 * @property rotationLambdaArn Specifies the ARN of the Lambda function that can rotate the secret. Must be supplied if the secret is not managed by AWS.
 * @property rotationRules A structure that defines the rotation configuration for this secret. Defined below.
 * @property secretId Specifies the secret to which you want to add a new version. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret. The secret must already exist.
 */
public data class SecretRotationArgs(
    public val rotateImmediately: Output? = null,
    public val rotationLambdaArn: Output? = null,
    public val rotationRules: Output? = null,
    public val secretId: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.aws.secretsmanager.SecretRotationArgs =
        com.pulumi.aws.secretsmanager.SecretRotationArgs.builder()
            .rotateImmediately(rotateImmediately?.applyValue({ args0 -> args0 }))
            .rotationLambdaArn(rotationLambdaArn?.applyValue({ args0 -> args0 }))
            .rotationRules(rotationRules?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
            .secretId(secretId?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [SecretRotationArgs].
 */
@PulumiTagMarker
public class SecretRotationArgsBuilder internal constructor() {
    private var rotateImmediately: Output? = null

    private var rotationLambdaArn: Output? = null

    private var rotationRules: Output? = null

    private var secretId: Output? = null

    /**
     * @param value Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window. The rotation schedule is defined in `rotation_rules`. For secrets that use a Lambda rotation function to rotate, if you don't immediately rotate the secret, Secrets Manager tests the rotation configuration by running the testSecret step (https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_how.html) of the Lambda rotation function. The test creates an AWSPENDING version of the secret and then removes it. Defaults to `true`.
     */
    @JvmName("guvnsvwndatifdxs")
    public suspend fun rotateImmediately(`value`: Output) {
        this.rotateImmediately = value
    }

    /**
     * @param value Specifies the ARN of the Lambda function that can rotate the secret. Must be supplied if the secret is not managed by AWS.
     */
    @JvmName("jktfqpcpskteuomv")
    public suspend fun rotationLambdaArn(`value`: Output) {
        this.rotationLambdaArn = value
    }

    /**
     * @param value A structure that defines the rotation configuration for this secret. Defined below.
     */
    @JvmName("encgpdeudwsmnyrj")
    public suspend fun rotationRules(`value`: Output) {
        this.rotationRules = value
    }

    /**
     * @param value Specifies the secret to which you want to add a new version. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret. The secret must already exist.
     */
    @JvmName("vnsqgfgqnwylfwcg")
    public suspend fun secretId(`value`: Output) {
        this.secretId = value
    }

    /**
     * @param value Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window. The rotation schedule is defined in `rotation_rules`. For secrets that use a Lambda rotation function to rotate, if you don't immediately rotate the secret, Secrets Manager tests the rotation configuration by running the testSecret step (https://docs.aws.amazon.com/secretsmanager/latest/userguide/rotate-secrets_how.html) of the Lambda rotation function. The test creates an AWSPENDING version of the secret and then removes it. Defaults to `true`.
     */
    @JvmName("ubpumtlaicgomvxk")
    public suspend fun rotateImmediately(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.rotateImmediately = mapped
    }

    /**
     * @param value Specifies the ARN of the Lambda function that can rotate the secret. Must be supplied if the secret is not managed by AWS.
     */
    @JvmName("wsjxwbcitqnylyqs")
    public suspend fun rotationLambdaArn(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.rotationLambdaArn = mapped
    }

    /**
     * @param value A structure that defines the rotation configuration for this secret. Defined below.
     */
    @JvmName("qpiwwtubkfapcwcp")
    public suspend fun rotationRules(`value`: SecretRotationRotationRulesArgs?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.rotationRules = mapped
    }

    /**
     * @param argument A structure that defines the rotation configuration for this secret. Defined below.
     */
    @JvmName("lsgmlxoxxmvoaiai")
    public suspend fun rotationRules(argument: suspend SecretRotationRotationRulesArgsBuilder.() -> Unit) {
        val toBeMapped = SecretRotationRotationRulesArgsBuilder().applySuspend { argument() }.build()
        val mapped = of(toBeMapped)
        this.rotationRules = mapped
    }

    /**
     * @param value Specifies the secret to which you want to add a new version. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret. The secret must already exist.
     */
    @JvmName("xulvtbpijnfvdskw")
    public suspend fun secretId(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.secretId = mapped
    }

    internal fun build(): SecretRotationArgs = SecretRotationArgs(
        rotateImmediately = rotateImmediately,
        rotationLambdaArn = rotationLambdaArn,
        rotationRules = rotationRules,
        secretId = secretId,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy