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

com.pulumi.awsnative.dynamodb.kotlin.Table.kt Maven / Gradle / Ivy

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

package com.pulumi.awsnative.dynamodb.kotlin

import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableAttributeDefinition
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableContributorInsightsSpecification
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableGlobalSecondaryIndex
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableImportSourceSpecification
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableKeySchema
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableKinesisStreamSpecification
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableLocalSecondaryIndex
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableOnDemandThroughput
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TablePointInTimeRecoverySpecification
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableProvisionedThroughput
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableResourcePolicy
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableSseSpecification
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableStreamSpecification
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableTimeToLiveSpecification
import com.pulumi.awsnative.kotlin.outputs.Tag
import com.pulumi.core.Either
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.Any
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableAttributeDefinition.Companion.toKotlin as tableAttributeDefinitionToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableContributorInsightsSpecification.Companion.toKotlin as tableContributorInsightsSpecificationToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableGlobalSecondaryIndex.Companion.toKotlin as tableGlobalSecondaryIndexToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableImportSourceSpecification.Companion.toKotlin as tableImportSourceSpecificationToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableKinesisStreamSpecification.Companion.toKotlin as tableKinesisStreamSpecificationToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableLocalSecondaryIndex.Companion.toKotlin as tableLocalSecondaryIndexToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableOnDemandThroughput.Companion.toKotlin as tableOnDemandThroughputToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TablePointInTimeRecoverySpecification.Companion.toKotlin as tablePointInTimeRecoverySpecificationToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableProvisionedThroughput.Companion.toKotlin as tableProvisionedThroughputToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableResourcePolicy.Companion.toKotlin as tableResourcePolicyToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableSseSpecification.Companion.toKotlin as tableSseSpecificationToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableStreamSpecification.Companion.toKotlin as tableStreamSpecificationToKotlin
import com.pulumi.awsnative.dynamodb.kotlin.outputs.TableTimeToLiveSpecification.Companion.toKotlin as tableTimeToLiveSpecificationToKotlin
import com.pulumi.awsnative.kotlin.outputs.Tag.Companion.toKotlin as tagToKotlin

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

    public var args: TableArgs = TableArgs()

    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 TableArgsBuilder.() -> Unit) {
        val builder = TableArgsBuilder()
        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(): Table {
        val builtJavaResource = com.pulumi.awsnative.dynamodb.Table(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Table(builtJavaResource)
    }
}

/**
 * The ``AWS::DynamoDB::Table`` resource creates a DDB table. For more information, see [CreateTable](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html) in the *API Reference*.
 *  You should be aware of the following behaviors when working with DDB tables:
 *   +   CFNlong typically creates DDB tables in parallel. However, if your template includes multiple DDB tables with indexes, you must declare dependencies so that the tables are created sequentially. DDBlong limits the number of tables with secondary indexes that are in the creating state. If you create multiple tables with indexes at the same time, DDB returns an error and the stack operation fails. For an example, see [DynamoDB Table with a DependsOn Attribute](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#aws-resource-dynamodb-table--examples--DynamoDB_Table_with_a_DependsOn_Attribute).
 *    Our guidance is to use the latest schema documented here for your CFNlong templates. This schema supports the provisioning of all table settings below. When using this schema in your CFNlong templates, please ensure that your Identity and Access Management (IAM) policies are updated with appropriate permissions to allow for the authorization of these setting changes.
 * ## Example Usage
 * ### Example
 * No Java example available.
 * ### Example
 * No Java example available.
 */
public class Table internal constructor(
    override val javaResource: com.pulumi.awsnative.dynamodb.Table,
) : KotlinCustomResource(javaResource, TableMapper) {
    /**
     * The Amazon Resource Name (ARN) of the DynamoDB table, such as `arn:aws:dynamodb:us-east-2:123456789012:table/myDynamoDBTable` .
     */
    public val arn: Output
        get() = javaResource.arn().applyValue({ args0 -> args0 })

    /**
     * A list of attributes that describe the key schema for the table and indexes.
     *  This property is required to create a DDB table.
     *  Update requires: [Some interruptions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-some-interrupt). Replacement if you edit an existing AttributeDefinition.
     */
    public val attributeDefinitions: Output>?
        get() = javaResource.attributeDefinitions().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        tableAttributeDefinitionToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * Specify how you are charged for read and write throughput and how you manage capacity.
     *  Valid values include:
     *   +   ``PROVISIONED`` - We recommend using ``PROVISIONED`` for predictable workloads. ``PROVISIONED`` sets the billing mode to [Provisioned Mode](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.ProvisionedThroughput.Manual).
     *   +   ``PAY_PER_REQUEST`` - We recommend using ``PAY_PER_REQUEST`` for unpredictable workloads. ``PAY_PER_REQUEST`` sets the billing mode to [On-Demand Mode](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html#HowItWorks.OnDemand).
     *  If not specified, the default is ``PROVISIONED``.
     */
    public val billingMode: Output?
        get() = javaResource.billingMode().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The settings used to enable or disable CloudWatch Contributor Insights for the specified table.
     */
    public val contributorInsightsSpecification: Output?
        get() = javaResource.contributorInsightsSpecification().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableContributorInsightsSpecificationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Determines if a table is protected from deletion. When enabled, the table cannot be deleted by any user or process. This setting is disabled by default. For more information, see [Using deletion protection](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.Basics.html#WorkingWithTables.Basics.DeletionProtection) in the *Developer Guide*.
     */
    public val deletionProtectionEnabled: Output?
        get() = javaResource.deletionProtectionEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Global secondary indexes to be created on the table. You can create up to 20 global secondary indexes.
     *   If you update a table to include a new global secondary index, CFNlong initiates the index creation and then proceeds with the stack update. CFNlong doesn't wait for the index to complete creation because the backfilling phase can take a long time, depending on the size of the table. You can't use the index or update the table until the index's status is ``ACTIVE``. You can track its status by using the DynamoDB [DescribeTable](https://docs.aws.amazon.com/cli/latest/reference/dynamodb/describe-table.html) command.
     *  If you add or delete an index during an update, we recommend that you don't update any other resources. If your stack fails to update and is rolled back while adding a new index, you must manually delete the index.
     *  Updates are not supported. The following are exceptions:
     *   +  If you update either the contributor insights specification or the provisioned throughput values of global secondary indexes, you can update the table without interruption.
     *   +  You can delete or add one global secondary index without interruption. If you do both in the same update (for example, by changing the index's logical ID), the update fails.
     */
    public val globalSecondaryIndexes: Output>?
        get() = javaResource.globalSecondaryIndexes().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        tableGlobalSecondaryIndexToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * Specifies the properties of data being imported from the S3 bucket source to the table.
     *   If you specify the ``ImportSourceSpecification`` property, and also specify either the ``StreamSpecification``, the ``TableClass`` property, or the ``DeletionProtectionEnabled`` property, the IAM entity creating/updating stack must have ``UpdateTable`` permission.
     */
    public val importSourceSpecification: Output?
        get() = javaResource.importSourceSpecification().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableImportSourceSpecificationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Specifies the attributes that make up the primary key for the table. The attributes in the ``KeySchema`` property must also be defined in the ``AttributeDefinitions`` property.
     */
    public val keySchema: Output, Any>>
        get() = javaResource.keySchema().applyValue({ args0 ->
            args0.transform(
                { args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            com.pulumi.awsnative.dynamodb.kotlin.outputs.TableKeySchema.Companion.toKotlin(args0)
                        })
                    })
                },
                { args0 -> args0 },
            )
        })

    /**
     * The Kinesis Data Streams configuration for the specified table.
     */
    public val kinesisStreamSpecification: Output?
        get() = javaResource.kinesisStreamSpecification().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableKinesisStreamSpecificationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Local secondary indexes to be created on the table. You can create up to 5 local secondary indexes. Each index is scoped to a given hash key value. The size of each hash key can be up to 10 gigabytes.
     */
    public val localSecondaryIndexes: Output>?
        get() = javaResource.localSecondaryIndexes().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 ->
                        tableLocalSecondaryIndexToKotlin(args0)
                    })
                })
            }).orElse(null)
        })

    /**
     * Sets the maximum number of read and write units for the specified on-demand table. If you use this property, you must specify ``MaxReadRequestUnits``, ``MaxWriteRequestUnits``, or both.
     */
    public val onDemandThroughput: Output?
        get() = javaResource.onDemandThroughput().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableOnDemandThroughputToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The settings used to enable point in time recovery.
     */
    public val pointInTimeRecoverySpecification: Output?
        get() = javaResource.pointInTimeRecoverySpecification().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tablePointInTimeRecoverySpecificationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Throughput for the specified table, which consists of values for ``ReadCapacityUnits`` and ``WriteCapacityUnits``. For more information about the contents of a provisioned throughput structure, see [Amazon DynamoDB Table ProvisionedThroughput](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ProvisionedThroughput.html).
     *  If you set ``BillingMode`` as ``PROVISIONED``, you must specify this property. If you set ``BillingMode`` as ``PAY_PER_REQUEST``, you cannot specify this property.
     */
    public val provisionedThroughput: Output?
        get() = javaResource.provisionedThroughput().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableProvisionedThroughputToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * A resource-based policy document that contains permissions to add to the specified table. In a CFNshort template, you can provide the policy in JSON or YAML format because CFNshort converts YAML to JSON before submitting it to DDB. For more information about resource-based policies, see [Using resource-based policies for](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/access-control-resource-based.html) and [Resource-based policy examples](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/rbac-examples.html).
     *  When you attach a resource-based policy while creating a table, the policy creation is *strongly consistent*. For information about the considerations that you should keep in mind while attaching a resource-based policy, see [Resource-based policy considerations](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/rbac-considerations.html).
     */
    public val resourcePolicy: Output?
        get() = javaResource.resourcePolicy().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableResourcePolicyToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * Specifies the settings to enable server-side encryption.
     */
    public val sseSpecification: Output?
        get() = javaResource.sseSpecification().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableSseSpecificationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The ARN of the DynamoDB stream, such as `arn:aws:dynamodb:us-east-1:123456789012:table/testddbstack-myDynamoDBTable-012A1SL7SMP5Q/stream/2015-11-30T20:10:00.000` .
     * > You must specify the `StreamSpecification` property to use this attribute.
     */
    public val streamArn: Output
        get() = javaResource.streamArn().applyValue({ args0 -> args0 })

    /**
     * The settings for the DDB table stream, which capture changes to items stored in the table.
     */
    public val streamSpecification: Output?
        get() = javaResource.streamSpecification().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableStreamSpecificationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The table class of the new table. Valid values are ``STANDARD`` and ``STANDARD_INFREQUENT_ACCESS``.
     */
    public val tableClass: Output?
        get() = javaResource.tableClass().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A name for the table. If you don't specify a name, CFNlong generates a unique physical ID and uses that ID for the table name. For more information, see [Name Type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-name.html).
     *   If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
     */
    public val tableName: Output?
        get() = javaResource.tableName().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * An array of key-value pairs to apply to this resource.
     *  For more information, see [Tag](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html).
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.let({ args0 -> tagToKotlin(args0) })
                })
            }).orElse(null)
        })

    /**
     * Specifies the Time to Live (TTL) settings for the table.
     *   For detailed information about the limits in DynamoDB, see [Limits in Amazon DynamoDB](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html) in the Amazon DynamoDB Developer Guide.
     */
    public val timeToLiveSpecification: Output?
        get() = javaResource.timeToLiveSpecification().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> tableTimeToLiveSpecificationToKotlin(args0) })
            }).orElse(null)
        })
}

public object TableMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.awsnative.dynamodb.Table::class == javaResource::class

    override fun map(javaResource: Resource): Table = Table(
        javaResource as
            com.pulumi.awsnative.dynamodb.Table,
    )
}

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

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