Giter VIP home page Giter VIP logo

Comments (2)

jderusse avatar jderusse commented on September 15, 2024

Hello, thank you for the well-explained report.
Are you sure about the minimal reproducer? I don't have the same result, in my case the region defined in ~/.aws/config is used.

The current implementation is:

  • When instantiating a client, the configuration object is built.
  • The configuration merge data from multiple source (env variables, .ini file, ...)
    $options = array_map(static function ($value) {
    return null !== $value ? (string) $value : $value;
    }, $options);
    $configuration = new self();
    $options = self::parseEnvironmentVariables($options);
    self::populateConfiguration($configuration, $options);
    $iniOptions = self::parseIniFiles($configuration);
    self::populateConfiguration($configuration, $iniOptions);
  • It load .ini files here:
    $options = [];
    if (!$configuration->isDefault(self::OPTION_REGION)) {
    return $options;
    }
    $profilesData = (new IniFileLoader())->loadProfiles([
    $configuration->get(self::OPTION_SHARED_CREDENTIALS_FILE),
    $configuration->get(self::OPTION_SHARED_CONFIG_FILE),
    ]);
    if (empty($profilesData)) {
    return $options;
    }
    /** @var string $profile */
    $profile = $configuration->get(Configuration::OPTION_PROFILE);
    if (isset($profilesData[$profile]['region'])) {
    $options[self::OPTION_REGION] = $profilesData[$profile]['region'];
    }
    return $options;
  • multiple ini files are merged together here:
    foreach ($this->parseIniFile($filepath) as $name => $profile) {
    $name = preg_replace('/^profile /', '', (string) $name);
    if (!isset($profilesData[$name])) {
    $profilesData[$name] = array_map('trim', $profile);
    } else {
    foreach ($profile as $k => $v) {
    if (!isset($profilesData[$name][$k])) {
    $profilesData[$name][$k] = trim($v);
    }
    }
    }
    }

As expected, if the region is defined in ~/.aws/config and credentials are defined in ~/.aws/credentials then both file are merged, and region from ~/.aws/config will be used.

Could you help to troubleshoot by dumping the configuration and checking if the region is set:

  • in src/Core/src/AbstractApi.php dump the $configuration at line 80
  • in src/Core/src/AbstractApi.php dump the $region variable at line 240

from aws.

petrisorciprian-vitals avatar petrisorciprian-vitals commented on September 15, 2024

Hi @jderusse !

Thank you for the hints, I've debugged this and found out that the project I'm working on had the following env set:

AWS_CONFIG_FILE=false

I now understand why the async-aws SDK behaved the way it did, since my ~/.aws/config file is not loaded.

What I'm not okay with is the fact that the official AWS SDK seemed to be just fine with this set as such.
I tracked this down to the following code on their side:
https://github.com/aws/aws-sdk-php/blob/master/src/AbstractConfigurationProvider.php#L106-L111

The function above calls getenv(self::ENV_CONFIG_FILE), which will return false (assuming AWS_CONFIG_FILE=false in env).
Thus, their if check fails and it goes into the return self::getHomeDir() .'/.aws/config'; below.

Not sure what to think on this one, I find the behaviour of async-aws to be more correct, but this difference is kind of a headache to debug and can potentially be very destructive when migrating from one sdk to another.

I'm curious what your thoughts are on this, I'm currently tempted to raise an issue in the official SDK about this.

from aws.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.