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 support for AWS AssumeRole with tiering #244

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 45 additions & 9 deletions tier-s3.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2015-2022 MinIO, Inc.
// Copyright (c) 2015-2023 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
Expand All @@ -23,14 +23,18 @@ 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"`
AWSRoleWebIdentityTokenFile string `json:",omitempty"`
AWSRoleARN string `json:",omitempty"`
AWSRoleSessionName string `json:",omitempty"`
AWSRoleDurationSeconds int `json:",omitempty"`
}

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

// S3AWSRoleWebIdentityTokenFile helper to use optional AWS Role token file to NewTierS3
func S3AWSRoleWebIdentityTokenFile(tokenFile string) func(s3 *TierS3) error {
return func(s3 *TierS3) error {
s3.AWSRoleWebIdentityTokenFile = tokenFile
return nil
}
}

// 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
}
}

// S3AWSRoleDurationSeconds helper to use optional token duration to NewTierS3
func S3AWSRoleDurationSeconds(dsecs int) func(s3 *TierS3) error {
return func(s3 *TierS3) error {
s3.AWSRoleDurationSeconds = dsecs
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
110 changes: 105 additions & 5 deletions tier-s3_gen.go

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

Loading