Skip to content
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

Merged

Conversation

ApsOps
Copy link
Contributor

@ApsOps ApsOps commented Oct 6, 2017

Copy link
Member

@radeksimko radeksimko left a 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.

@radeksimko radeksimko added enhancement Requests to existing resources that expand the functionality or scope. waiting-response Maintainers are waiting on response from community or contributor. labels Oct 9, 2017
@ApsOps ApsOps force-pushed the firehose-redshift-dest-s3-backup-support branch 3 times, most recently from b32ed22 to db51754 Compare October 23, 2017 20:11
@ApsOps ApsOps force-pushed the firehose-redshift-dest-s3-backup-support branch from db51754 to dba6601 Compare October 23, 2017 20:17
@ApsOps
Copy link
Contributor Author

ApsOps commented Oct 23, 2017

@radeksimko Added the acceptance tests. These are passing for me.
Please let me know if I missed something.

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,
Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

@radeksimko radeksimko left a 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,
Copy link
Member

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 {
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor Author

@ApsOps ApsOps Oct 25, 2017

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?

Copy link
Member

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,
Copy link
Member

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?

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Oct 25, 2017
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@radeksimko radeksimko merged commit 44edced into hashicorp:master Oct 25, 2017
@ghost
Copy link

ghost commented Apr 10, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants