/terraform-aws-tf-state

Terraform / OpenTofu module for storing Terraform / OpenTofu state in AWS S3 bucket and state locks in AWS DynamoDB.

Primary LanguageHCLApache License 2.0Apache-2.0

terraform-aws-tf-state

Terraform / OpenTofu module for storing Terraform / OpenTofu state in AWS S3 bucket and state locks in AWS DynamoDB.

Usage

Create resources

module "tf_state" {
    source  = "voidsolutionsorg/tf-state/aws"
    version = "1.0.0"

    project_name = "example"
}

Setup backend configuration

terraform {
  backend "s3" {
    bucket         = "example-tf-state"
    key            = "myapp/production/tfstate"
    region         = "us-east-1"
    dynamodb_table = "example-tf-state-lock"
    encrypt        = true
  }
}

Requirements

Name Version
terraform >= 1.5.0
aws ~> 5.0

Providers

Name Version
aws 5.61.0

Modules

No modules.

Resources

Name Type
aws_dynamodb_table.tf_state_lock resource
aws_s3_bucket.tf_state resource
aws_s3_bucket_acl.tf_state resource
aws_s3_bucket_ownership_controls.tf_state resource
aws_s3_bucket_versioning.tf_state resource

Inputs

Name Description Type Default Required
billing_mode The billing mode for the DynamoDB table string "PAY_PER_REQUEST" no
force_destroy Destroy the bucket even if it contains objects bool true no
project_name The name of the project, used for naming resources string n/a yes
read_capacity The read capacity for the DynamoDB table number null no
tags A map of tags to add to all resources map(string) {} no
write_capacity The write capacity for the DynamoDB table number null no

Outputs

No outputs.

Authors

Module is maintained by Aleksa Siriški with help from the VoidSolutions team.

License

Apache 2 Licensed. See LICENSE for full details.