Authentication via API Token seems to produce an error.
To reproduce
Using 5.9.1,
Provide BUILDKITE_AGENT_TOKEN envvar, with no other authentication methods
Receive error failed to initialize Buildkite token provider: one of the [BUILDKITE_AGENT_TOKEN,BUILDKITE_AGENT_TOKEN_SSM_KEY,BUILDKITE_AGENT_SECRETS_MANAGER_SECRET_ID] environment variables must be provided
Investigation
I think this is in https://github.com/buildkite/buildkite-agent-metrics/blob/master/lambda/main.go#L185 where providers gets set when checking for tokens/SSM, but returned when checking for Secrets Manager. At the end of the function, we return an error.
If I had to guess, I'd say the solution probably looks like...
diff --git a/lambda/main.go b/lambda/main.go
index a15ff40..2ffd761 100644
--- a/lambda/main.go
+++ b/lambda/main.go
@@ -241,11 +241,15 @@ func initTokenProvider(awsRegion string) ([]token.Provider, error) {
}
providers = append(providers, secretManager)
}
- return providers, nil
}
- return nil, fmt.Errorf("failed to initialize Buildkite token provider: one of the [%s] environment variables "+
+ if len(providers) > 0 {
+ return providers, nil
+ } else {
+ return nil, fmt.Errorf("failed to initialize Buildkite token provider: one of the [%s] environment variables "+
"must be provided", strings.Join(mutuallyExclusiveEnvVars, ","))
+ }
+
}
... but I don't know Go, so I could be way off base here.
Workaround
I'm not seeing this error in 5.9.0. However, 5.9.0 does not include #234, so neither of these is working for me at the moment.
Summary
Authentication via API Token seems to produce an error.
To reproduce
BUILDKITE_AGENT_TOKEN
envvar, with no other authentication methodsfailed to initialize Buildkite token provider: one of the [BUILDKITE_AGENT_TOKEN,BUILDKITE_AGENT_TOKEN_SSM_KEY,BUILDKITE_AGENT_SECRETS_MANAGER_SECRET_ID] environment variables must be provided
Investigation
I think this is in
https://github.com/buildkite/buildkite-agent-metrics/blob/master/lambda/main.go#L185
whereproviders
gets set when checking for tokens/SSM, but returned when checking for Secrets Manager. At the end of the function, we return an error.If I had to guess, I'd say the solution probably looks like...
... but I don't know Go, so I could be way off base here.
Workaround
I'm not seeing this error in 5.9.0. However, 5.9.0 does not include #234, so neither of these is working for me at the moment.