Skip to content

Commit ba692ef

Browse files
lafareraknysh
authored andcommitted
Configure bucket public access setting (#13)
* Configure bucket public access setting * Run terraform fmt and regenerate README.md
1 parent 861f07c commit ba692ef

File tree

4 files changed

+46
-10
lines changed

4 files changed

+46
-10
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ __NOTE:__ This module cannot be used to apply changes to the `mfa_delete` featur
2626

2727
---
2828

29-
This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
29+
This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
3030
[<img align="right" title="Share via Email" src="https://docs.cloudposse.com/images/ionicons/ios-email-outline-2.0.1-16x16-999999.svg"/>][share_email]
3131
[<img align="right" title="Share on Google+" src="https://docs.cloudposse.com/images/ionicons/social-googleplus-outline-2.0.1-16x16-999999.svg" />][share_googleplus]
3232
[<img align="right" title="Share on Facebook" src="https://docs.cloudposse.com/images/ionicons/social-facebook-outline-2.0.1-16x16-999999.svg" />][share_facebook]
@@ -47,7 +47,7 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE).
4747

4848

4949

50-
We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out!
50+
We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out!
5151

5252

5353

@@ -124,17 +124,21 @@ Available targets:
124124
| acl | The canned ACL to apply to the S3 bucket | string | `private` | no |
125125
| additional_tag_map | Additional tags for appending to each tag map | map | `<map>` | no |
126126
| attributes | Additional attributes (e.g. `state`) | list | `<list>` | no |
127+
| block_public_acls | Whether Amazon S3 should block public ACLs for this bucket. | string | `false` | no |
128+
| block_public_policy | Whether Amazon S3 should block public bucket policies for this bucket. | string | `false` | no |
127129
| context | Default context to use for passing state between label invocations | map | `<map>` | no |
128130
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `-` | no |
129131
| enable_server_side_encryption | Enable DynamoDB server-side encryption | string | `true` | no |
130132
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `` | no |
131133
| force_destroy | A boolean that indicates the S3 bucket can be destroyed even if it contains objects. These objects are not recoverable | string | `false` | no |
134+
| ignore_public_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | string | `false` | no |
132135
| label_order | The naming order of the id output and Name tag | list | `<list>` | no |
133136
| mfa_delete | A boolean that indicates that versions of S3 objects can only be deleted with MFA. ( Terraform cannot apply changes of this value; https://github.com/terraform-providers/terraform-provider-aws/issues/629 ) | string | `false` | no |
134137
| name | Solution name, e.g. 'app' or 'jenkins' | string | `terraform` | no |
135138
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | `` | no |
136139
| read_capacity | DynamoDB read capacity units | string | `5` | no |
137140
| region | AWS Region the S3 bucket should reside in | string | - | yes |
141+
| restrict_public_buckets | Whether Amazon S3 should restrict public bucket policies for this bucket. | string | `false` | no |
138142
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | string | `` | no |
139143
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map | `<map>` | no |
140144
| write_capacity | DynamoDB write capacity units | string | `5` | no |
@@ -153,9 +157,9 @@ Available targets:
153157

154158

155159

156-
## Share the Love
160+
## Share the Love
157161

158-
Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/terraform-aws-tfstate-backend)! (it helps us **a lot**)
162+
Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/terraform-aws-tfstate-backend)! (it helps us **a lot**)
159163

160164
Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =)
161165

@@ -179,9 +183,9 @@ File a GitHub [issue](https://github.com/cloudposse/terraform-aws-tfstate-backen
179183

180184
## Commercial Support
181185

182-
Work directly with our team of DevOps experts via email, slack, and video conferencing.
186+
Work directly with our team of DevOps experts via email, slack, and video conferencing.
183187

184-
We provide [*commercial support*][commercial_support] for all of our [Open Source][github] projects. As a *Dedicated Support* customer, you have access to our team of subject matter experts at a fraction of the cost of a full-time engineer.
188+
We provide [*commercial support*][commercial_support] for all of our [Open Source][github] projects. As a *Dedicated Support* customer, you have access to our team of subject matter experts at a fraction of the cost of a full-time engineer.
185189

186190
[![E-Mail](https://img.shields.io/badge/[email protected])][email]
187191

@@ -191,7 +195,7 @@ We provide [*commercial support*][commercial_support] for all of our [Open Sourc
191195
- **Bug Fixes.** We'll rapidly work to fix any bugs in our projects.
192196
- **Build New Terraform Modules.** We'll [develop original modules][module_development] to provision infrastructure.
193197
- **Cloud Architecture.** We'll assist with your cloud strategy and design.
194-
- **Implementation.** We'll provide hands-on support to implement our reference architectures.
198+
- **Implementation.** We'll provide hands-on support to implement our reference architectures.
195199

196200

197201

@@ -206,7 +210,7 @@ Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Ou
206210

207211
## Newsletter
208212

209-
Signup for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
213+
Signup for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
210214

211215
## Contributing
212216

@@ -235,9 +239,9 @@ Copyright © 2017-2019 [Cloud Posse, LLC](https://cpco.io/copyright)
235239

236240

237241

238-
## License
242+
## License
239243

240-
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
244+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
241245

242246
See [LICENSE](LICENSE) for full details.
243247

docs/terraform.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@
55
| acl | The canned ACL to apply to the S3 bucket | string | `private` | no |
66
| additional_tag_map | Additional tags for appending to each tag map | map | `<map>` | no |
77
| attributes | Additional attributes (e.g. `state`) | list | `<list>` | no |
8+
| block_public_acls | Whether Amazon S3 should block public ACLs for this bucket. | string | `false` | no |
9+
| block_public_policy | Whether Amazon S3 should block public bucket policies for this bucket. | string | `false` | no |
810
| context | Default context to use for passing state between label invocations | map | `<map>` | no |
911
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | string | `-` | no |
1012
| enable_server_side_encryption | Enable DynamoDB server-side encryption | string | `true` | no |
1113
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | string | `` | no |
1214
| force_destroy | A boolean that indicates the S3 bucket can be destroyed even if it contains objects. These objects are not recoverable | string | `false` | no |
15+
| ignore_public_acls | Whether Amazon S3 should ignore public ACLs for this bucket. | string | `false` | no |
1316
| label_order | The naming order of the id output and Name tag | list | `<list>` | no |
1417
| mfa_delete | A boolean that indicates that versions of S3 objects can only be deleted with MFA. ( Terraform cannot apply changes of this value; https://github.com/terraform-providers/terraform-provider-aws/issues/629 ) | string | `false` | no |
1518
| name | Solution name, e.g. 'app' or 'jenkins' | string | `terraform` | no |
1619
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | string | `` | no |
1720
| read_capacity | DynamoDB read capacity units | string | `5` | no |
1821
| region | AWS Region the S3 bucket should reside in | string | - | yes |
22+
| restrict_public_buckets | Whether Amazon S3 should restrict public bucket policies for this bucket. | string | `false` | no |
1923
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | string | `` | no |
2024
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map | `<map>` | no |
2125
| write_capacity | DynamoDB write capacity units | string | `5` | no |

main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ resource "aws_s3_bucket" "default" {
3939
tags = "${module.s3_bucket_label.tags}"
4040
}
4141

42+
resource "aws_s3_bucket_public_access_block" "default" {
43+
bucket = "${aws_s3_bucket.default.id}"
44+
block_public_acls = "${var.block_public_acls}"
45+
ignore_public_acls = "${var.ignore_public_acls}"
46+
block_public_policy = "${var.block_public_policy}"
47+
restrict_public_buckets = "${var.restrict_public_buckets}"
48+
}
49+
4250
module "dynamodb_table_label" {
4351
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.5.3"
4452
context = "${module.base_label.context}"

variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,23 @@ variable "enable_server_side_encryption" {
9393
description = "Enable DynamoDB server-side encryption"
9494
default = "true"
9595
}
96+
97+
variable "block_public_acls" {
98+
description = "Whether Amazon S3 should block public ACLs for this bucket."
99+
default = false
100+
}
101+
102+
variable "ignore_public_acls" {
103+
description = "Whether Amazon S3 should ignore public ACLs for this bucket."
104+
default = false
105+
}
106+
107+
variable "block_public_policy" {
108+
description = "Whether Amazon S3 should block public bucket policies for this bucket."
109+
default = false
110+
}
111+
112+
variable "restrict_public_buckets" {
113+
description = "Whether Amazon S3 should restrict public bucket policies for this bucket."
114+
default = false
115+
}

0 commit comments

Comments
 (0)