Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Terraform module to create AWS DynamoDB resources 🇺🇦

License

NotificationsYou must be signed in to change notification settings

terraform-aws-modules/terraform-aws-dynamodb-table

Terraform module to create a DynamoDB table.

Usage

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"  }}

Notes

Warning: enabling or disabling autoscaling can cause your table to be recreated

There are two separate Terraform resources used for the DynamoDB table: one is for when any autoscaling is enabled the other when disabled. If your table is already created and then you change the variableautoscaling_enabled then your table will be recreated by Terraform. In this case you will need to move the oldaws_dynamodb_table resource that is beingdestroyed to the new resource that is beingcreated. For example:

terraform state mv module.dynamodb_table.aws_dynamodb_table.this module.dynamodb_table.aws_dynamodb_table.autoscaled

Warning: autoscaling with global secondary indexes

When using an autoscaled provisioned table with GSIs you may find that applying TF changes whilst a GSI is scaled up will reset the capacity, thereis anopen issue for this on the AWS Provider. To get around this issue you can enabletheignore_changes_global_secondary_index setting however, using this setting means that any changes to GSIs will be ignored by Terraform and willhence have to be applied manually (or via some other automation).

NOTE: Settingignore_changes_global_secondary_index after the table is already created causes your table to be recreated. In this case, you willneed to move the oldaws_dynamodb_table resource that is beingdestroyed to the new resource that is beingcreated. For example:

terraform state mv module.dynamodb_table.aws_dynamodb_table.autoscaled module.dynamodb_table.aws_dynamodb_table.autoscaled_ignore_gsi

Module wrappers

Users of this Terraform module can create multiple similar resources by usingfor_each meta-argument withinmodule block which became available in Terraform 0.13.

Users of Terragrunt can achieve similar results by using modules provided in thewrappers directory, if they prefer to reduce amount of configuration files.

Examples

Requirements

NameVersion
terraform>= 1.5.7
aws>= 6.13

Providers

NameVersion
aws>= 6.13

Modules

No modules.

Resources

NameType
aws_appautoscaling_policy.index_read_policyresource
aws_appautoscaling_policy.index_write_policyresource
aws_appautoscaling_policy.table_read_policyresource
aws_appautoscaling_policy.table_write_policyresource
aws_appautoscaling_target.index_readresource
aws_appautoscaling_target.index_writeresource
aws_appautoscaling_target.table_readresource
aws_appautoscaling_target.table_writeresource
aws_dynamodb_resource_policy.thisresource
aws_dynamodb_table.autoscaledresource
aws_dynamodb_table.autoscaled_gsi_ignoreresource
aws_dynamodb_table.thisresource

Inputs

NameDescriptionTypeDefaultRequired
attributesList of nested attribute definitions. Only required for hash_key and range_key attributes. Each attribute has two properties: name - (Required) The name of the attribute, type - (Required) Attribute type, which must be a scalar type: S, N, or B for (S)tring, (N)umber or (B)inary datalist(map(string))[]no
autoscaling_defaultsA map of default autoscaling settingsmap(string)
{
"scale_in_cooldown": 0,
"scale_out_cooldown": 0,
"target_value": 70
}
no
autoscaling_enabledWhether or not to enable autoscaling. See note in README about this settingboolfalseno
autoscaling_indexesA map of index autoscaling configurations. See example in examples/autoscalingmap(map(string)){}no
autoscaling_readA map of read autoscaling settings.max_capacity is the only required key. See example in examples/autoscalingmap(string){}no
autoscaling_writeA map of write autoscaling settings.max_capacity is the only required key. See example in examples/autoscalingmap(string){}no
billing_modeControls how you are billed for read/write throughput and how you manage capacity. The valid values are PROVISIONED or PAY_PER_REQUESTstring"PAY_PER_REQUEST"no
create_tableControls if DynamoDB table and associated resources are createdbooltrueno
deletion_protection_enabledEnables deletion protection for tableboolnullno
global_secondary_indexesDescribe a GSI for the table; subject to the normal limits on the number of GSIs, projected attributes, etc.any[]no
hash_keyThe attribute to use as the hash (partition) key. Must also be defined as an attributestringnullno
ignore_changes_global_secondary_indexWhether to ignore changes lifecycle to global secondary indices, useful for provisioned tables with scalingboolfalseno
import_tableConfigurations for importing s3 data into a new table.any{}no
local_secondary_indexesDescribe an LSI on the table; these can only be allocated at creation so you cannot change this definition after you have created the resource.any[]no
nameName of the DynamoDB tablestringnullno
on_demand_throughputSets the maximum number of read and write units for the specified on-demand tableany{}no
point_in_time_recovery_enabledWhether to enable point-in-time recoveryboolfalseno
point_in_time_recovery_period_in_daysNumber of preceding days for which continuous backups are taken and maintained. Default 35numbernullno
range_keyThe attribute to use as the range (sort) key. Must also be defined as an attributestringnullno
read_capacityThe number of read units for this table. If the billing_mode is PROVISIONED, this field should be greater than 0numbernullno
regionRegion where this resource will be managed. Defaults to the Region set in the provider configurationstringnullno
replica_regionsRegion names for creating replicas for a global DynamoDB table.any[]no
resource_policyThe JSON definition of the resource-based policy.stringnullno
restore_date_timeTime of the point-in-time recovery point to restore.stringnullno
restore_source_nameName of the table to restore. Must match the name of an existing table.stringnullno
restore_source_table_arnARN of the source table to restore. Must be supplied for cross-region restores.stringnullno
restore_to_latest_timeIf set, restores table to the most recent point-in-time recovery point.boolnullno
server_side_encryption_enabledWhether or not to enable encryption at rest using an AWS managed KMS customer master key (CMK)boolfalseno
server_side_encryption_kms_key_arnThe 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.stringnullno
stream_enabledIndicates whether Streams are to be enabled (true) or disabled (false).boolfalseno
stream_view_typeWhen 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.stringnullno
table_classThe storage class of the table. Valid values are STANDARD and STANDARD_INFREQUENT_ACCESSstringnullno
tagsA map of tags to add to all resourcesmap(string){}no
timeoutsUpdated Terraform resource management timeoutsmap(string)
{
"create": "10m",
"delete": "10m",
"update": "60m"
}
no
ttl_attribute_nameThe name of the table attribute to store the TTL timestamp instring""no
ttl_enabledIndicates whether ttl is enabledboolfalseno
warm_throughputSets the number of warm read and write units for the specified tableany{}no
write_capacityThe number of write units for this table. If the billing_mode is PROVISIONED, this field should be greater than 0numbernullno

Outputs

NameDescription
dynamodb_table_arnARN of the DynamoDB table
dynamodb_table_idID of the DynamoDB table
dynamodb_table_stream_arnThe ARN of the Table Stream. Only available when var.stream_enabled is true
dynamodb_table_stream_labelA timestamp, in ISO 8601 format of the Table Stream. Only available when var.stream_enabled is true

Authors

Module is maintained byAnton Babenko with help fromthese awesome contributors.

License

Apache 2 Licensed. SeeLICENSE for full details.

About

Terraform module to create AWS DynamoDB resources 🇺🇦

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp