Skip to content
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

AWS Account Number not returned properly #87

Closed
mattBrzezinski opened this issue Sep 19, 2019 · 2 comments
Closed

AWS Account Number not returned properly #87

mattBrzezinski opened this issue Sep 19, 2019 · 2 comments

Comments

@mattBrzezinski
Copy link
Member

mattBrzezinski commented Sep 19, 2019

https://github.com/JuliaCloud/AWSCore.jl/blob/v0.6.2/src/AWSCredentials.jl#L220

When the creds.account_number from the AWSConfig is an empty string, we are instead returning the user ARN.

This doesn't seem correct.

@omus
Copy link
Member

omus commented Sep 24, 2019

That function call populates the user ARN and the account number and doesn't return the ARN ever (phew).

The code however is confusing and at least deserves a comment but I would recommend making a new function that just does the populating:

function _populate!(creds::AWSCredentials)
    r = Services.sts(aws, "GetCallerIdentity", [])
    creds.user_arn = r["Arn"]
    creds.account_number = r["Account"]
    return creds
end

function aws_user_arn(aws::AWSConfig)
    creds = aws[:creds]
    if creds.user_arn == ""
        _populate!(creds)
    end
    return creds.user_arn
end

function aws_account_number(aws::AWSConfig)
    creds = aws[:creds]
    if creds.account_number == ""
        _populate!(creds)
    end
    return creds.account_number
end

@mattBrzezinski
Copy link
Member Author

Ah you're right, I miss read the return statement. I'll include this as part of my NFC CR coming up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants