### Terraform Initialization, Planning, and Application Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/autoscaling/README.md These commands are used to initialize the Terraform working directory, generate an execution plan, and apply the changes to create the AWS DynamoDB table with autoscaling. ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Terraform Random Pet Resource Example Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/s3-import/README.md This snippet shows the use of the `random_pet` resource from the `random` provider in Terraform. This is often used for generating unique names or identifiers in examples. ```hcl resource "random_pet" "this" { length = 2 } ``` -------------------------------- ### Terraform Configuration for DynamoDB Table Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/basic/README.md This Terraform configuration defines the requirements, providers, and modules needed to create a DynamoDB table. It includes a reference to a random pet resource for demonstration purposes. ```terraform terraform { required_providers { aws = { source = "hashicorp/aws" version = ">= 6.9" } random = { source = "hashicorp/random" version = ">= 2.0" } } required_version = ">= 1.5.7" } provider "random" { version = ">= 2.0" } module "dynamodb_table" { source = "../../" } module "disabled_dynamodb_table" { source = "../../" } resource "random_pet" "this" {} ``` -------------------------------- ### Terraform Provider Requirements Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/global-tables/README.md Defines the minimum required versions for Terraform itself and the AWS and random providers. These version constraints ensure compatibility and access to necessary features. ```hcl terraform { required_providers { aws = { source = "hashicorp/aws" version = ">= 6.9" } random = { source = "hashicorp/random" version = ">= 2.0" } } required_version = ">= 1.5.7" } ``` -------------------------------- ### Terraform DynamoDB Table Outputs Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/global-tables/README.md Defines the outputs for the DynamoDB table, including its ARN, ID, stream ARN, and stream label. These outputs provide access to important information about the created table after deployment. ```hcl output "dynamodb_table_arn" { description = "ARN of the DynamoDB table" value = module.dynamodb_table.dynamodb_table_arn } output "dynamodb_table_id" { description = "ID of the DynamoDB table" value = module.dynamodb_table.dynamodb_table_id } output "dynamodb_table_stream_arn" { description = "The ARN of the Table Stream. Only available when var.stream_enabled is true" value = module.dynamodb_table.dynamodb_table_stream_arn } output "dynamodb_table_stream_label" { description = "A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream_enabled is true" value = module.dynamodb_table.dynamodb_table_stream_label } ``` -------------------------------- ### Terraform DynamoDB Table Module Usage Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/global-tables/README.md Includes the DynamoDB table module from a local path. This snippet demonstrates how to incorporate reusable Terraform modules into your infrastructure code to define the DynamoDB table. ```hcl module "dynamodb_table" { source = "../../" # Add other module inputs here if needed } ``` -------------------------------- ### Terraform AWS Provider Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/global-tables/README.md Configures the AWS provider for the primary region (eu-west-1) and an additional region (eu-west-2). This setup allows the Terraform configuration to manage resources in multiple AWS regions. ```hcl provider "aws" { region = "eu-west-1" } provider "aws" { alias = "euwest2" region = "eu-west-2" } ``` -------------------------------- ### Terraform Configuration for DynamoDB JSON Import Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/s3-import/README.md This Terraform configuration utilizes the `terraform-aws-modules/s3-bucket/aws` module to create an S3 bucket and upload a JSON file, subsequently importing data into a DynamoDB table. It requires the `aws` and `random` providers. ```hcl module "import_json_table" { source = "../../" } module "s3_bucket" { source = "terraform-aws-modules/s3-bucket/aws" version = "~> 3.15" } module "s3_import_object_json" { source = "terraform-aws-modules/s3-bucket/aws//modules/object" version = "~> 3.15" bucket_name = module.s3_bucket.bucket_id source = "./data.json" key = "data.json" } ``` -------------------------------- ### Create DynamoDB Table with Terraform Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md This snippet demonstrates the basic usage of the Terraform module to create a DynamoDB table. It defines the table name, hash key, attributes, and tags. Ensure Terraform and the AWS provider are installed and configured. ```hcl module "dynamodb_table" { source = "terraform-aws-modules/dynamodb-table/aws" name = "my-table" hash_key = "id" attributes = [ { name = "id" type = "N" } ] tags = { Terraform = "true" Environment = "staging" } } ``` -------------------------------- ### Terraform AWS KMS Key Resources Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/global-tables/README.md Defines primary and secondary AWS KMS (Key Management Service) keys. These keys are used for encrypting data within the DynamoDB table, enhancing security. ```hcl resource "aws_kms_key" "primary" { description = "primary_key" deletion_ அதிகரிக்கிறது = false enable_key_rotation = true tags = { Name = "primary_key" Environment = "DynamoDB-Global-Table" } } resource "aws_kms_key" "secondary" { provider = aws.euwest2 description = "secondary_key" deletion_ அதிகரிக்கிறது = false enable_key_rotation = true tags = { Name = "secondary_key" Environment = "DynamoDB-Global-Table" } } ``` -------------------------------- ### Terraform Configuration for DynamoDB CSV Import Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/examples/s3-import/README.md This Terraform configuration uses the `terraform-aws-modules/s3-bucket/aws` module to create an S3 bucket and upload a CSV file, which is then used to import data into a DynamoDB table. It depends on the `aws` and `random` providers. ```hcl module "import_csv_table" { source = "../../" } module "s3_bucket" { source = "terraform-aws-modules/s3-bucket/aws" version = "~> 3.15" } module "s3_import_object_csv" { source = "terraform-aws-modules/s3-bucket/aws//modules/object" version = "~> 3.15" bucket_name = module.s3_bucket.bucket_id source = "./data.csv" key = "data.csv" } ``` -------------------------------- ### Move Terraform DynamoDB Table Resource Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Provides an example of how to move a Terraform DynamoDB table resource when changing autoscaling configurations. This is necessary to prevent table recreation when switching between autoscaled and non-autoscaled states. ```bash terraform state mv module.dynamodb_table.aws_dynamodb_table.this module.dynamodb_table.aws_dynamodb_table.autoscaled ``` -------------------------------- ### DynamoDB Table Wrapper with Terragrunt Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/wrappers/README.md Demonstrates using the DynamoDB Table module wrapper with Terragrunt. It specifies the source for the wrapper module and defines default input values and specific items for configuration. This pattern is useful for managing multiple module instances in Terragrunt. ```hcl terraform { source = "tfr:///terraform-aws-modules/dynamodb-table/aws//wrappers" # Alternative source: # source = "git::git@github.com:terraform-aws-modules/terraform-aws-dynamodb-table.git//wrappers?ref=master" } inputs = { defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### DynamoDB Table Wrapper with Terraform Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/wrappers/README.md Shows how to use the DynamoDB Table module wrapper directly with Terraform. It defines a module block specifying the source and provides input variables for default configurations and specific items, enabling management of multiple table instances. ```hcl module "wrapper" { source = "terraform-aws-modules/dynamodb-table/aws//wrappers" defaults = { # Default values create = true tags = { Terraform = "true" Environment = "dev" } } items = { my-item = { # omitted... can be any argument supported by the module } my-second-item = { # omitted... can be any argument supported by the module } # omitted... } } ``` -------------------------------- ### S3 Bucket Wrapper with Terragrunt Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/wrappers/README.md Illustrates managing multiple S3 buckets within a single Terragrunt layer using the S3 Bucket module wrapper. It configures default settings like `force_destroy` and specifies bucket names and tags for individual items, promoting code reuse. ```hcl terraform { source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" # Alternative source: # source = "git::git@github.com:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" } inputs = { defaults = { force_destroy = true attach_elb_log_delivery_policy = true attach_lb_log_delivery_policy = true attach_deny_insecure_transport_policy = true attach_require_latest_tls_policy = true } items = { bucket1 = { bucket = "my-random-bucket-1" } bucket2 = { bucket = "my-random-bucket-2" tags = { Secure = "probably" } } } } ``` -------------------------------- ### DynamoDB Import Table Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Configures the import of data from an S3 bucket into a new DynamoDB table. ```terraform import_table = { source_table_arn = "arn:aws:dynamodb:us-east-1:123456789012:table/my-source-table" input_format = "DYNAMODB_JSON" } ``` -------------------------------- ### DynamoDB Table Configuration Inputs Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md This snippet details the input variables for configuring a DynamoDB table using Terraform. It covers attributes like encryption, streams, TTL, and capacity settings. ```terraform resource_policy: The JSON definition of the resource-based policy. restore_date_time: Time of the point-in-time recovery point to restore. restore_source_name: Name of the table to restore. Must match the name of an existing table. restore_source_table_arn: ARN of the source table to restore. Must be supplied for cross-region restores. restore_to_latest_time: If set, restores table to the most recent point-in-time recovery point. server_side_encryption_enabled: Whether or not to enable encryption at rest using an AWS managed KMS customer master key (CMK) server_side_encryption_kms_key_arn: The ARN of the CMK that should be used for the AWS KMS encryption. This attribute should only be specified if the key is different from the default DynamoDB CMK, alias/aws/dynamodb. stream_enabled: Indicates whether Streams are to be enabled (true) or disabled (false). stream_view_type: When an item in the table is modified, StreamViewType determines what information is written to the table's stream. Valid values are KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES. table_class: The storage class of the table. Valid values are STANDARD and STANDARD_INFREQUENT_ACCESS tags: A map of tags to add to all resources timeouts: Updated Terraform resource management timeouts ttl_attribute_name: The name of the table attribute to store the TTL timestamp in ttl_enabled: Indicates whether ttl is enabled write_capacity: The number of write units for this table. If the billing_mode is PROVISIONED, this field should be greater than 0 ``` -------------------------------- ### DynamoDB Autoscaling Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Configures autoscaling for DynamoDB tables and their global secondary indexes. Includes default settings and specific configurations for read and write capacity. ```terraform autoscaling_enabled = true autoscaling_defaults = { scale_in_cooldown = 60 scale_out_cooldown = 60 target_value = 70 } autoscaling_read = { min_capacity = 5 max_capacity = 50 } autoscaling_write = { min_capacity = 5 max_capacity = 50 } autoscaling_indexes = { "my-gsi" = { read_min_capacity = 5 read_max_capacity = 50 write_min_capacity = 5 write_max_capacity = 50 } } ``` -------------------------------- ### DynamoDB Local Secondary Index (LSI) Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Defines local secondary indexes for the DynamoDB table. These indexes can only be created at table creation time. ```terraform local_secondary_indexes = [ { name = "my-lsi" hash_key = "id" range_key = "data" non_key_attributes = ["data"] projection_type = "KEYS_ONLY" } ] ``` -------------------------------- ### DynamoDB Point-in-Time Recovery Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Enables and configures point-in-time recovery for the DynamoDB table, allowing restoration to any point in time. ```terraform point_in_time_recovery_enabled = true point_in_time_recovery_period_in_days = 7 ``` -------------------------------- ### Move Terraform DynamoDB Table Resource (Ignore GSI) Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Demonstrates moving a Terraform DynamoDB table resource when the `ignore_changes_global_secondary_index` setting is applied after the table has already been created. This prevents table recreation when this specific setting is changed. ```bash terraform state mv module.dynamodb_table.aws_dynamodb_table.autoscaled module.dynamodb_table.aws_dynamodb_table.autoscaled_ignore_gsi ``` -------------------------------- ### DynamoDB Global Secondary Index (GSI) Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Defines global secondary indexes for the DynamoDB table, including their key schema and projected attributes. ```terraform global_secondary_indexes = [ { name = "my-gsi" hash_key = "data" range_key = "id" non_key_attributes = ["data"] projection_type = "INCLUDE" } ] ``` -------------------------------- ### DynamoDB Table Output Values Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md This snippet outlines the output values provided by the DynamoDB table Terraform module. These outputs include the table's ARN, ID, and stream-related information when streams are enabled. ```terraform dynamodb_table_arn: ARN of the DynamoDB table dynamodb_table_id: ID of the DynamoDB table dynamodb_table_stream_arn: The ARN of the Table Stream. Only available when var.stream_enabled is true dynamodb_table_stream_label: A timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream_enabled is true ``` -------------------------------- ### DynamoDB Replication Regions Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Specifies the AWS regions where replicas of the DynamoDB table should be created for global table functionality. ```terraform replica_regions = ["us-west-2", "eu-central-1"] ``` -------------------------------- ### DynamoDB Primary Key Definition Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Specifies the hash (partition) key for the DynamoDB table. ```terraform hash_key = "id" range_key = "data" ``` -------------------------------- ### DynamoDB Table Attributes Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Defines the attributes for a DynamoDB table, specifying their names and types. Essential for defining primary keys (hash_key and range_key). ```terraform attributes = [ { name = "id" type = "S" }, { name = "data" type = "S" } ] ``` -------------------------------- ### DynamoDB Billing Mode Configuration Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Specifies the billing mode for the DynamoDB table, choosing between provisioned throughput or on-demand capacity. ```terraform billing_mode = "PROVISIONED" read_capacity = 10 write_capacity = 10 ``` ```terraform billing_mode = "PAY_PER_REQUEST" on_demand_throughput = { read_capacity_units = 10 write_capacity_units = 10 } ``` -------------------------------- ### DynamoDB Table Name Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Specifies the name of the DynamoDB table. ```terraform name = "my-dynamodb-table" ``` -------------------------------- ### DynamoDB Table Creation Control Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Controls whether the DynamoDB table and its associated resources are created by the module. ```terraform create_table = false ``` -------------------------------- ### DynamoDB Ignore Changes for GSI Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Option to ignore lifecycle changes for global secondary indexes, useful for provisioned tables with active scaling. ```terraform ignore_changes_global_secondary_index = true ``` -------------------------------- ### DynamoDB Deletion Protection Source: https://github.com/terraform-aws-modules/terraform-aws-dynamodb-table/blob/master/README.md Enables or disables deletion protection for the DynamoDB table, preventing accidental deletion. ```terraform deletion_protection_enabled = true ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.