Skip to content

Commit

Permalink
Update to HCL 2.0 (#1)
Browse files Browse the repository at this point in the history
* requires TF 0.12, AWS Provider >2.10.0, Template Provier > 1.0.0

* adds examples for `simple`, `complex`, `logging`, `versioning`, `website`, SSE, and Object-lock configurations
  • Loading branch information
ksatirli authored Sep 30, 2019
1 parent d5fe1d3 commit 116a1fd
Show file tree
Hide file tree
Showing 24 changed files with 1,034 additions and 0 deletions.
121 changes: 121 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Terraform Module: AWS S3 Bucket DNS Records

> This repository is a [Terraform](https://terraform.io/) Module for managing AWS [S3 Bucket](https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html) for AWS S3 Buckets.
## Table of Contents

- [Terraform Module: AWS S3 Bucket DNS Records](#terraform-module-aws-s3-bucket-dns-records)
- [Table of Contents](#table-of-contents)
- [Requirements](#requirements)
- [Dependencies](#dependencies)
- [Usage](#usage)
- [Module Variables](#module-variables)
- [Module Outputs](#module-outputs)
- [Author Information](#author-information)
- [License](#license)

## Requirements

This module requires Terraform version `0.12.0` or newer.

## Dependencies

This module depends on a correctly configured [AWS Provider](https://www.terraform.io/docs/providers/aws/index.html) in your Terraform codebase.

## Usage

Add the module to your Terraform resources like so:

```hcl
module "simple-example" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demo-simple-example"
tags = {
Department = "Operations"
}
force_destroy = true
create_readme = false
}
```

Then, fetch the module from the [Terraform Registry](https://registry.terraform.io/modules/operatehappy/s3-bucket) using `terraform get`.

Additional usage examples are avaialble in the `examples` directory via [GitHub](https://github.com/operatehappy/terraform-aws-s3-bucket/tree/master/examples).

### Module Variables

Available variables are listed below, along with their default values:

| variable | type | description | default |
|----------------------------------------|---------------|--------------------------------------------------------------------------------------|-----------------|
| `name` | `string` | Name of S3 Bucket | |
| `use_prefix` | `bool` | Toggle to use randomly-generated Prefix for Bucket Name | `false` |
| `acl` | `string` | Canned ACL of S3 Bucket | `"private"` |
| `policy` | `string` | Policy (JSON) Document of S3 Bucket | `null` |
| `use_default_tags` | `bool` | Toggle to enable creation of default tags, containing Terraform Workspace identifier | `true` |
| `tags` | `map` | Mapping of Tags of S3 Bucket | `{}` |
| `force_destroy` | `bool` | Toggle to enable force-destruction of S3 Bucket | `false` |
| `website` | `map(string)` | Map of Website configuration of S3 Bucket | `{}` |
| `cors_rule` | `any` | Map of CORS Rules of S3 Bucket | `{}` |
| `versioning` | `map(string)` | Map of Versionining configuration of S3 Bucket | `{}` |
| `logging` | `map(string)` | Map of Logging configuration of S3 Bucket | `{}` |
| `lifecycle_rule` | `list` | Map of Lifecycle Rule configuration of S3 Bucket | `[]` |
| `acceleration_status` | `string` | Acceleration Status of S3 Bucket | `"Suspended"` |
| `request_payer` | `string` | Identifier for Request Cost-allocation of S3 Bucket | `"BucketOwner"` |
| `region` | `string` | Region of S3 Bucket | `null` |
| `server_side_encryption_configuration` | `map` | Server-side Encryption (SSE) Configuration of S3 Bucket | `{}` |
| `object_lock_configuration` | `any` | Object-lock Configuration of S3 Bucket | `{}` |
| `create_readme` | `bool` | Toggle creation of `README.md` in root of S3 Bucket | `true` |
| `readme_additions` | `string` | Additional content (e.g.: information, instructions) to add to README.md | `""` |

Additionally, the following variables are generated as [locals](https://www.terraform.io/docs/configuration/locals.html):

| key | value |
|-----------------|---------------------------------------------------------------------|
| `default_tags` | default tags containing Terraform Workspace identifier |
| `merged_tags` | merged value of `var.tags` and `local.default_tags` _or_ `var.tags` |
| `name` | value of `var.name` or `null` |
| `bucket_prefix` | value of `var.name` or `null` |

### Module Outputs

Available outputs are listed below, along with their description

| output | description |
|-------------------------------|----------------------------------------------|
| `id` | Name of the Bucket |
| `arn` | ARN of the Bucket |
| `bucket_domain_name` | Domain name of the Bucket |
| `bucket_regional_domain_name` | Region-specific domain name of the Bucket |
| `hosted_zone_id` | Hosted Zone ID of the Bucket's Region |
| `region` | Region of the Bucket |
| `website_endpoint` | Website Endpoint of the Bucket |
| `website_domain` | Domain of the Website Endpoint of the Bucket |
| `readme_id` | Key of the README file |
| `readme_etag` | ETag of the README file |
| `readme_version_id` | Version ID of the README file |

## Author Information

This module is currently maintained by the individuals listed below.

- [Kerim Satirli](https://github.com/ksatirli)

Development of this module was sponsored by [Operate Happy](https://github.com/operatehappy).

## License

Copyright 2019 [Kerim Satirli](https://github.com/ksatirli)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.

You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an _"AS IS"_ basis, without WARRANTIES or conditions of any kind, either express or implied.

See the License for the specific language governing permissions and limitations under the License.
68 changes: 68 additions & 0 deletions examples/complex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Example: `complex`

> This is an example of a _complex_ configuration of the [terraform-aws-s3-bucket Module](https://registry.terraform.io/modules/operatehappy/s3-bucket/)
## Table of Contents

- [Example: `complex`](#example-complex)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [Module Variables and Outputs](#module-variables-and-outputs)

## Installation

For a list of installation instructions, see the [Readme document](https://registry.terraform.io/modules/operatehappy/s3-bucket/) on the Terraform Registry.

## Usage

A _complex_ configuration of the `terraform-aws-s3-bucket` Module could look like this:

```hcl
// create S3 Bucket to be used as logging target
module "complex-example-target" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demos-complex-example-target"
acl = "log-delivery-write"
server_side_encryption_configuration = [{
kms_master_key_id = "alias/oh-demos"
sse_algorithm = "aws:kms"
}]
}
module "complex-example" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demos-complex-example"
tags = {
Department = "Operations"
}
force_destroy = true
versioning = [{
enabled = true
mfa_delete = false
}]
logging = [{
target_bucket = module.complex-example-target.id
target_prefix = "logs"
}]
server_side_encryption_configuration = [{
kms_master_key_id = "alias/oh-demos"
sse_algorithm = "aws:kms"
}]
}
```

## Module Variables and Outputs

For a list of available variables and outputs, see the [Readme document](https://registry.terraform.io/modules/operatehappy/s3-bucket/) on the Terraform Registry.

A copy of this document (as `README.md`) is also available on [GitHub](https://github.com/operatehappy/terraform-aws-s3-bucket/blob/master/README.md#readme).
39 changes: 39 additions & 0 deletions examples/complex/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module "complex-example-target" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demos-complex-example-target"
acl = "log-delivery-write"

server_side_encryption_configuration = [{
kms_master_key_id = "alias/oh-demos"
sse_algorithm = "aws:kms"
}]
}

module "complex-example" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"

name = "oh-demos-complex-example"

tags = {
Department = "Operations"
}

force_destroy = true

versioning = [{
enabled = true
mfa_delete = false
}]

logging = [{
target_bucket = module.complex-example-target.id
target_prefix = "logs"
}]

server_side_encryption_configuration = [{
kms_master_key_id = "alias/oh-demos"
sse_algorithm = "aws:kms"
}]
}
47 changes: 47 additions & 0 deletions examples/logging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Example: `logging`

> This is an example of a _logging_ configuration of the [terraform-aws-s3-bucket Module](https://registry.terraform.io/modules/operatehappy/s3-bucket/)
## Table of Contents

- [Example: `logging`](#example-logging)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [Module Variables and Outputs](#module-variables-and-outputs)

## Installation

For a list of installation instructions, see the [Readme document](https://registry.terraform.io/modules/operatehappy/s3-bucket/) on the Terraform Registry.

## Usage

A _logging_ configuration of the `terraform-aws-s3-bucket` Module could look like this:

```hcl
// create S3 Bucket to be used as logging target
module "logging-example-target" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demos-logging-example-target"
acl = "log-delivery-write"
}
module "logging-example" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demos-logging-example"
logging = {
target_bucket = module.logging-example-target.id
target_prefix = "logs"
}
}
```

## Module Variables and Outputs

For a list of available variables and outputs, see the [Readme document](https://registry.terraform.io/modules/operatehappy/s3-bucket/) on the Terraform Registry.

A copy of this document (as `README.md`) is also available on [GitHub](https://github.com/operatehappy/terraform-aws-s3-bucket/blob/master/README.md#readme).
18 changes: 18 additions & 0 deletions examples/logging/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module "logging-example-target" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demos-logging-example-target"
acl = "log-delivery-write"
}

module "logging-example" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"

name = "oh-demos-logging-example"

logging = {
target_bucket = module.logging-example-target.id
target_prefix = "logs"
}
}
45 changes: 45 additions & 0 deletions examples/object-lock-configuration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Example: `object-lock`

> This is an example of an _object-lock_ configuration of the [terraform-aws-s3-bucket Module](https://registry.terraform.io/modules/operatehappy/s3-bucket/)
## Table of Contents

- [Example: `object-lock`](#example-object-lock)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Usage](#usage)
- [Module Variables and Outputs](#module-variables-and-outputs)

## Installation

For a list of installation instructions, see the [Readme document](https://registry.terraform.io/modules/operatehappy/s3-bucket/) on the Terraform Registry.

## Usage

An _object-lock_ configuration of the `terraform-aws-s3-bucket` Module could look like this:

```hcl
module "object-lock-configuration-example" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"
name = "oh-demos-object-lock-configuration-example"
object_lock_configuration = {
object_lock_enabled = "Enabled"
rule = {
default_retention = {
mode = "GOVERNANCE"
days = 366
}
}
}
}
```

## Module Variables and Outputs

For a list of available variables and outputs, see the [Readme document](https://registry.terraform.io/modules/operatehappy/s3-bucket/) on the Terraform Registry.

A copy of this document (as `README.md`) is also available on [GitHub](https://github.com/operatehappy/terraform-aws-s3-bucket/blob/master/README.md#readme).
17 changes: 17 additions & 0 deletions examples/object-lock-configuration/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module "object-lock-configuration-example" {
source = "operatehappy/s3-bucket/aws"
version = "1.0.0"

name = "oh-demos-object-lock-configuration-example"

object_lock_configuration = {
object_lock_enabled = "Enabled"

rule = {
default_retention = {
mode = "GOVERNANCE"
days = 366
}
}
}
}
Loading

0 comments on commit 116a1fd

Please sign in to comment.