-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add the inteligent tiering configuration #166
Conversation
f442a08
to
8a673bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. Could you please try to implement such a feature as close to the rest of the code in this module (no need for a new module, var.intelligent_tiering_config
should be map(any)
or any
, do not use module experiments, defaults(), optional())?
variables.tf
Outdated
@@ -4,6 +4,24 @@ variable "create_bucket" { | |||
default = true | |||
} | |||
|
|||
variable "intelligent_tiering" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this variable to the end of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @antonbabenko. I pushed the suggested changes
e6b4ed2
to
6a1087f
Compare
main.tf
Outdated
@@ -707,3 +712,25 @@ resource "aws_s3_bucket_ownership_controls" "this" { | |||
aws_s3_bucket.this | |||
] | |||
} | |||
|
|||
resource "aws_s3_bucket_intelligent_tiering_configuration" "tiering_conf" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource "aws_s3_bucket_intelligent_tiering_configuration" "tiering_conf" { | |
resource "aws_s3_bucket_intelligent_tiering_configuration" "this" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resource was renamed
main.tf
Outdated
@@ -9,6 +9,11 @@ locals { | |||
grants = try(jsondecode(var.grant), var.grant) | |||
cors_rules = try(jsondecode(var.cors_rule), var.cors_rule) | |||
lifecycle_rules = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule) | |||
intelligent_tiering_config = var.intelligent_tiering_config == null ? null : defaults(var.intelligent_tiering_config, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intelligent_tiering_config = var.intelligent_tiering_config == null ? null : defaults(var.intelligent_tiering_config, { | |
intelligent_tiering_config = try(jsondecode(var.intelligent_tiering_config), var.intelligent_tiering_config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the magic with defaults()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
main.tf
Outdated
@@ -707,3 +712,25 @@ resource "aws_s3_bucket_ownership_controls" "this" { | |||
aws_s3_bucket.this | |||
] | |||
} | |||
|
|||
resource "aws_s3_bucket_intelligent_tiering_configuration" "tiering_conf" { | |||
for_each = local.intelligent_tiering_config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add new line after for_each
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such for_each
should respect the value of local.create_bucket
as in other resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I updated the for_each loop
main.tf
Outdated
bucket = aws_s3_bucket.this[0].id | ||
status = each.value.status | ||
|
||
filter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filter
is optional according to the docs. Same as prefix
and tags
in it. Update the code to use dynamic
. See other resources for examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the config to a dynamic block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can filter
be one or multiple blocks? Now it looks like multiple, but according to the docs it should be zero-or-one? Please update as in other resource (... ? [true] : []
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is in place
main.tf
Outdated
for_each = each.value.tiering | ||
|
||
content { | ||
access_tier = try(tiering.key, null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
access_tier
and days
are required, so there is no need to wrap values with try()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I removed the try()
variables.tf
Outdated
@@ -201,3 +201,22 @@ variable "putin_khuylo" { | |||
type = bool | |||
default = true | |||
} | |||
|
|||
variable "intelligent_tiering_config" { | |||
description = <<EOS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the description as a string (not heredoc), no link to the documentation, and no comments for the type. See line 146, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, the description was updated
variables.tf
Outdated
# days = number | ||
# })) | ||
# })) | ||
default = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default = null | |
default = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is in place
main.tf
Outdated
for_each = local.intelligent_tiering_config | ||
name = each.key | ||
bucket = aws_s3_bucket.this[0].id | ||
status = each.value.status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make status
to accept boolean true
/ false
also. See other resources in this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is in place
914dca8
to
0c7d472
Compare
This issue has been resolved in version 3.3.0 🎉 |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Description
This pull request adds the option of managing the bucket intelligent tiering configuration by passing a map of objects to this module. This map of objects encapsulates the configuration options from this resource: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_intelligent_tiering_configuration
Motivation and Context
Intelligent tiering configuration can optimize the costs of the S3 buckets infrastructure and the changes in this pull request make these configurations available from the module.
Breaking Changes
None
How Has This Been Tested?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request