Skip to content

Commit

Permalink
add support for AWS AssumeRole with tiering
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana committed Oct 30, 2023
1 parent 59a7fea commit 6b070a3
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 13 deletions.
35 changes: 27 additions & 8 deletions tier-s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ package madmin

// TierS3 represents the remote tier configuration for AWS S3 compatible backend.
type TierS3 struct {
Endpoint string `json:",omitempty"`
AccessKey string `json:",omitempty"`
SecretKey string `json:",omitempty"`
Bucket string `json:",omitempty"`
Prefix string `json:",omitempty"`
Region string `json:",omitempty"`
StorageClass string `json:",omitempty"`
AWSRole bool `json:",omitempty"`
Endpoint string `json:",omitempty"`
AccessKey string `json:",omitempty"`
SecretKey string `json:",omitempty"`
Bucket string `json:",omitempty"`
Prefix string `json:",omitempty"`
Region string `json:",omitempty"`
StorageClass string `json:",omitempty"`
AWSRole bool `json:",omitempty"`
AWSRoleARN string `json:",omitempty"`
AWSRoleSessionName string `json:",omitempty"`
DurationSeconds int `json:",omitempty"`
}

// S3Options supports NewTierS3 to take variadic options
Expand Down Expand Up @@ -76,6 +79,22 @@ func S3AWSRole() func(s3 *TierS3) error {
}
}

// S3AWSRoleARN helper to use optional AWS RoleARN to NewTierS3
func S3AWSRoleARN(roleARN string) func(s3 *TierS3) error {
return func(s3 *TierS3) error {
s3.AWSRoleARN = roleARN
return nil
}
}

// S3AWSRoleSessionName helper to use optional AWS RoleSessionName to NewTierS3
func S3AWSRoleSessionName(roleSessionName string) func(s3 *TierS3) error {
return func(s3 *TierS3) error {
s3.AWSRoleSessionName = roleSessionName
return nil
}
}

// NewTierS3 returns a TierConfig of S3 type. Returns error if the given
// parameters are invalid like name is empty etc.
func NewTierS3(name, accessKey, secretKey, bucket string, options ...S3Options) (*TierConfig, error) {
Expand Down
85 changes: 80 additions & 5 deletions tier-s3_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6b070a3

Please sign in to comment.