Giter Site home page Giter Site logo

devops-9 / terraform-aws-s3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clouddrove/terraform-aws-s3

0.0 1.0 0.0 77 KB

Terraform module to create default S3 bucket with logging and encryption type specific features.

Home Page: https://www.terraform.io/docs/providers/aws/r/s3_bucket.html

License: MIT License

HCL 78.36% Makefile 0.30% Go 21.34%

terraform-aws-s3's Introduction

Terraform AWS S3

Terraform module to create default S3 bucket with logging and encryption type specific features.

Terraform Licence


We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.

This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.

Prerequisites

This module has a few dependencies:

Examples

IMPORTANT: Since the master branch used in source varies based on new modifications, we suggest that you use the release versions here.

Here are some examples of how you can use this module in your inventory structure:

Basic Bucket

module "s3_bucket" {
  source              = "clouddrove/s3/aws"
  version             = "0.14.0"
  name                = "clouddrove-secure-bucket"
  environment         = "test"
  label_order         = ["name", "environment"]
  versioning          = true
  acl                 = "private"
  bucket_enabled      = true
}

Encryption Bucket

module "s3_bucket" {
  source                     = "clouddrove/s3/aws"
  version                    = "0.14.0"
  name                       = "clouddrove-encryption-bucket"
  environment                = "test"
  label_order                = ["name", "environment"]
  versioning                 = true
  acl                        = "private"
  bucket_encryption_enabled  = true
  sse_algorithm              = "aws:kms"
  kms_master_key_id          = module.kms_key.key_arn
}
### Logging-Encryption Bucket
```hcl
module "s3_bucket" {
  source                             = "clouddrove/s3/aws"
  version                            = "0.14.0"
  name                               = "clouddrove-logging-encryption-bucket"
  environment                        = "test"
  label_order                        = ["name", "environment"]
  versioning                         = true
  acl                                = "private"
  bucket_logging_encryption_enabled  = true
  sse_algorithm                      = "AES256"
  target_bucket                      = "bucket-logs12"
  target_prefix                      = "logs"
}

Logging Bucket

module "s3_bucket" {
  source                  = "clouddrove/s3/aws"
  version                 = "0.14.0"
  name                    = "clouddrove-logging-bucket"
  environment             = "test"
  label_order             = ["name", "environment"]
  versioning              = true
  acl                     = "private"
  bucket_logging_enabled  = true
  target_bucket           = "bucket-logs12"
  target_prefix           = "logs"
}

Website Host Bucket

module "s3_bucket" {
  source                              = "clouddrove/s3/aws"
  version                             = "0.14.0"
  name                                = "clouddrove-website-bucket"
  environment                         = "test"
  label_order                         = ["name", "environment"]
  versioning                          = true
  acl                                 = "private"
  website_hosting_bucket              = true
  website_index                       = "index.html"
  website_error                       = "error.html"
  bucket_policy                       = true
  lifecycle_expiration_enabled        = true
  lifecycle_expiration_object_prefix  = "test"
  lifecycle_days_to_expiration        = 10
  aws_iam_policy_document             = data.aws_iam_policy_document.default.json
}
data "aws_iam_policy_document" "default" {
  version = "2012-10-17"
  statement {
       sid = "Stmt1447315805704"
       effect = "Allow"
       principals {
            type = "AWS"
            identifiers = ["*"]
          }
       actions = ["s3:GetObject"]
       resources = ["arn:aws:s3:::clouddrove-website-bucket-test/*"]
   }
}

Inputs

Name Description Type Default Required
acl Canned ACL to apply to the S3 bucket. string "" no
attributes Additional attributes (e.g. 1). list(any) [] no
aws_iam_policy_document Specifies the number of days after object creation when the object expires. string "" no
bucket_enabled Enable simple S3. bool false no
bucket_encryption_enabled Enable encryption of S3. bool false no
bucket_logging_enabled Enable logging of S3. bool false no
bucket_logging_encryption_enabled Enable logging encryption of S3. bool false no
bucket_policy Conditionally create S3 bucket policy. bool false no
create_bucket Conditionally create S3 bucket. bool true no
delimiter Delimiter to be used between organization, environment, name and attributes. string "-" no
environment Environment (e.g. prod, dev, staging). string "" no
force_destroy A boolean that indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error. These objects are not recoverable. bool false no
kms_master_key_id The AWS KMS master key ID used for the SSE-KMS encryption. This can only be used when you set the value of sse_algorithm as aws:kms. The default aws/s3 AWS KMS master key is used if this element is absent while the sse_algorithm is aws:kms. string "" no
label_order Label order, e.g. name,application. list(any) [] no
lifecycle_days_to_expiration Specifies the number of days after object creation when the object expires. number 365 no
lifecycle_days_to_glacier_transition Specifies the number of days after object creation when it will be moved to Glacier storage. number 180 no
lifecycle_days_to_infrequent_storage_transition Specifies the number of days after object creation when it will be moved to standard infrequent access storage. number 60 no
lifecycle_expiration_enabled Specifies expiration lifecycle rule status. bool false no
lifecycle_expiration_object_prefix Object key prefix identifying one or more objects to which the lifecycle rule applies. string "" no
lifecycle_glacier_object_prefix Object key prefix identifying one or more objects to which the lifecycle rule applies. string "" no
lifecycle_glacier_transition_enabled Specifies Glacier transition lifecycle rule status. bool false no
lifecycle_infrequent_storage_object_prefix Object key prefix identifying one or more objects to which the lifecycle rule applies. string "" no
lifecycle_infrequent_storage_transition_enabled Specifies infrequent storage transition lifecycle rule status. bool false no
managedby ManagedBy, eg 'CloudDrove'. string "[email protected]" no
mfa_delete Enable MFA delete for either Change the versioning state of your bucket or Permanently delete an object version. bool false no
name Name (e.g. app or cluster). string "" no
repository Terraform current module repo string "https://registry.terraform.io/modules/clouddrove/s3/aws" no
sse_algorithm The server-side encryption algorithm to use. Valid values are AES256 and aws:kms. string "AES256" no
tags Additional tags (e.g. map(BusinessUnit,XYZ). map(any) {} no
target_bucket The name of the bucket that will receive the log objects. string "" no
target_prefix To specify a key prefix for log objects. string "" no
versioning Enable Versioning of S3. bool true no
website_error An absolute path to the document to return in case of a 4XX error. string "error.html" no
website_hosting_bucket Enable website hosting of S3. bool false no
website_index Amazon S3 returns this index document when requests are made to the root domain or any of the subfolders. string "index.html" no

Outputs

Name Description
arn The ARN of the s3 bucket.
bucket_domain_name The Domain of the s3 bucket.
id The ID of the s3 bucket.
tags A mapping of tags to assign to the resource.

Testing

In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.

You need to run the following command in the testing folder:

  go test -run Test

Feedback

If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at [email protected].

If you have found it worth your time, go ahead and give us a ★ on our GitHub!

About us

At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

We are The Cloud Experts!


We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

terraform-aws-s3's People

Contributors

anmolnagpal avatar dhyanio avatar sohanyadav avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.