aadesh-bhardwaj / terraform-aws-tfstate

Terraform Module to create Terraform state storage backend based on AWS S3 and DynamoDB for state locking.

Home Page:https://squareops.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWS tfstate Terraform module

squareops_avatar

SquareOps Technologies Your DevOps Partner for Accelerating cloud journey.


Terraform module to create Remote State Storage resources for workload deployment on AWS Cloud.

Usage Example

module "backend" {
  source = "squareops/tfstate/aws"

  environment                                     = "Production"
  bucket_name                                     = "tfstate"
  force_destroy                                   = true
  versioning_enabled                              = true
  logging                                         = true
}

Refer examples for more details.

IAM Permissions

The required IAM permissions to create resources from this module can be found here

Important Note

Terraform state locking is a mechanism used to prevent multiple users from simultaneously making changes to the same Terraform state, which could result in conflicts and data loss. A state lock is acquired and maintained by Terraform while it is making changes to the state, and other instances of Terraform are unable to make changes until the lock is released.

An Amazon S3 bucket and a DynamoDB table can be used as a remote backend to store and manage the Terraform state file, and also to implement state locking. The S3 bucket is used to store the state file, while the DynamoDB table is used to store the lock information, such as who acquired the lock and when. Terraform will check the lock state in the DynamoDB table before making changes to the state file in the S3 bucket, and will wait or retry if the lock is already acquired by another instance. This provides a centralized and durable mechanism for managing the Terraform state and ensuring that changes are made in a controlled and safe manner.

Security & Compliance

Security scanning is graciously provided by Prowler. Proowler is the leading fully hosted, cloud-native solution providing continuous cluster security and compliance.

Benchmark Description
Ensure that encryption is enabled for RDS instances Enabled for RDS created using this module.

Requirements

Name Version
terraform >= 1.0
aws >= 4.9

Providers

Name Version
aws >= 4.9

Modules

Name Source Version
kms_key clouddrove/kms/aws 0.15.0
log_bucket terraform-aws-modules/s3-bucket/aws 3.4.0
s3_bucket terraform-aws-modules/s3-bucket/aws 3.4.0

Resources

Name Type
aws_cloudtrail.s3_cloudtrail resource
aws_cloudwatch_log_group.s3_cloudwatch resource
aws_dynamodb_table.dynamodb_table resource
aws_iam_policy.s3_cloudtrail_cloudwatch_policy resource
aws_iam_role.s3_cloudtrail_cloudwatch_role resource
aws_iam_role.this resource
aws_iam_role_policy_attachment.s3_cloudtrail_policy_attachment resource
aws_kms_key.mykey resource
aws_caller_identity.current data source
aws_iam_policy_document.bucket_policy data source
aws_iam_policy_document.cloudtrail_assume_role data source
aws_iam_policy_document.default data source

Inputs

Name Description Type Default Required
bucket_name bucket name string "" no
environment Select enviroment type: dev, demo, prod string "demo" no
force_destroy Indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error bool false no
logging Map containing access bucket logging configuration bool false no
region In which region S3 bucket will create string "" no
versioning_enabled keeping multiple variants of an object in the same bucket bool false no

Outputs

Name Description
bucket_region In which region S3 bucket will create
dynamodb_table_name dynamodb table name
log_bucket_name logging table name
state_bucket_name bucket name with id

Contribution & Issue Reporting

To report an issue with a project:

  1. Check the repository's issue tracker on GitHub
  2. Search to see if the issue has already been reported
  3. If you can't find an answer to your question in the documentation or issue tracker, you can ask a question by creating a new issue. Make sure to provide enough context and details .

License

Apache License, Version 2.0, January 2004 (http://www.apache.org/licenses/).

Support Us

To support a GitHub project by liking it, you can follow these steps:

  1. Visit the repository: Navigate to the GitHub repository

  2. Click the "Star" button: On the repository page, you'll see a "Star" button in the upper right corner. Clicking on it will star the repository, indicating your support for the project.

  3. Optionally, you can also leave a comment on the repository or open an issue to give feedback or suggest changes.

Starring a repository on GitHub is a simple way to show your support and appreciation for the project. It also helps to increase the visibility of the project and make it more discoverable to others.

Who we are

We believe that the key to success in the digital age is the ability to deliver value quickly and reliably. That’s why we offer a comprehensive range of DevOps & Cloud services designed to help your organization optimize its systems & Processes for speed and agility.

  1. We are an AWS Advanced consulting partner which reflects our deep expertise in AWS Cloud and helping 100+ clients over the last 4 years.
  2. Expertise in Kubernetes and overall container solution helps companies expedite their journey by 10X.
  3. Infrastructure Automation is a key component to the success of our Clients and our Expertise helps deliver the same in the shortest time.
  4. DevSecOps as a service to implement security within the overall DevOps process and helping companies deploy securely and at speed.
  5. Platform engineering which supports scalable,Cost efficient infrastructure that supports rapid development, testing, and deployment.
  6. 24*7 SRE service to help you Monitor the state of your infrastructure and eradicate any issue within the SLA.

We provide support on all of our projects, no matter how small or large they may be.

You can find more information about our company on this squareops.com, follow us on Linkedin, or fill out a job application. If you have any questions or would like assistance with your cloud strategy and implementation, please don't hesitate to contact us.

About

Terraform Module to create Terraform state storage backend based on AWS S3 and DynamoDB for state locking.

https://squareops.com

License:Apache License 2.0


Languages

Language:HCL 100.0%