Skip to content

Commit 618a71b

Browse files
authored
Full support for lifecycle configuration (#135)
1 parent 03a9738 commit 618a71b

File tree

15 files changed

+540
-285
lines changed

15 files changed

+540
-285
lines changed

.github/workflows/auto-context.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
3636
- name: Create Pull Request
3737
if: steps.update.outputs.create_pull_request == 'true'
38-
uses: cloudposse/actions/github/create-pull-request@0.22.0
38+
uses: cloudposse/actions/github/create-pull-request@0.30.0
3939
with:
4040
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
4141
committer: 'cloudpossebot <[email protected]>'

.github/workflows/auto-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
fi
6363
6464
- name: Auto Test
65-
uses: cloudposse/actions/github/repository-dispatch@0.22.0
65+
uses: cloudposse/actions/github/repository-dispatch@0.30.0
6666
# match users by ID because logins (user names) are inconsistent,
6767
# for example in the REST API Renovate Bot is `renovate[bot]` but
6868
# in GraphQL it is just `renovate`, plus there is a non-bot

.github/workflows/chatops.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
steps:
1010
- uses: actions/checkout@v2
1111
- name: "Handle common commands"
12-
uses: cloudposse/actions/github/slash-command-dispatch@0.22.0
12+
uses: cloudposse/actions/github/slash-command-dispatch@0.30.0
1313
with:
1414
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
1515
reaction-token: ${{ secrets.GITHUB_TOKEN }}
@@ -24,7 +24,7 @@ jobs:
2424
- name: "Checkout commit"
2525
uses: actions/checkout@v2
2626
- name: "Run tests"
27-
uses: cloudposse/actions/github/slash-command-dispatch@0.22.0
27+
uses: cloudposse/actions/github/slash-command-dispatch@0.30.0
2828
with:
2929
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
3030
reaction-token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 58 additions & 17 deletions
Large diffs are not rendered by default.

README.yaml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ related:
6666

6767
# Short description of this project
6868
description: |-
69-
This module creates an S3 bucket with support of versioning, replication, encryption, ACL, and bucket object policy.
69+
This module creates an S3 bucket with support for versioning, lifecycles, object locks, replication, encryption, ACL,
70+
bucket object policies, and static website hosting.
71+
7072
If `user_enabled` variable is set to `true`, the module will provision a basic IAM user with permissions to access the bucket.
71-
7273
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
7374
[AWS IAM Instance Profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) and
7475
do not already have IAM credentials. Users or systems that have IAM credentials should either be granted access directly based on
@@ -77,7 +78,7 @@ description: |-
7778
We do not recommend creating IAM users this way for any other purpose.
7879
7980
This module blocks public access to the bucket by default. See `block_public_acls`, `block_public_policy`,
80-
and `ignore_public_acls` to change the settings. See [AWS documentation](https://docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html)
81+
`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)
8182
for more details.
8283
8384
# How to use this project
@@ -100,7 +101,43 @@ usage: |-
100101
}
101102
```
102103
103-
Using [grants](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html) to enable access to another account and for logging.
104+
Configuring S3 [storage lifecycle](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html):
105+
106+
```hcl
107+
locals {
108+
lifecycle_configuration_rules = [{
109+
enabled = true # bool
110+
id = "v2rule"
111+
112+
abort_incomplete_multipart_upload_days = 1 # number
113+
114+
filter_and = null
115+
expiration = {
116+
days = 120 # integer > 0
117+
}
118+
noncurrent_version_expiration = {
119+
newer_noncurrent_versions = 3 # integer > 0
120+
noncurrent_days = 60 # integer >= 0
121+
}
122+
transition = [{
123+
days = 30 # integer >= 0
124+
storage_class = "STANDARD_IA" # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.
125+
},
126+
{
127+
days = 60 # integer >= 0
128+
storage_class = "ONEZONE_IA" # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.
129+
}]
130+
noncurrent_version_transition = [{
131+
newer_noncurrent_versions = 3 # integer >= 0
132+
noncurrent_days = 30 # integer >= 0
133+
storage_class = "ONEZONE_IA" # string/enum, one of GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE, GLACIER_IR.
134+
}]
135+
}]
136+
}
137+
```
138+
139+
Using [grants](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html) to enable access
140+
to another account and for logging, and incorporating the above lifecycle configuration.
104141
105142
```hcl
106143
module "s3_bucket" {
@@ -110,11 +147,13 @@ usage: |-
110147
acl = ""
111148
enabled = true
112149
user_enabled = true
113-
versioning_enabled = false
150+
versioning_enabled = true
114151
allowed_bucket_actions = ["s3:GetObject", "s3:ListBucket", "s3:GetBucketLocation"]
115152
name = "app"
116153
stage = "test"
117154
namespace = "eg"
155+
156+
lifecycle_configuration_rules = local.lifecycle_configuration_rules
118157
119158
grants = [
120159
{
@@ -149,10 +188,12 @@ usage: |-
149188
stage = "test"
150189
namespace = "eg"
151190
152-
privileged_principal_arns = {
191+
privileged_principal_arns = [
192+
{
153193
"arn:aws:iam::123456789012:role/principal1" = ["prefix1/", "prefix2/"]
194+
}, {
154195
"arn:aws:iam::123456789012:role/principal2" = [""]
155-
}
196+
}]
156197
privileged_principal_actions = [
157198
"s3:PutObject",
158199
"s3:PutObjectAcl",

0 commit comments

Comments
 (0)