-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
added recording_mode{} attribute #87
Conversation
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.
Looking good, but I think we should change that type def unless I'm mistaken.
One other thing: We'll need to require the latest provider to support this, so we'll need to change to version = ">= 5.38"
here.
Check out those updates and let me know your thoughts! Once you've got it into a solid spot where it's ready for another review, please do the following locally, adding + committing the result, and push to your branch:
make init
make readme
Thanks!
variables.tf
Outdated
- Continuous | ||
- Daily |
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.
Provider docs seem to uppercase these, so just in case that is an issue..
- Continuous | |
- Daily | |
- CONTINUOUS | |
- DAILY |
variables.tf
Outdated
recording_mode_override = optional(list(object({ | ||
description = string | ||
recording_frequency = string | ||
resource_types = list(string) | ||
}))) |
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.
AFAICT, it seems there can only be one recording_mode_override
block, yeah? Considering that, I'd just make this a single option object like so:
recording_mode_override = optional(list(object({ | |
description = string | |
recording_frequency = string | |
resource_types = list(string) | |
}))) | |
recording_mode_override = optional(object({ | |
description = string | |
recording_frequency = string | |
resource_types = list(string) | |
})) |
This way we don't need to worry about list access and can avoid that data type. Or am I missing something on that?
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 AWS API has a list, which means it is meant for future expansion. Whomever designed the Terraform resource did not realize that and just coded a structure.
We can align to the Terraform resource, knowing that in the future this could be an issue.
variables.tf
Outdated
@@ -144,6 +144,27 @@ variable "managed_rules" { | |||
default = {} | |||
} | |||
|
|||
variable "recording_mode" { | |||
description = <<-DOC | |||
The mode for AWS Config to record configuration changes. Possible values are: |
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.
We could create a validation
block for these values in this variable, but not required.
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.
Adding validation client side means we need to publish new versions as the API changes. My preference is to provide clear examples, optional attributes, and let the APIs do the validation. But, I am open to adding it if you feel it's necessary.
Output post apply:
|
/terratest |
@AdamTylerLynch Tests are failing elsewhere (#86), so we're working on that internally and will circle back once they're fixed 👍 Thanks for the patience! |
/terratest |
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.
LGTM, thank you! There remains a lot of cruft in this module to clean up around testing and examples, but that is beyond the scope of this PR.
- Supersedes and closes Update README.md and docs #86
- Supersedes and closes Optional recording #79
- Supersedes and closes Add Filtering of Recorded ResourceTypes #65
- Supersedes and closes add ability to choose specific resources in config #49
- Supersedes and closes Fix: Allow recorders to define including global resources #36
/terratest |
@AdamTylerLynch Thank you very much for this PR. As you can see, it elegantly resolved a number of piecemeal attempts at adding this feature and complaints about missing support. @Gowiem Thank you for all your help. Your guidance was excellent, so by the time I got to look at this PR, all my concerns about the original PR had been addressed. FYI, regarding list vs. not a list inputs, this is a complex issue about which I'm going to write a more detailed article. As a general rule, if the Terraform resource block is documented in the Terraform resource to be a list (see, for example, aws_route_table.route), we model it as a list, even if it is documented as a list of max length 1. If it is documented as an optional block, as here with Now if the variable in question is involved with determining the number of resources to create, a number which must be known at plan time, we always use a list or map. But in this case where, even if the API is documented as a list, the Terraform resource is not documented as being a block list, we leave it an object. Regarding validation blocks, we typically use them as enhanced documentation for the case where the input type does not match the resource attribute type. The primary case being these variables that control the number of resources. We may take an optional value as a list of length zero or one, even though the resource takes a plain value, so there we add a validation rejecting lists longer than length one and explaining the situation. Other situation for custom validation are where there is some value (typically one or more of a set of I agree with @AdamTylerLynch that duplicating validation done by the API adds maintenance burden and slows the adoption of new features without providing enough benefit to be worth it. |
what
Added recording_mode block.
Requesting maintainer guidance on properly defining the inputs as a practitioner would expect. The way it is defined now feels odd, requiring a variable assignment and then a list for recording_mode_override.
Example:
why
This feature allows for cost optimization. Adds the ability to leverage Periodic recording VS continious.
references