The agent-acess-token flag returns a 401 even if their pass a valid token, because, the are two kinds of agent tokens: “agent registration tokens”, and “agent session tokens”.
The agent access token is set when the agent exchanges its registration token for a session token, which is stored in $BUILDKITE_AGENT_ACCESS_TOKEN. So if you are not providing the access token via the flag on the “buildkite-agent artifact upload” command, it will default to using the value set in $BUILDKITE_AGENT_ACCESS_TOKEN when the agent first registers itself with Buildkite. So in your case I would suggest you to remove the --agent-access-token flag and it should work as expected (assuming that you successfully authenticated with AWS S3, using any of the included credential providers) Here is some examples: buildkite-agent artifact v3 | Buildkite Documentation
If you’re still running into trouble after removing the --agent-access-token flag, please do let us know support@buildkite.com.
You can use the bk cli’s bk local run for running the pipelines locally, however not all pipeline steps features are supported. Development has also discontinued on that branch. We are now developing a new version of bk cli (branch 3.x) that provides more interaction with your buildkite org’s pipelines and builds.
For debugging, we usually start with the job logs that you can see from the UI, but is also available for download via API Jobs API | Buildkite Documentation.
For agent logs, for self-hosted agents running locally, you should be able to access them in your own environments. But for running agents via the elastic stack, we have a guide available for troubleshooting and collecting the logs here Troubleshooting the Elastic CI Stack for AWS | Buildkite Documentation.