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

com.pulumi.aws.dynamodb.kotlin.GlobalTable.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.dynamodb.kotlin

import com.pulumi.aws.dynamodb.kotlin.outputs.GlobalTableReplica
import com.pulumi.aws.dynamodb.kotlin.outputs.GlobalTableReplica.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 [GlobalTable].
 */
@PulumiTagMarker
public class GlobalTableResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: GlobalTableArgs = GlobalTableArgs()

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

/**
 * Manages [DynamoDB Global Tables V1 (version 2017.11.29)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V1.html). These are layered on top of existing DynamoDB Tables.
 * > **NOTE:** To instead manage [DynamoDB Global Tables V2 (version 2019.11.21)](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables.V2.html), use the `aws.dynamodb.Table` resource `replica` configuration block.
 * > Note: There are many restrictions before you can properly create DynamoDB Global Tables in multiple regions. See the [AWS DynamoDB Global Table Requirements](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/globaltables_reqs_bestpractices.html) for more information.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const us_east_1 = new aws.dynamodb.Table("us-east-1", {
 *     hashKey: "myAttribute",
 *     name: "myTable",
 *     streamEnabled: true,
 *     streamViewType: "NEW_AND_OLD_IMAGES",
 *     readCapacity: 1,
 *     writeCapacity: 1,
 *     attributes: [{
 *         name: "myAttribute",
 *         type: "S",
 *     }],
 * });
 * const us_west_2 = new aws.dynamodb.Table("us-west-2", {
 *     hashKey: "myAttribute",
 *     name: "myTable",
 *     streamEnabled: true,
 *     streamViewType: "NEW_AND_OLD_IMAGES",
 *     readCapacity: 1,
 *     writeCapacity: 1,
 *     attributes: [{
 *         name: "myAttribute",
 *         type: "S",
 *     }],
 * });
 * const myTable = new aws.dynamodb.GlobalTable("myTable", {
 *     name: "myTable",
 *     replicas: [
 *         {
 *             regionName: "us-east-1",
 *         },
 *         {
 *             regionName: "us-west-2",
 *         },
 *     ],
 * }, {
 *     dependsOn: [
 *         us_east_1,
 *         us_west_2,
 *     ],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * us_east_1 = aws.dynamodb.Table("us-east-1",
 *     hash_key="myAttribute",
 *     name="myTable",
 *     stream_enabled=True,
 *     stream_view_type="NEW_AND_OLD_IMAGES",
 *     read_capacity=1,
 *     write_capacity=1,
 *     attributes=[{
 *         "name": "myAttribute",
 *         "type": "S",
 *     }])
 * us_west_2 = aws.dynamodb.Table("us-west-2",
 *     hash_key="myAttribute",
 *     name="myTable",
 *     stream_enabled=True,
 *     stream_view_type="NEW_AND_OLD_IMAGES",
 *     read_capacity=1,
 *     write_capacity=1,
 *     attributes=[{
 *         "name": "myAttribute",
 *         "type": "S",
 *     }])
 * my_table = aws.dynamodb.GlobalTable("myTable",
 *     name="myTable",
 *     replicas=[
 *         {
 *             "region_name": "us-east-1",
 *         },
 *         {
 *             "region_name": "us-west-2",
 *         },
 *     ],
 *     opts = pulumi.ResourceOptions(depends_on=[
 *             us_east_1,
 *             us_west_2,
 *         ]))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var us_east_1 = new Aws.DynamoDB.Table("us-east-1", new()
 *     {
 *         HashKey = "myAttribute",
 *         Name = "myTable",
 *         StreamEnabled = true,
 *         StreamViewType = "NEW_AND_OLD_IMAGES",
 *         ReadCapacity = 1,
 *         WriteCapacity = 1,
 *         Attributes = new[]
 *         {
 *             new Aws.DynamoDB.Inputs.TableAttributeArgs
 *             {
 *                 Name = "myAttribute",
 *                 Type = "S",
 *             },
 *         },
 *     });
 *     var us_west_2 = new Aws.DynamoDB.Table("us-west-2", new()
 *     {
 *         HashKey = "myAttribute",
 *         Name = "myTable",
 *         StreamEnabled = true,
 *         StreamViewType = "NEW_AND_OLD_IMAGES",
 *         ReadCapacity = 1,
 *         WriteCapacity = 1,
 *         Attributes = new[]
 *         {
 *             new Aws.DynamoDB.Inputs.TableAttributeArgs
 *             {
 *                 Name = "myAttribute",
 *                 Type = "S",
 *             },
 *         },
 *     });
 *     var myTable = new Aws.DynamoDB.GlobalTable("myTable", new()
 *     {
 *         Name = "myTable",
 *         Replicas = new[]
 *         {
 *             new Aws.DynamoDB.Inputs.GlobalTableReplicaArgs
 *             {
 *                 RegionName = "us-east-1",
 *             },
 *             new Aws.DynamoDB.Inputs.GlobalTableReplicaArgs
 *             {
 *                 RegionName = "us-west-2",
 *             },
 *         },
 *     }, new CustomResourceOptions
 *     {
 *         DependsOn =
 *         {
 *             us_east_1,
 *             us_west_2,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/dynamodb"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := dynamodb.NewTable(ctx, "us-east-1", &dynamodb.TableArgs{
 * 			HashKey:        pulumi.String("myAttribute"),
 * 			Name:           pulumi.String("myTable"),
 * 			StreamEnabled:  pulumi.Bool(true),
 * 			StreamViewType: pulumi.String("NEW_AND_OLD_IMAGES"),
 * 			ReadCapacity:   pulumi.Int(1),
 * 			WriteCapacity:  pulumi.Int(1),
 * 			Attributes: dynamodb.TableAttributeArray{
 * 				&dynamodb.TableAttributeArgs{
 * 					Name: pulumi.String("myAttribute"),
 * 					Type: pulumi.String("S"),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = dynamodb.NewTable(ctx, "us-west-2", &dynamodb.TableArgs{
 * 			HashKey:        pulumi.String("myAttribute"),
 * 			Name:           pulumi.String("myTable"),
 * 			StreamEnabled:  pulumi.Bool(true),
 * 			StreamViewType: pulumi.String("NEW_AND_OLD_IMAGES"),
 * 			ReadCapacity:   pulumi.Int(1),
 * 			WriteCapacity:  pulumi.Int(1),
 * 			Attributes: dynamodb.TableAttributeArray{
 * 				&dynamodb.TableAttributeArgs{
 * 					Name: pulumi.String("myAttribute"),
 * 					Type: pulumi.String("S"),
 * 				},
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = dynamodb.NewGlobalTable(ctx, "myTable", &dynamodb.GlobalTableArgs{
 * 			Name: pulumi.String("myTable"),
 * 			Replicas: dynamodb.GlobalTableReplicaArray{
 * 				&dynamodb.GlobalTableReplicaArgs{
 * 					RegionName: pulumi.String("us-east-1"),
 * 				},
 * 				&dynamodb.GlobalTableReplicaArgs{
 * 					RegionName: pulumi.String("us-west-2"),
 * 				},
 * 			},
 * 		}, pulumi.DependsOn([]pulumi.Resource{
 * 			us_east_1,
 * 			us_west_2,
 * 		}))
 * 		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.dynamodb.Table;
 * import com.pulumi.aws.dynamodb.TableArgs;
 * import com.pulumi.aws.dynamodb.inputs.TableAttributeArgs;
 * import com.pulumi.aws.dynamodb.GlobalTable;
 * import com.pulumi.aws.dynamodb.GlobalTableArgs;
 * import com.pulumi.aws.dynamodb.inputs.GlobalTableReplicaArgs;
 * import com.pulumi.resources.CustomResourceOptions;
 * 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 us_east_1 = new Table("us-east-1", TableArgs.builder()
 *             .hashKey("myAttribute")
 *             .name("myTable")
 *             .streamEnabled(true)
 *             .streamViewType("NEW_AND_OLD_IMAGES")
 *             .readCapacity(1)
 *             .writeCapacity(1)
 *             .attributes(TableAttributeArgs.builder()
 *                 .name("myAttribute")
 *                 .type("S")
 *                 .build())
 *             .build());
 *         var us_west_2 = new Table("us-west-2", TableArgs.builder()
 *             .hashKey("myAttribute")
 *             .name("myTable")
 *             .streamEnabled(true)
 *             .streamViewType("NEW_AND_OLD_IMAGES")
 *             .readCapacity(1)
 *             .writeCapacity(1)
 *             .attributes(TableAttributeArgs.builder()
 *                 .name("myAttribute")
 *                 .type("S")
 *                 .build())
 *             .build());
 *         var myTable = new GlobalTable("myTable", GlobalTableArgs.builder()
 *             .name("myTable")
 *             .replicas(
 *                 GlobalTableReplicaArgs.builder()
 *                     .regionName("us-east-1")
 *                     .build(),
 *                 GlobalTableReplicaArgs.builder()
 *                     .regionName("us-west-2")
 *                     .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(
 *                     us_east_1,
 *                     us_west_2)
 *                 .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   us-east-1:
 *     type: aws:dynamodb:Table
 *     properties:
 *       hashKey: myAttribute
 *       name: myTable
 *       streamEnabled: true
 *       streamViewType: NEW_AND_OLD_IMAGES
 *       readCapacity: 1
 *       writeCapacity: 1
 *       attributes:
 *         - name: myAttribute
 *           type: S
 *   us-west-2:
 *     type: aws:dynamodb:Table
 *     properties:
 *       hashKey: myAttribute
 *       name: myTable
 *       streamEnabled: true
 *       streamViewType: NEW_AND_OLD_IMAGES
 *       readCapacity: 1
 *       writeCapacity: 1
 *       attributes:
 *         - name: myAttribute
 *           type: S
 *   myTable:
 *     type: aws:dynamodb:GlobalTable
 *     properties:
 *       name: myTable
 *       replicas:
 *         - regionName: us-east-1
 *         - regionName: us-west-2
 *     options:
 *       dependson:
 *         - ${["us-east-1"]}
 *         - ${["us-west-2"]}
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import DynamoDB Global Tables using the global table name. For example:
 * ```sh
 * $ pulumi import aws:dynamodb/globalTable:GlobalTable MyTable MyTable
 * ```
 */
public class GlobalTable internal constructor(
    override val javaResource: com.pulumi.aws.dynamodb.GlobalTable,
) : KotlinCustomResource(javaResource, GlobalTableMapper) {
    /**
     * The ARN of the DynamoDB Global Table
     */
    public val arn: Output
        get() = javaResource.arn().applyValue({ args0 -> args0 })

    /**
     * The name of the global table. Must match underlying DynamoDB Table names in all regions.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * Underlying DynamoDB Table. At least 1 replica must be defined. See below.
     */
    public val replicas: Output>
        get() = javaResource.replicas().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            })
        })
}

public object GlobalTableMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.dynamodb.GlobalTable::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy