lib/plugins/aws/configCredentials/awsConfigCredentials.js/AwsConfigCredentials/configureCredentials
class AwsConfigCredentials:  configureCredentials() {
    // sanitize
    this.options.provider = this.options.provider.toLowerCase();
    this.options.profile = this.options.profile ? this.options.profile : 'default';

    // resolve if provider option is not 'aws'
    if (this.options.provider !== 'aws') {
      return BbPromise.resolve();
    }

    // validate
    if (!this.options.key || !this.options.secret) {
      throw new this.serverless.classes.Error('Please include --key and --secret options for AWS.');
    }

    this.serverless.cli.log('Setting up AWS...');

    this.credentials = this.getCredentials();

    // Get the profile start line and end line numbers inside the credentials array
    const profileBoundaries = this.getProfileBoundaries();

    // Check if the profile exists
    const isNewProfile = profileBoundaries.start === -1;
    if (isNewProfile) {
      this.addProfile();
    } else {
      // Only update the profile if the overwrite flag was set
      if (!this.options.overwrite) {
        const message = [
          `Failed! ~/.aws/credentials already has a "${this.options.profile}" profile.`,
          ' Use the overwrite flag ("-o" or "--overwrite") to force the update',
        ].join('');
        this.serverless.cli.log(message);
        return BbPromise.resolve();
      }

      this.updateProfile(profileBoundaries);
    }

    return this.saveCredentialsFile();
  }