aws/aws-sdk-cpp

Long loading time when initializing Aws::Auth::AWSCredentials

JeffreyChee opened this issue · 7 comments

Describe the bug

    TRACE("CAWSManager::InitFunctions 1\n");
    ASSERT(NULL == m_pcClientPtr);
    m_pcClientPtr = new std::shared_ptr<Aws::Lambda::LambdaClient>;
    if (NULL == m_pcClientPtr) {
        ASSERT(FALSE);
        return FALSE;
    }
    TRACE("CAWSManager::InitFunctions 2\n");
    Aws::Client::ClientConfiguration config;
    config.region = "us-east-1";
    config.disableIMDS = true;
    // this credential only have access lamba function and s3 read/write to a certain bucket
    Aws::Auth::AWSCredentials credentials("my accessKeyId", "my secretKey");
    TRACE("CAWSManager::InitFunctions 3\n");
    *m_pcClientPtr = Aws::MakeShared<Aws::Lambda::LambdaClient>(ALLOCATION_TAG, credentials, config);
    if (NULL == *m_pcClientPtr) {
        ASSERT(FALSE);
        return FALSE;
    }
    TRACE("CAWSManager::InitFunctions 4\n");

Expected Behavior

I Expected no or minimal delays between printing the log
CAWSManager::InitFunctions 1
CAWSManager::InitFunctions 2
CAWSManager::InitFunctions 3
CAWSManager::InitFunctions 4

but in between "CAWSManager::InitFunctions 2" and "CAWSManager::InitFunctions 3"
it takes around 5 seconds to finish constructing the Aws::Auth::AWSCredentials

may I know how should I eliminate this problem?
I saw a similar problem in the past where adding disableIMDS = true solves it, but this time it doesn't

Current Behavior

but in between "CAWSManager::InitFunctions 2" and "CAWSManager::InitFunctions 3"
it takes around 5 seconds to finish constructing the Aws::Auth::AWSCredentials

may I know how should I eliminate this problem?
I saw a similar problem in the past where adding disableIMDS = true solves it, but this time it doesn't

Reproduction Steps

    TRACE("CAWSManager::InitFunctions 1\n");
    ASSERT(NULL == m_pcClientPtr);
    m_pcClientPtr = new std::shared_ptr<Aws::Lambda::LambdaClient>;
    if (NULL == m_pcClientPtr) {
        ASSERT(FALSE);
        return FALSE;
    }
    TRACE("CAWSManager::InitFunctions 2\n");
    Aws::Client::ClientConfiguration config;
    config.region = "us-east-1";
    config.disableIMDS = true;
    // this credential only have access lamba function and s3 read/write to a certain bucket
    Aws::Auth::AWSCredentials credentials("my accessKeyId", "my secretKey");
    TRACE("CAWSManager::InitFunctions 3\n");
    *m_pcClientPtr = Aws::MakeShared<Aws::Lambda::LambdaClient>(ALLOCATION_TAG, credentials, config);
    if (NULL == *m_pcClientPtr) {
        ASSERT(FALSE);
        return FALSE;
    }
    TRACE("CAWSManager::InitFunctions 4\n");

Possible Solution

im looking for the solution...

Additional Information/Context

No response

AWS CPP SDK version used

1.11.330 from homebrew

Compiler and Version used

Apple clang in Xcode latest

Operating System and version

macOS 14.5 (23F79)

I can't seem to reproduce the same loading time that you're seeing. I modified your sample slightly to get it to run by itself, but I'm only seeing 1 millisecond elapse:

[TRACE] 2024-06-17 23:16:08.811 main [140681837720320] CAWSManager::InitFunctions 1
[TRACE] 2024-06-17 23:16:08.811 main [140681837720320] CAWSManager::InitFunctions 2
[DEBUG] 2024-06-17 23:16:08.811 ClientConfiguration [140681837720320] Request Compression enabled
[DEBUG] 2024-06-17 23:16:08.811 ClientConfiguration [140681837720320] ClientConfiguration will use MinReqCompression: 10240
[DEBUG] 2024-06-17 23:16:08.811 ClientConfiguration [140681837720320] ClientConfiguration will use SDK Auto Resolved profile: [default] if not specified by users.
[INFO] 2024-06-17 23:16:08.811 ClientConfiguration [140681837720320] Retry Strategy will use the default max attempts.
[TRACE] 2024-06-17 23:16:08.811 main [140681837720320] CAWSManager::InitFunctions 3
[INFO] 2024-06-17 23:16:08.812 CurlHandleContainer [140681837720320] Initializing CurlHandleContainer with size 25
[TRACE] 2024-06-17 23:16:08.812 main [140681837720320] CAWSManager::InitFunctions 4

Can you provide more details on reproducing this. (a docker container would be great). It it possible something else in your test is causing this to take 5 seconds? Something in your environment?

Hi, im really new to the aws cpp sdk. I just download it from homebrew, put the lib and headers in my project and run it.
I did not configure any aws client on my computer at all.

Can you try building this sdk from source and see if you can document your reproduction steps. Here are the steps for how to do this. Please let me know if you have any problems/questions while trying to do this.

I've tried to compile the sdk myself. but I keep getting runtime missing dylib errors. the homebrew version only needs a few dylibs, but when I build the sdk myself. it seem to ask for a lot of other dylibs.
I'll stick to using the homebrew version for my Mac build (for testing only) and using the mobile sdks for android and iOS.
Was thinking it should be best to use the cpp library for all platforms...

if only someone could provide a cpp binary package that works on all platform with instructions on which libraries are meant for which.

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

I sorry that you were unable to build this sdk without running into missing dylibs. We provide many different configuration options when building this sdk and there are many difference platforms that this sdk can be build for. So for those reasons and many others we don't provide a binary package. If you share the errors that you are currently running into I can try to help you build this sdk.