Skip to content

Commit 760c346

Browse files
authored
Deprecation Notice, Terraform Provider v5 Support (#93)
1 parent dd8b6e6 commit 760c346

File tree

12 files changed

+731
-70
lines changed

12 files changed

+731
-70
lines changed

.github/renovate.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"extends": [
33
"config:base",
4-
":preserveSemverRanges"
4+
":preserveSemverRanges",
5+
":rebaseStalePrs"
56
],
6-
"baseBranches": ["main", "master", "/^release\\/v\\d{1,2}$/"],
7+
"baseBranches": ["main"],
78
"labels": ["auto-update"],
89
"dependencyDashboardAutoclose": true,
910
"enabledManagers": ["terraform"],
1011
"terraform": {
11-
"ignorePaths": ["**/context.tf", "examples/**"]
12+
"ignorePaths": ["**/context.tf"]
1213
}
1314
}

.github/workflows/release-branch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- 'docs/**'
1111
- 'examples/**'
1212
- 'test/**'
13+
- 'README.*'
1314

1415
permissions:
1516
contents: write

.github/workflows/release-published.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ permissions:
1111

1212
jobs:
1313
terraform-module:
14-
uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release.yml@main
14+
uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release-published.yml@main

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
<!-- markdownlint-disable -->
3-
# terraform-aws-s3-website [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-s3-website.svg)](https://github.com/cloudposse/terraform-aws-s3-website/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
3+
# ~~terraform-aws-s3-website~~ OBSOLETE
4+
5+
[![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-s3-website.svg)](https://github.com/cloudposse/terraform-aws-s3-website/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
46
<!-- markdownlint-restore -->
57

68
[![README Header][readme_header_img]][readme_header_link]
@@ -28,6 +30,16 @@
2830
2931
-->
3032

33+
34+
## Deprecated
35+
36+
**As of July, 2023 this module is deprecated.** `terraform-aws-s3-website` offers little value beyond [
37+
the `terraform-aws-s3-bucket` module](https://github.com/cloudposse/terraform-aws-s3-bucket),
38+
so Cloud Posse is phasing out support for this project. Users are advised to migrate to
39+
[terraform-aws-s3-bucket](https://github.com/cloudposse/terraform-aws-s3-bucket) to manage the S3 bucket
40+
(including logging) and [terraform-aws-route53-alias](https://github.com/cloudposse/terraform-aws-route53-alias)
41+
to register the website hostname in Route53. Feature requests should be directed to those modules.
42+
3143
Terraform module to provision S3-backed Websites.
3244
**IMPORTANT:** This module provisions a globally accessible S3 bucket for unauthenticated users because it is designed for hosting public static websites. Normally, AWS recommends that S3 buckets should not publicly accessible in order to protect S3 data from unauthorized users.
3345

@@ -89,10 +101,6 @@ We highly recommend that in your code you pin the version to the exact version y
89101
using so that your infrastructure remains stable, and update versions in a
90102
systematic way so that they do not catch you by surprise.
91103

92-
Also, because of a bug in the Terraform registry ([hashicorp/terraform#21417](https://github.com/hashicorp/terraform/issues/21417)),
93-
the registry shows many of our inputs as required when in fact they are optional.
94-
The table below correctly indicates which inputs are required.
95-
96104

97105
#### Create s3 website bucket
98106

@@ -153,31 +161,33 @@ Available targets:
153161

154162
| Name | Version |
155163
|------|---------|
156-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
157-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0, < 4.0.0 |
164+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
165+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9 |
158166
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.2 |
159167

160168
## Providers
161169

162170
| Name | Version |
163171
|------|---------|
164-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0, < 4.0.0 |
172+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9 |
165173

166174
## Modules
167175

168176
| Name | Source | Version |
169177
|------|--------|---------|
170178
| <a name="module_default_label"></a> [default\_label](#module\_default\_label) | cloudposse/label/null | 0.25.0 |
171179
| <a name="module_dns"></a> [dns](#module\_dns) | cloudposse/route53-alias/aws | 0.13.0 |
172-
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 0.20.0 |
180+
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 1.4.2 |
173181
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
174182

175183
## Resources
176184

177185
| Name | Type |
178186
|------|------|
179187
| [aws_s3_bucket.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
188+
| [aws_s3_bucket_ownership_controls.s3_bucket_ownership_controls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
180189
| [aws_s3_bucket_policy.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
190+
| [aws_s3_bucket_public_access_block.s3_allow_public_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
181191
| [aws_iam_policy_document.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
182192
| [aws_iam_policy_document.deployment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
183193
| [aws_iam_policy_document.replication](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
@@ -440,11 +450,11 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
440450
[readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-s3-website&utm_content=readme_footer_link
441451
[readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img
442452
[readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-s3-website&utm_content=readme_commercial_support_link
443-
[share_twitter]: https://twitter.com/intent/tweet/?text=terraform-aws-s3-website&url=https://github.com/cloudposse/terraform-aws-s3-website
444-
[share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=terraform-aws-s3-website&url=https://github.com/cloudposse/terraform-aws-s3-website
453+
[share_twitter]: https://twitter.com/intent/tweet/?text=~~terraform-aws-s3-website~~+OBSOLETE&url=https://github.com/cloudposse/terraform-aws-s3-website
454+
[share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=~~terraform-aws-s3-website~~+OBSOLETE&url=https://github.com/cloudposse/terraform-aws-s3-website
445455
[share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/terraform-aws-s3-website
446456
[share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/terraform-aws-s3-website
447457
[share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-s3-website
448-
[share_email]: mailto:?subject=terraform-aws-s3-website&body=https://github.com/cloudposse/terraform-aws-s3-website
458+
[share_email]: mailto:?subject=~~terraform-aws-s3-website~~+OBSOLETE&body=https://github.com/cloudposse/terraform-aws-s3-website
449459
[beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-s3-website?pixel&cs=github&cm=readme&an=terraform-aws-s3-website
450460
<!-- markdownlint-restore -->

README.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
# Name of this project
7-
name: terraform-aws-s3-website
7+
name: ~~terraform-aws-s3-website~~ OBSOLETE
88
# Tags of this project
99
tags:
1010
- aws
@@ -50,6 +50,16 @@ related:
5050
url: "https://github.com/cloudposse/terraform-aws-lb-s3-bucket"
5151
# Short description of this project
5252
description: |-
53+
54+
## Deprecated
55+
56+
**As of July, 2023 this module is deprecated.** `terraform-aws-s3-website` offers little value beyond [
57+
the `terraform-aws-s3-bucket` module](https://github.com/cloudposse/terraform-aws-s3-bucket),
58+
so Cloud Posse is phasing out support for this project. Users are advised to migrate to
59+
[terraform-aws-s3-bucket](https://github.com/cloudposse/terraform-aws-s3-bucket) to manage the S3 bucket
60+
(including logging) and [terraform-aws-route53-alias](https://github.com/cloudposse/terraform-aws-route53-alias)
61+
to register the website hostname in Route53. Feature requests should be directed to those modules.
62+
5363
Terraform module to provision S3-backed Websites.
5464
**IMPORTANT:** This module provisions a globally accessible S3 bucket for unauthenticated users because it is designed for hosting public static websites. Normally, AWS recommends that S3 buckets should not publicly accessible in order to protect S3 data from unauthorized users.
5565
# How to use this project

docs/terraform.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
7-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0, < 4.0.0 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
7+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9 |
88
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.2 |
99

1010
## Providers
1111

1212
| Name | Version |
1313
|------|---------|
14-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.0, < 4.0.0 |
14+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9 |
1515

1616
## Modules
1717

1818
| Name | Source | Version |
1919
|------|--------|---------|
2020
| <a name="module_default_label"></a> [default\_label](#module\_default\_label) | cloudposse/label/null | 0.25.0 |
2121
| <a name="module_dns"></a> [dns](#module\_dns) | cloudposse/route53-alias/aws | 0.13.0 |
22-
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 0.20.0 |
22+
| <a name="module_logs"></a> [logs](#module\_logs) | cloudposse/s3-log-storage/aws | 1.4.2 |
2323
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
2424

2525
## Resources
2626

2727
| Name | Type |
2828
|------|------|
2929
| [aws_s3_bucket.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
30+
| [aws_s3_bucket_ownership_controls.s3_bucket_ownership_controls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
3031
| [aws_s3_bucket_policy.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
32+
| [aws_s3_bucket_public_access_block.s3_allow_public_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
3133
| [aws_iam_policy_document.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
3234
| [aws_iam_policy_document.deployment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
3335
| [aws_iam_policy_document.replication](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

examples/complete/versions.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_version = ">= 1.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 5.0"
8+
}
9+
local = {
10+
source = "hashicorp/local"
11+
version = ">= 1.2"
12+
}
13+
}
14+
}

main.tf

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
22
enabled = module.this.enabled
3-
bucket_arn = "arn:${data.aws_partition.current.partition}:s3:::${join("", aws_s3_bucket.default.*.id)}"
3+
bucket_arn = "arn:${data.aws_partition.current.partition}:s3:::${join("", aws_s3_bucket.default[*].id)}"
44

55
website_config = {
66
redirect_all = [
@@ -19,10 +19,12 @@ locals {
1919
}
2020

2121
module "logs" {
22-
source = "cloudposse/s3-log-storage/aws"
23-
version = "0.20.0"
22+
source = "cloudposse/s3-log-storage/aws"
23+
version = "1.4.2"
24+
25+
enabled = local.enabled && var.logs_enabled
26+
2427
attributes = ["logs"]
25-
enabled = local.enabled && var.logs_enabled
2628
standard_transition_days = var.logs_standard_transition_days
2729
glacier_transition_days = var.logs_glacier_transition_days
2830
expiration_days = var.logs_expiration_days
@@ -38,13 +40,36 @@ module "default_label" {
3840
context = module.this.context
3941
}
4042

43+
resource "aws_s3_bucket_public_access_block" "s3_allow_public_access" {
44+
count = local.enabled ? 1 : 0
45+
46+
# The bucket used for a public static website.
47+
#bridgecrew:skip=BC_AWS_S3_19:Skipping `Ensure S3 bucket has block public ACLS enabled`
48+
#bridgecrew:skip=BC_AWS_S3_20:Skipping `Ensure S3 Bucket BlockPublicPolicy is set to True`
49+
#bridgecrew:skip=BC_AWS_S3_21:Skipping `Ensure S3 bucket IgnorePublicAcls is set to True`
50+
#bridgecrew:skip=BC_AWS_S3_22:Skipping `Ensure S3 bucket RestrictPublicBucket is set to True`
51+
bucket = aws_s3_bucket.default[0].id
52+
53+
block_public_acls = false
54+
block_public_policy = false
55+
ignore_public_acls = false
56+
restrict_public_buckets = false
57+
}
58+
59+
resource "aws_s3_bucket_ownership_controls" "s3_bucket_ownership_controls" {
60+
count = local.enabled ? 1 : 0
61+
62+
bucket = aws_s3_bucket.default[0].id
63+
rule {
64+
object_ownership = "BucketOwnerEnforced"
65+
}
66+
}
67+
4168
resource "aws_s3_bucket" "default" {
4269
count = local.enabled ? 1 : 0
4370

44-
#bridgecrew:skip=BC_AWS_S3_1:The bucket used for a public static website. (https://docs.bridgecrew.io/docs/s3_1-acl-read-permissions-everyone)
4571
#bridgecrew:skip=BC_AWS_S3_14:Skipping `Ensure all data stored in the S3 bucket is securely encrypted at rest` check until bridgecrew will support dynamic blocks (https://github.com/bridgecrewio/checkov/issues/776).
4672
#bridgecrew:skip=CKV_AWS_52:Skipping `Ensure S3 bucket has MFA delete enabled` due to issue using `mfa_delete` by terraform (https://github.com/hashicorp/terraform-provider-aws/issues/629).
47-
acl = "public-read"
4873
bucket = var.hostname
4974
tags = module.default_label.tags
5075
force_destroy = var.force_destroy
@@ -115,6 +140,8 @@ resource "aws_s3_bucket_policy" "default" {
115140

116141
bucket = aws_s3_bucket.default[0].id
117142
policy = data.aws_iam_policy_document.default[0].json
143+
144+
depends_on = [aws_s3_bucket_public_access_block.s3_allow_public_access[0]]
118145
}
119146

120147
data "aws_iam_policy_document" "default" {
@@ -155,7 +182,7 @@ data "aws_iam_policy_document" "default" {
155182

156183
# Support replication ARNs
157184
dynamic "statement" {
158-
for_each = flatten(data.aws_iam_policy_document.replication.*.statement)
185+
for_each = flatten(data.aws_iam_policy_document.replication[*].statement)
159186
content {
160187
actions = lookup(statement.value, "actions", null)
161188
effect = lookup(statement.value, "effect", null)
@@ -193,7 +220,7 @@ data "aws_iam_policy_document" "default" {
193220

194221
# Support deployment ARNs
195222
dynamic "statement" {
196-
for_each = flatten(data.aws_iam_policy_document.deployment.*.statement)
223+
for_each = flatten(data.aws_iam_policy_document.deployment[*].statement)
197224
content {
198225
actions = lookup(statement.value, "actions", null)
199226
effect = lookup(statement.value, "effect", null)
@@ -287,8 +314,8 @@ module "dns" {
287314
aliases = compact([signum(length(var.parent_zone_id)) == 1 || signum(length(var.parent_zone_name)) == 1 ? var.hostname : ""])
288315
parent_zone_id = var.parent_zone_id
289316
parent_zone_name = var.parent_zone_name
290-
target_dns_name = join("", aws_s3_bucket.default.*.website_domain)
291-
target_zone_id = join("", aws_s3_bucket.default.*.hosted_zone_id)
317+
target_dns_name = join("", aws_s3_bucket.default[*].website_domain)
318+
target_zone_id = join("", aws_s3_bucket.default[*].hosted_zone_id)
292319

293320
context = module.this.context
294321
}

outputs.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@ output "hostname" {
44
}
55

66
output "s3_bucket_name" {
7-
value = join("", aws_s3_bucket.default.*.id)
7+
value = join("", aws_s3_bucket.default[*].id)
88
description = "DNS record of the website bucket"
99
}
1010

1111
output "s3_bucket_domain_name" {
12-
value = join("", aws_s3_bucket.default.*.bucket_domain_name)
12+
value = join("", aws_s3_bucket.default[*].bucket_domain_name)
1313
description = "Name of the website bucket"
1414
}
1515

1616
output "s3_bucket_arn" {
17-
value = join("", aws_s3_bucket.default.*.arn)
17+
value = join("", aws_s3_bucket.default[*].arn)
1818
description = "ARN identifier of the website bucket"
1919
}
2020

2121
output "s3_bucket_website_endpoint" {
22-
value = join("", aws_s3_bucket.default.*.website_endpoint)
22+
value = join("", aws_s3_bucket.default[*].website_endpoint)
2323
description = "The website endpoint URL"
2424
}
2525

2626
output "s3_bucket_website_domain" {
27-
value = join("", aws_s3_bucket.default.*.website_domain)
27+
value = join("", aws_s3_bucket.default[*].website_domain)
2828
description = "The domain of the website endpoint"
2929
}
3030

3131
output "s3_bucket_hosted_zone_id" {
32-
value = join("", aws_s3_bucket.default.*.hosted_zone_id)
32+
value = join("", aws_s3_bucket.default[*].hosted_zone_id)
3333
description = "The Route 53 Hosted Zone ID for this bucket's region"
3434
}

test/src/go.mod

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
module github.com/cloudposse/terraform-aws-s3-website
22

3-
go 1.13
3+
go 1.20
44

55
require (
6-
github.com/aws/aws-sdk-go v1.34.6 // indirect
6+
github.com/gruntwork-io/terratest v0.34.7
7+
github.com/stretchr/testify v1.6.1
8+
)
9+
10+
require (
11+
github.com/agext/levenshtein v1.2.1 // indirect
12+
github.com/apparentlymart/go-textseg v1.0.0 // indirect
13+
github.com/apparentlymart/go-textseg/v12 v12.0.0 // indirect
714
github.com/davecgh/go-spew v1.1.1 // indirect
8-
github.com/google/uuid v1.1.1 // indirect
9-
github.com/gruntwork-io/terratest v0.16.0
10-
github.com/pquerna/otp v1.2.0 // indirect
11-
github.com/stretchr/testify v1.5.1
12-
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f // indirect
13-
golang.org/x/sys v0.0.0-20190527104216-9cd6430ef91e // indirect
15+
github.com/hashicorp/errwrap v1.0.0 // indirect
16+
github.com/hashicorp/go-multierror v1.1.0 // indirect
17+
github.com/hashicorp/hcl/v2 v2.8.2 // indirect
18+
github.com/hashicorp/terraform-json v0.9.0 // indirect
19+
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
20+
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
21+
github.com/pmezard/go-difflib v1.0.0 // indirect
22+
github.com/zclconf/go-cty v1.2.1 // indirect
23+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
24+
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
25+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect
26+
golang.org/x/text v0.3.3 // indirect
27+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
1428
)

0 commit comments

Comments
 (0)