-
Notifications
You must be signed in to change notification settings - Fork 68
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
Support credential profiles #74
Comments
Hi @mousedownmike , Thanks for the feedback X-Ray Daemon is using AWS SDK Go to send requests to AWS service endpoint and based on AWS Go's documentation, you can specify which profile to use by setting We're planning to support passing a command-line argument when running Daemon locally and we'll put this in our backlog. Also you're always welcome to submit a PR to contribute. Thanks |
@lupengamzn, I did try setting the |
The curious thing is that I develop in Go and use the aws-sdk-go for my projects. In those projects, the I will try to find some time to dig a little deeper into this and report back. |
Hey @mousedownmike , I just tried this on my end with X-Ray Daemon Thanks |
Created a pull request for this. Could you please review? |
@lupengamzn I'm using the Docker image with the following Dockerfile.
This is the run configuration: docker build -t xray-daemon .
&& docker run
-p 2000:2000/udp
--env AWS_REGION=us-east-1
--env AWS_PROFILE=myprofile
-v /home/mike/.aws:/root/.aws:ro
--net host
xray-daemon -l dev -o Here is the output I'm getting:
For good measure, I just ran the daemon directly from the command line with the same setup and received the same errors.
I'm running a pretty generic |
@mousedownmike
|
@wangzlei yes, my credentials are set up like that. I was able to verify that the profiles work using the AWS CLI and I use them in my own Go code. I'm going to try building and running the daemon from the source when I have a spare moment. Would you recommend using the |
Hey @mousedownmike ,
May I know why you're using |
Lanks @lupengamzn , I have tried the It works great with the cli and with my local Go programs that use the AWS SDK.. The daemon is the only tool where I've had issues which still makes me suspect I'm doing something wrong. When I have a moment I'll try running it from source to see if I can help discover the issue. |
@mousedownmike Have you ever tried |
When I set
|
We'll take a closer look into this. Look like we're missing debugging logs around the credential resolution. Thanks! |
@mousedownmike yeah, that means your profile takes effect, but might forget to set |
@wangzlei you are correct, I did not have
|
I finally found some time to dig into the code here and discovered that result, serr := session.NewSessionWithOptions(session.Options{SharedConfigState: session.SharedConfigEnable}) My profile is loaded (assuming I have es := getDefaultSession()
awsRegion = *es.Config.Region
if awsRegion == "" {
_ = log.Error("Unable to fetch region from session config")
} else {
log.Debugf("Fetched region %v from session config", awsRegion)
} These changes are isolated to |
* #74 using SharedConfigState to enable credential profiles and regions set in session config * Using session region if noMetadata is set to true * Reverting import formatting and !noMetadata log.Errorf Co-authored-by: Lei Wang <[email protected]>
This works now? Close this issue? |
I just had some difficulty getting the Daemon running locally due to the way I have my credentials configured. To get things to work, I ultimately had to change my
[default]
credentials. This request is to add support for credential profiles. It's possible this can work another way, I just couldn't find it documented.For reference, here is a sample credentials file.
And here is the sample config file to go with that:
I would like to set an environment variable of
AWS_PROFILE=corpdev
or pass a command-line argument and have the Daemon use the specified profile's configuration/credentials.I was able to confirm that the
corpdev
profile permissions were sufficient by running the following CLI:aws xray put-trace-segments --trace-segment-documents "{\"trace_id\": \"1-5f84854a-b250fd33b4dd6208733a59df\", \"id\": \"ebd6c854cd28bca2\", \"start_time\": 1602520394, \"in_progress\": true, \"name\": \"Scorekeep-build\"}" --profile corpdev
I tried passing the role directly like
-r "arn:aws:iam::123412341234:role/corp-dev-account-role"
but that resulted in an AccessDenied error indicating the user from my[mike]
(same as[default]
) profile did not have permsission to assume that role (which is accurate).In order to move on, I simply changed by
[default]
profile to be the[corp]
profile and I pass thecorp-dev-account-role
ARN in as a-r
command line option and it works.This was pretty difficult to diagnose due to the default logging information available:
dev
, there are a number of JSON parsing errors that seem to indicate an error but they're apparently expected (SerializationError: failed decoding REST JSON error response #22).The text was updated successfully, but these errors were encountered: