Skip to content

Commit cb261d9

Browse files
authored
fix(operator): provide AWS region in environment variable for STS mode (#21136)
1 parent 5e47080 commit cb261d9

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

‎operator/internal/manifests/storage/configure.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,13 @@ func tokenAuthCredentials(opts Options) []corev1.EnvVar {
222222
return []corev1.EnvVar{
223223
envVarFromValue(EnvAWSCredentialsFile, path.Join(tokenAuthConfigDirectory, KeyAWSCredentialsFilename)),
224224
envVarFromValue(EnvAWSSdkLoadConfig, "true"),
225+
envVarFromValue(EnvAWSRegion, opts.S3.Region),
225226
}
226227
} else {
227228
return []corev1.EnvVar{
228229
envVarFromSecret(EnvAWSRoleArn, opts.SecretName, KeyAWSRoleArn),
229230
envVarFromValue(EnvAWSWebIdentityTokenFile, ServiceAccountTokenFilePath),
231+
envVarFromValue(EnvAWSRegion, opts.S3.Region),
230232
}
231233
}
232234
case lokiv1.ObjectStorageSecretAzure:

‎operator/internal/manifests/storage/configure_test.go‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,9 @@ func TestConfigureDeploymentForStorageType(t *testing.T) {
867867
SharedStore: lokiv1.ObjectStorageSecretS3,
868868
CredentialMode: lokiv1.CredentialModeToken,
869869
S3: &S3StorageConfig{
870-
STS: true,
871870
Audience: "test",
871+
Region: "test-region",
872+
STS: true,
872873
},
873874
},
874875
dpl: &appsv1.Deployment{
@@ -919,6 +920,10 @@ func TestConfigureDeploymentForStorageType(t *testing.T) {
919920
Name: "AWS_WEB_IDENTITY_TOKEN_FILE",
920921
Value: "/var/run/secrets/storage/serviceaccount/token",
921922
},
923+
{
924+
Name: "AWS_REGION",
925+
Value: "test-region",
926+
},
922927
},
923928
},
924929
},
@@ -960,7 +965,8 @@ func TestConfigureDeploymentForStorageType(t *testing.T) {
960965
SharedStore: lokiv1.ObjectStorageSecretS3,
961966
CredentialMode: lokiv1.CredentialModeTokenCCO,
962967
S3: &S3StorageConfig{
963-
STS: true,
968+
Region: "test-region",
969+
STS: true,
964970
},
965971
OpenShift: OpenShiftOptions{
966972
Enabled: true,
@@ -1012,6 +1018,10 @@ func TestConfigureDeploymentForStorageType(t *testing.T) {
10121018
Name: "AWS_SDK_LOAD_CONFIG",
10131019
Value: "true",
10141020
},
1021+
{
1022+
Name: "AWS_REGION",
1023+
Value: "test-region",
1024+
},
10151025
},
10161026
},
10171027
},
@@ -2065,7 +2075,8 @@ func TestConfigureStatefulSetForStorageType(t *testing.T) {
20652075
SharedStore: lokiv1.ObjectStorageSecretS3,
20662076
CredentialMode: lokiv1.CredentialModeTokenCCO,
20672077
S3: &S3StorageConfig{
2068-
STS: true,
2078+
Region: "test-region",
2079+
STS: true,
20692080
},
20702081
OpenShift: OpenShiftOptions{
20712082
Enabled: true,
@@ -2117,6 +2128,10 @@ func TestConfigureStatefulSetForStorageType(t *testing.T) {
21172128
Name: "AWS_SDK_LOAD_CONFIG",
21182129
Value: "true",
21192130
},
2131+
{
2132+
Name: "AWS_REGION",
2133+
Value: "test-region",
2134+
},
21202135
},
21212136
},
21222137
},

‎operator/internal/manifests/storage/var.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const (
77
EnvAlibabaCloudAccessKeyID = "ALIBABA_CLOUD_ACCESS_KEY_ID"
88
// EnvAlibabaCloudAccessKeySecret is the environment variable to specify the AlibabaCloud client secret to access S3.
99
EnvAlibabaCloudAccessKeySecret = "ALIBABA_CLOUD_ACCESS_KEY_SECRET"
10+
// EnvAWSRegion configures the AWS region the client uses for operations.
11+
EnvAWSRegion = "AWS_REGION"
1012
// EnvAWSAccessKeyID is the environment variable to specify the AWS client id to access S3.
1113
EnvAWSAccessKeyID = "AWS_ACCESS_KEY_ID"
1214
// EnvAWSAccessKeySecret is the environment variable to specify the AWS client secret to access S3.

0 commit comments

Comments
 (0)