-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add s3_backup_mode option in Firehose Redshift destination #1830
Add s3_backup_mode option in Firehose Redshift destination #1830
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.
Hi @ApsOps
thanks for the PR.
Do you mind adding an acceptance test or modifying an existing one to make use of this new field?
The test would normally go under https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_kinesis_firehose_delivery_stream_test.go
Let me know if you need any help in that context.
b32ed22
to
db51754
Compare
db51754
to
dba6601
Compare
@radeksimko Added the acceptance tests. These are passing for me. Thanks a lot for helping out with this! |
@@ -41,6 +41,59 @@ func cloudWatchLoggingOptionsSchema() *schema.Schema { | |||
} | |||
} | |||
|
|||
func S3BackupConfigurationSchema() *schema.Schema { | |||
return &schema.Schema{ | |||
Type: schema.TypeSet, |
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.
@radeksimko I have a doubt here. When do we use TypeSet
vs TypeList
?
I see S3ConfigurationSchema
has TypeList
with MaxItems: 1
. Is this significant only during type assertion?
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.
Set is used when order doesn't matter, list is used in all other cases and typically with MaxItems: 1
for easier referencing as we can predict the index, i.e. field_name.0.nested_field
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.
In other words it would be better to use TypeList
here.
Can't we call this s3ConfigurationSchema
and use it in "s3_configuration"
too to reduce the repetition a bit?
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't we call this s3ConfigurationSchema and use it in "s3_configuration" too to reduce the repetition a bit?
That's what I was going for and noticed that the schemaTypes are different.
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.
Set is used when order doesn't matter
@radeksimko Just curious. Why do we use TypeList
here then? The order doesn't matter here, right?
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.
Correct, it doesn't, but also there's really nothing to order 😃 as we only ever have a single item in the list and TypeList
makes it more convenient for referencing purposes, i.e. field_name.0.nested_field
instead of field_name.<computed-index>.nested_field
.
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 adding the test (it's also passing for me), this is starting to look pretty good. I left you a few more comments which are mostly nitpicks, the PR looks otherwise good.
Let me know if you need any further clarification for any of my comments.
@@ -41,6 +41,59 @@ func cloudWatchLoggingOptionsSchema() *schema.Schema { | |||
} | |||
} | |||
|
|||
func S3BackupConfigurationSchema() *schema.Schema { | |||
return &schema.Schema{ | |||
Type: schema.TypeSet, |
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.
Set is used when order doesn't matter, list is used in all other cases and typically with MaxItems: 1
for easier referencing as we can predict the index, i.e. field_name.0.nested_field
@@ -467,6 +536,34 @@ func createS3Config(d *schema.ResourceData) *firehose.S3DestinationConfiguration | |||
return configuration | |||
} | |||
|
|||
func createS3BackupConfig(d *schema.ResourceData) *firehose.S3DestinationConfiguration { |
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.
Do you mind reducing the scope here? i.e. the function doesn't need access to the whole schema (all fields), all it needs is a single field, so we can pass it as map[string]interface{}
I think?
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.
Also it is a convention throughout the codebase to call these functions "expanders" - i.e. expandS3BackupConfig
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.
@radeksimko We're not using "expanders" for createS3Config
and createExtendedS3Config
- few lines above and below this snippet. Should I change those too?
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 didn't notice that previously - good catch - we should certainly fix that, but I'd prefer to do it in a separate PR which may come afterwards to keep the context & LOC low here. 😉
@@ -41,6 +41,59 @@ func cloudWatchLoggingOptionsSchema() *schema.Schema { | |||
} | |||
} | |||
|
|||
func S3BackupConfigurationSchema() *schema.Schema { | |||
return &schema.Schema{ | |||
Type: schema.TypeSet, |
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.
In other words it would be better to use TypeList
here.
Can't we call this s3ConfigurationSchema
and use it in "s3_configuration"
too to reduce the repetition a bit?
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'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
http://docs.aws.amazon.com/cli/latest/reference/firehose/create-delivery-stream.html