Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feature(config): manage AWS Config Remediation Configuration #9348
feature(config): manage AWS Config Remediation Configuration #9348
Changes from all commits
3b7a126
9ce9044
bad9ae8
70be653
d55268f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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've separated the resource and schema functions into their own package,
github.com/hashicorp/terraform-plugin-sdk/helper/*
. Please update to use those packages.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.
It would be good to have a check here that would return an error if neither
resource_value
norstatic_value
is set. You could usegithub.aaakk.us.kg/hashicorp/go-multierror
to collect all errors instead of returning on the first.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.
Does
Value
need to be set toconfigservice.ResourceValueTypeResourceId
?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.
This could be inlined, something like
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.
This could be inlined, something like
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.
This check could be moved to the top and test
len(c) > 0
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 prefer that the resource schema function (i.e.
resourceAwsConfigRemediationConfiguration()
) is at the top of the fileThere 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 remediation configuration has an ARN returned by the AWS API that can be used to uniquely identify it. We should have a
Computed
attribute calledarn
that is set to that valueThere 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 prefer named constants for timeout values
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're updating our error messages to use the Go 1.13 error wrapping verb
%w
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've started adding one last try after
resource.Retry()
in case of a timeout.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 ID should be set to the ARN value, since that uniquely identifies it
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.
This is a really tough one -- https://godoc.org/github.com/aws/aws-sdk-go/service/configservice#PutRemediationConfigurationsOutput doesn't return the ARN. We could use "describe" to get the arn, but it could return multiple configurations, and we'd have to make some assumptions to get a single arn.
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 call to
len()
can be inlined in the checkThere 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.
This appears like it could have been a previous iteration of the schema. We'd expect to see
d.Set()
calls like the below with the current schema so Terraform can appropriately save each of the attributes into the Terraform state to perform drift detection and support import: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.
I'll have to put this error handling code in the
flattenRemediationConfigurations
, then, as this code handles lists ofRemediationConfiguration
objects.Unless you mean I have to handle
RemediationConfiguration
one by one?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 more I read this specific review, my code, and AWS documentation (website and
man
), the more I feel like there is something to clarify before getting forward :Remediation Configuration
objects can only be identified by their correspondingConfig Rule
, which makes sense as they dannot exist without aConfig Rule
on top of them.aws
CLI comand reflects that fact :Which appears the same way in the GO API this provider is using to communicate with AWS, if I understood correctly.
At this point I'm not sure I wrote a code that matches these behaviors : maybe it would be best to only handle lists of Remediation Configuraion objects, be it when reading or writing them, instead of allowing to write a single
Remediation Configuration
object outside of any kind of collection.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.
When creating resources that depend on other resources, we tend to separate them out when the dependent resource has its own APIs. This lets them be managed separately, for example if different teams define the config rules and the remediation actions they could be defined in separate Terraform configurations