tier: support using aws role for s3 (#3736)
Signed-off-by: Poorna Krishnamoorthy <poorna@minio.io>
This commit is contained in:
+15
-2
@@ -50,6 +50,10 @@ var adminTierAddFlags = []cli.Flag{
|
||||
Value: "",
|
||||
Usage: "AWS S3 or compatible object storage secret-key",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "use-aws-role",
|
||||
Usage: "use AWS S3 role",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "account-name",
|
||||
Value: "",
|
||||
@@ -119,6 +123,9 @@ EXAMPLES:
|
||||
3. Configure a new remote tier which transitions objects to a bucket in Google Cloud Storage.
|
||||
{{.Prompt}} {{.HelpName}} s3 myminio GCSTIER --credentials-file /path/to/credentials.json --region us-east-1 --bucket testbucket --prefix testprefix/
|
||||
|
||||
4. Configure a new remote tier which transitions objects to a bucket in AWS S3 with STANDARD storage class using aws role.
|
||||
{{.Prompt}} {{.HelpName}} s3 myminio S3TIER --endpoint https://s3.amazonaws.com --use-aws-role \
|
||||
--region us-east-1 --bucket testbucket --prefix testprefix/ --storage-class "STANDARD"
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -147,7 +154,11 @@ func fetchTierConfig(ctx *cli.Context, tierName string, tierType madmin.TierType
|
||||
case madmin.S3:
|
||||
accessKey := ctx.String("access-key")
|
||||
secretKey := ctx.String("secret-key")
|
||||
if accessKey == "" || secretKey == "" {
|
||||
useAwsRole := ctx.IsSet("use-aws-role")
|
||||
if accessKey == "" && secretKey == "" && !useAwsRole {
|
||||
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("%s remote tier requires access credentials or AWS role", tierType))
|
||||
}
|
||||
if (accessKey != "" || secretKey != "") && useAwsRole {
|
||||
fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("%s remote tier requires access credentials", tierType))
|
||||
}
|
||||
|
||||
@@ -179,7 +190,9 @@ func fetchTierConfig(ctx *cli.Context, tierName string, tierType madmin.TierType
|
||||
}
|
||||
s3Opts = append(s3Opts, madmin.S3StorageClass(s3SC))
|
||||
}
|
||||
|
||||
if ctx.IsSet("use-aws-role") {
|
||||
s3Opts = append(s3Opts, madmin.S3AWSRole())
|
||||
}
|
||||
s3Cfg, err := madmin.NewTierS3(tierName, accessKey, secretKey, bucket, s3Opts...)
|
||||
if err != nil {
|
||||
fatalIf(probe.NewError(err), "Invalid configuration for AWS S3 compatible remote tier")
|
||||
|
||||
@@ -38,6 +38,10 @@ var adminTierEditFlags = []cli.Flag{
|
||||
Value: "",
|
||||
Usage: "AWS S3 or compatible object storage secret-key",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "use-aws-role",
|
||||
Usage: "use AWS S3 role",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "account-name",
|
||||
Value: "",
|
||||
@@ -118,11 +122,14 @@ func mainAdminTierEdit(ctx *cli.Context) error {
|
||||
accountName := ctx.String("account-name")
|
||||
accountKey := ctx.String("account-key")
|
||||
credsPath := ctx.String("credentials-file")
|
||||
useAwsRole := ctx.IsSet("use-aws-role")
|
||||
|
||||
switch {
|
||||
case accessKey != "" && secretKey != "": // S3 tier
|
||||
case accessKey != "" && secretKey != "" && !useAwsRole: // S3 tier
|
||||
creds.AccessKey = accessKey
|
||||
creds.SecretKey = secretKey
|
||||
case useAwsRole:
|
||||
creds.AWSRole = true
|
||||
case accountName != "" && accountKey != "": // Azure tier
|
||||
creds.AccessKey = accountName
|
||||
creds.SecretKey = accountKey
|
||||
|
||||
@@ -15,7 +15,7 @@ require (
|
||||
github.com/minio/cli v1.22.0
|
||||
github.com/minio/colorjson v1.0.1
|
||||
github.com/minio/filepath v1.0.0
|
||||
github.com/minio/madmin-go v1.0.9
|
||||
github.com/minio/madmin-go v1.0.10-0.20210602195449-b1bf23ec13e4
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210517200026-f0518ca447d6
|
||||
github.com/minio/pkg v1.0.3
|
||||
github.com/minio/sha256-simd v1.0.0
|
||||
|
||||
@@ -248,6 +248,8 @@ github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
|
||||
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
|
||||
github.com/minio/madmin-go v1.0.9 h1:zXZMppnqboIyELPirHcU6qxrnJkVwj2k7rLIB0T12sY=
|
||||
github.com/minio/madmin-go v1.0.9/go.mod h1:BK+z4XRx7Y1v8SFWXsuLNqQqnq5BO/axJ8IDJfgyvfs=
|
||||
github.com/minio/madmin-go v1.0.10-0.20210602195449-b1bf23ec13e4 h1:AxtnO3AODg0t2IPXbrqmDBhGZTcrUhlT/ixdLQQ3164=
|
||||
github.com/minio/madmin-go v1.0.10-0.20210602195449-b1bf23ec13e4/go.mod h1:BK+z4XRx7Y1v8SFWXsuLNqQqnq5BO/axJ8IDJfgyvfs=
|
||||
github.com/minio/md5-simd v1.1.0 h1:QPfiOqlZH+Cj9teu0t9b1nTBfPbyTl16Of5MeuShdK4=
|
||||
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
||||
github.com/minio/minio-go/v7 v7.0.11-0.20210302210017-6ae69c73ce78/go.mod h1:mTh2uJuAbEqdhMVl6CMIIZLUeiMiWtJR4JB8/5g2skw=
|
||||
|
||||
Reference in New Issue
Block a user