Skip to content

Commit 5ce52e3

Browse files
Merge pull request #3 from RohitSquareops/main
Updated readme, variables
2 parents c0426b2 + 1443010 commit 5ce52e3

File tree

12 files changed

+63
-60
lines changed

12 files changed

+63
-60
lines changed

IAM.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
The Policy required is:
55

66
```json
7-
{
7+
{
88
"Version": "2012-10-17",
99
"Statement": [
1010
{
@@ -110,4 +110,4 @@ The Policy required is:
110110
}
111111

112112
```
113-
<!-- END OF PRE-COMMIT-PIKE DOCS HOOK -->
113+
<!-- END OF PRE-COMMIT-PIKE DOCS HOOK -->

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2023 SquareOps Technologies Pvt. Ltd.
189+
Copyright 2023 SquareOps Technologies Pvt. Ltd.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@ Terraform module to create Remote State Storage resources for workload deploymen
1212
```hcl
1313
module "backend" {
1414
source = "squareops/tfstate/aws"
15-
15+
logging = true
1616
environment = "Production"
1717
bucket_name = "tfstate"
1818
force_destroy = true
1919
versioning_enabled = true
20-
logging = true
2120
}
2221
2322
```
24-
Refer [examples](https://github.com/squareops/terraform-aws-tfstate/tree/main/examples/state-storage-backend) for more details.
23+
Refer [examples](https://github.com/squareops/terraform-aws-tfstate/tree/main/examples/state-storage-backend) for more details.
2524

2625
## IAM Permissions
2726
The required IAM permissions to create resources from this module can be found [here](https://github.com/squareops/terraform-aws-tfstate/blob/main/IAM.md)
@@ -60,8 +59,8 @@ In this module, we have implemented the following CIS Compliance checks for S3:
6059
| Name | Source | Version |
6160
|------|--------|---------|
6261
| <a name="module_kms_key"></a> [kms\_key](#module\_kms\_key) | clouddrove/kms/aws | 0.15.0 |
63-
| <a name="module_log_bucket"></a> [log\_bucket](#module\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | 3.4.0 |
64-
| <a name="module_s3_bucket"></a> [s3\_bucket](#module\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | 3.4.0 |
62+
| <a name="module_log_bucket"></a> [log\_bucket](#module\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | 3.10.0 |
63+
| <a name="module_s3_bucket"></a> [s3\_bucket](#module\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | 3.10.0 |
6564

6665
## Resources
6766

@@ -79,26 +78,25 @@ In this module, we have implemented the following CIS Compliance checks for S3:
7978
| [aws_iam_policy_document.bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
8079
| [aws_iam_policy_document.cloudtrail_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
8180
| [aws_iam_policy_document.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
81+
| [aws_region.region](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
8282

8383
## Inputs
8484

8585
| Name | Description | Type | Default | Required |
8686
|------|-------------|------|---------|:--------:|
87-
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | bucket name | `string` | `""` | no |
88-
| <a name="input_environment"></a> [environment](#input\_environment) | Select enviroment type: dev, demo, prod | `string` | `"demo"` | no |
89-
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | Indicates all objects should be deleted from the bucket so that the bucket can be destroyed without error | `bool` | `false` | no |
90-
| <a name="input_logging"></a> [logging](#input\_logging) | Map containing access bucket logging configuration | `bool` | `false` | no |
91-
| <a name="input_region"></a> [region](#input\_region) | In which region S3 bucket will create | `string` | `""` | no |
92-
| <a name="input_versioning_enabled"></a> [versioning\_enabled](#input\_versioning\_enabled) | keeping multiple variants of an object in the same bucket | `bool` | `false` | no |
87+
| <a name="input_bucket_name"></a> [bucket\_name](#input\_bucket\_name) | Name of the S3 bucket to be created. | `string` | `""` | no |
88+
| <a name="input_environment"></a> [environment](#input\_environment) | Specify the type of environment(dev, demo, prod) in which the S3 bucket will be created. | `string` | `"demo"` | no |
89+
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | Whether or not to delete all objects from the bucket to allow for destruction of the bucket without error. | `bool` | `false` | no |
90+
| <a name="input_logging"></a> [logging](#input\_logging) | Configuration for S3 bucket access logging. | `bool` | `true` | no |
91+
| <a name="input_versioning_enabled"></a> [versioning\_enabled](#input\_versioning\_enabled) | Whether or not to enable versioning for the S3 bucket, which allows multiple versions of an object to be stored in the same bucket. | `bool` | `false` | no |
9392

9493
## Outputs
9594

9695
| Name | Description |
9796
|------|-------------|
98-
| <a name="output_bucket_region"></a> [bucket\_region](#output\_bucket\_region) | In which region S3 bucket will create |
99-
| <a name="output_dynamodb_table_name"></a> [dynamodb\_table\_name](#output\_dynamodb\_table\_name) | dynamodb table name |
100-
| <a name="output_log_bucket_name"></a> [log\_bucket\_name](#output\_log\_bucket\_name) | logging table name |
101-
| <a name="output_state_bucket_name"></a> [state\_bucket\_name](#output\_state\_bucket\_name) | bucket name with id |
97+
| <a name="output_dynamodb_table_name"></a> [dynamodb\_table\_name](#output\_dynamodb\_table\_name) | Name of the DynamoDB table that will be used to manage locking and unlocking of the Terraform state file. |
98+
| <a name="output_log_bucket_name"></a> [log\_bucket\_name](#output\_log\_bucket\_name) | Name of the S3 bucket that will be used to store logs for this module. |
99+
| <a name="output_state_bucket_name"></a> [state\_bucket\_name](#output\_state\_bucket\_name) | Specify the region in which an S3 bucket will be created by the module. |
102100
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
103101

104102
## Contribution & Issue Reporting
@@ -107,7 +105,7 @@ To report an issue with a project:
107105

108106
1. Check the repository's [issue tracker](https://github.com/squareops/terraform-aws-tfstate/issues) on GitHub
109107
2. Search to see if the issue has already been reported
110-
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 .
108+
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 .
111109

112110
## License
113111

@@ -139,4 +137,3 @@ We believe that the key to success in the digital age is the ability to deliver
139137
We provide [support](https://squareops.com/contact-us/) on all of our projects, no matter how small or large they may be.
140138

141139
You can find more information about our company on this [squareops.com](https://squareops.com/), follow us on [Linkedin](https://www.linkedin.com/company/squareops-technologies-pvt-ltd/), or fill out a [job application](https://squareops.com/careers/). If you have any questions or would like assistance with your cloud strategy and implementation, please don't hesitate to [contact us](https://squareops.com/contact-us/).
142-

examples/state-storage-backend/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
7-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | 3.50.0 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
7+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9 |
88

99
## Providers
1010

@@ -14,7 +14,7 @@ No providers.
1414

1515
| Name | Source | Version |
1616
|------|--------|---------|
17-
| <a name="module_backend"></a> [backend](#module\_backend) | ../../ | n/a |
17+
| <a name="module_backend"></a> [backend](#module\_backend) | squareops/tfstate/aws | n/a |
1818

1919
## Resources
2020

@@ -28,9 +28,10 @@ No inputs.
2828

2929
| Name | Description |
3030
|------|-------------|
31-
| <a name="output_bucket_region"></a> [bucket\_region](#output\_bucket\_region) | In which region S3 bucket will create |
32-
| <a name="output_dynamodb_table_name"></a> [dynamodb\_table\_name](#output\_dynamodb\_table\_name) | dynamodb table name |
33-
| <a name="output_state_bucket_name"></a> [state\_bucket\_name](#output\_state\_bucket\_name) | bucket name with id |
31+
| <a name="output_bucket_region"></a> [bucket\_region](#output\_bucket\_region) | Specify the region in which an S3 bucket will be created by the module. |
32+
| <a name="output_dynamodb_table_name"></a> [dynamodb\_table\_name](#output\_dynamodb\_table\_name) | Name of the DynamoDB table that will be used to manage locking and unlocking of the Terraform state file. |
33+
| <a name="output_log_bucket_name"></a> [log\_bucket\_name](#output\_log\_bucket\_name) | Name of the S3 bucket that will be used to store logs for this module. |
34+
| <a name="output_state_bucket_name"></a> [state\_bucket\_name](#output\_state\_bucket\_name) | Name of the S3 bucket that will be used to store the Terraform state file. |
3435
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3536
## Our Other Projects
3637

@@ -81,4 +82,3 @@ We believe that the key to success in the digital age is the ability to deliver
8182
We provide [support](https://squareops.com/contact-us/) on all of our projects, no matter how small or large they may be.
8283

8384
You can find more information about our company on this [squareops.com](https://squareops.com/), follow us on [linkdin](https://www.linkedin.com/company/squareops-technologies-pvt-ltd/), or fill out a [job application](https://squareops.com/careers/). If you have any questions or would like assistance with your cloud strategy and implementation, please don't hesitate to [contact us](https://squareops.com/contact-us/).
84-
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
locals {
22
region = "us-east-2"
3-
environment = "dev"
3+
environment = "prod"
4+
additional_tags = {
5+
Owner = "organization_name"
6+
Expires = "Never"
7+
Department = "Engineering"
8+
}
49
}
510

611
module "backend" {
7-
source = "../../"
12+
source = "squareops/tfstate/aws"
13+
logging = true
814
environment = local.environment
915
bucket_name = "production-tfstate-bucket" #unique global s3 bucket name
1016
force_destroy = true
1117
versioning_enabled = true
12-
logging = true
13-
1418
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
output "bucket_region" {
2-
description = "In which region S3 bucket will create"
2+
description = "Specify the region in which an S3 bucket will be created by the module."
33
value = local.region
44
}
55

66
output "state_bucket_name" {
7-
description = "bucket name with id"
7+
description = "Name of the S3 bucket that will be used to store the Terraform state file."
88
value = module.backend.state_bucket_name
99
}
1010

1111
output "dynamodb_table_name" {
12-
description = "dynamodb table name"
12+
description = "Name of the DynamoDB table that will be used to manage locking and unlocking of the Terraform state file."
1313
value = module.backend.dynamodb_table_name
1414
}
15+
16+
output "log_bucket_name" {
17+
description = "Name of the S3 bucket that will be used to store logs for this module."
18+
value = module.backend.log_bucket_name
19+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
provider "aws" {
22
region = local.region
3-
}
3+
default_tags {
4+
tags = local.additional_tags
5+
}
6+
}

examples/state-storage-backend/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ terraform {
77

88
}
99
}
10-
}
10+
}

logging.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,8 @@ resource "aws_iam_role_policy_attachment" "s3_cloudtrail_policy_attachment" {
110110
module "log_bucket" {
111111
count = var.logging ? 1 : 0
112112
source = "terraform-aws-modules/s3-bucket/aws"
113-
version = "3.4.0"
113+
version = "3.10.0"
114114
bucket = format("%s-%s-log-bucket", var.bucket_name, data.aws_caller_identity.current.account_id)
115-
acl = "log-delivery-write"
116115
force_destroy = true
117116
attach_elb_log_delivery_policy = true
118117
attach_lb_log_delivery_policy = true

main.tf

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,13 @@ data "aws_iam_policy_document" "bucket_policy" {
5555
}
5656

5757
module "s3_bucket" {
58-
source = "terraform-aws-modules/s3-bucket/aws"
59-
version = "3.4.0"
60-
61-
bucket = format("%s-%s", var.bucket_name, data.aws_caller_identity.current.account_id)
62-
acl = "private"
63-
force_destroy = var.force_destroy
64-
65-
attach_policy = true
66-
policy = data.aws_iam_policy_document.bucket_policy.json
67-
58+
source = "terraform-aws-modules/s3-bucket/aws"
59+
version = "3.10.0"
60+
bucket = format("%s-%s", var.bucket_name, data.aws_caller_identity.current.account_id)
61+
force_destroy = var.force_destroy
62+
attach_policy = true
63+
policy = data.aws_iam_policy_document.bucket_policy.json
6864
attach_deny_insecure_transport_policy = true
69-
7065
versioning = {
7166
enabled = var.versioning_enabled
7267
}
@@ -92,8 +87,8 @@ module "s3_bucket" {
9287
restrict_public_buckets = true
9388

9489
# S3 Bucket Ownership Controls
95-
control_object_ownership = false
96-
object_ownership = "bucket-owner-full-control"
90+
control_object_ownership = true
91+
object_ownership = "BucketOwnerPreferred"
9792
}
9893

9994
resource "aws_dynamodb_table" "dynamodb_table" {

0 commit comments

Comments
 (0)