You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.yaml
+26-50Lines changed: 26 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -69,31 +69,42 @@ description: |-
69
69
This module creates an S3 bucket with support for versioning, lifecycles, object locks, replication, encryption, ACL,
70
70
bucket object policies, and static website hosting.
71
71
72
-
If `user_enabled` variable is set to `true`, the module will provision a basic IAM user with permissions to access the bucket.
73
-
This basic IAM system user is suitable for CI/CD systems (_e.g._ TravisCI, CircleCI) or systems which are *external* to AWS that cannot leverage
74
-
[AWS IAM Instance Profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html)
75
-
or [AWS OIDC](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html) to authenticate and
76
-
do not already have IAM credentials. Users or systems that have IAM credentials should either be granted access directly based on
77
-
their IAM identity via `privileged_principal_arns` or be allowed to assume an IAM role with access.
78
-
79
-
We do not recommend creating IAM users this way for any other purpose.
80
-
72
+
For backward compatibility, it sets the S3 bucket ACL to `private` and the `s3_object_ownership`
73
+
to `ObjectWriter`. Moving forward, setting `s3_object_ownership` to `BucketOwnerEnforced` is recommended,
74
+
and doing so automatically disables the ACL.
75
+
81
76
This module blocks public access to the bucket by default. See `block_public_acls`, `block_public_policy`,
82
77
`ignore_public_acls`, and `restrict_public_buckets` to change the settings. See [AWS documentation](https://docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html)
83
-
for more details.
78
+
for more details.
79
+
80
+
This module can optionally create an IAM User with access to the S3 bucket. This is inherently insecure in that
81
+
to enable anyone to become the User, access keys must be generated, and anything generated by Terraform is stored
82
+
unencrypted in the Terraform state. See the [Terraform documentation](https://www.terraform.io/docs/state/sensitive-data.html) for more details
83
+
84
+
The best way to grant access to the bucket is to grant one or more IAM Roles access to the bucket via `privileged_principal_arns`.
85
+
This IAM Role can be assumed by EC2 instances via their Instance Profile, or Kubernetes (EKS) services using
Entities outside of AWS can assume the Role via [OIDC](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html).
88
+
(See [this example of connecting GitHub](https://aws.amazon.com/blogs/security/use-iam-roles-to-connect-github-actions-to-actions-in-aws/)
89
+
to enable GitHub actions to assume AWS IAM roles, or use [this Cloud Posse component](https://github.com/cloudposse/terraform-aws-components/tree/main/modules/github-oidc-provider)
90
+
if you are already using the Cloud Posse reference architecture.)
91
+
92
+
If neither of those approaches work, then as a last resort you can set `user_enabled = true` and
93
+
this module will provision a basic IAM user with permissions to access the bucket.
94
+
We do not recommend creating IAM users this way for any other purpose.
84
95
85
96
If an IAM user is created, the IAM user name is constructed using [terraform-null-label](https://github.com/cloudposse/terraform-null-label)
86
97
and some input is required. The simplest input is `name`. By default the name will be converted to lower case
87
98
and all non-alphanumeric characters except for hyphen will be removed. See the documentation for `terraform-null-label`
88
99
to learn how to override these defaults if desired.
89
100
90
101
If an AWS Access Key is created, it is stored either in SSM Parameter Store or is provided as a module output,
91
-
but not both. Using SSM Parameter Store is recommended because module outputs are stored in plaintext in
92
-
the Terraform state file.
102
+
but not both. Using SSM Parameter Store is recommended because that will keep the secret from being easily accessible
103
+
via Terraform remote state lookup, but the key will still be stored unencrypted in the Terraform state in any case.
93
104
94
105
# How to use this project
95
106
usage: |-
96
-
Using a [canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html).
107
+
Using [BucketOwnerEnforced](https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html#object-ownership-overview)
97
108
98
109
```hcl
99
110
module "s3_bucket" {
@@ -104,7 +115,7 @@ usage: |-
104
115
stage = "test"
105
116
namespace = "eg"
106
117
107
-
acl= "private"
118
+
s3_object_ownership = "BucketOwnerEnforced"
108
119
enabled = true
109
120
user_enabled = false
110
121
versioning_enabled = false
@@ -156,41 +167,6 @@ usage: |-
156
167
}
157
168
```
158
169
159
-
Using [grants](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html) to enable access
160
-
to another account and for logging, and incorporating the above lifecycle configuration.
161
-
162
-
```hcl
163
-
module "s3_bucket" {
164
-
source = "cloudposse/s3-bucket/aws"
165
-
# Cloud Posse recommends pinning every module to a specific version
0 commit comments