lib/plugins/aws/deployFunction/index.js/AwsDeployFunction/updateFunctionConfiguration
class AwsDeployFunction:  updateFunctionConfiguration() {
    const functionObj = this.options.functionObj;
    const serviceObj = this.serverless.service.serviceObject;
    const providerObj = this.serverless.service.provider;
    const params = {
      FunctionName: functionObj.name,
    };

    if ('awsKmsKeyArn' in functionObj && !_.isObject(functionObj.awsKmsKeyArn)) {
      params.KMSKeyArn = functionObj.awsKmsKeyArn;
    } else if (serviceObj && 'awsKmsKeyArn' in serviceObj && !_.isObject(serviceObj.awsKmsKeyArn)) {
      params.KMSKeyArn = serviceObj.awsKmsKeyArn;
    }

    if ('description' in functionObj && !_.isObject(functionObj.description)) {
      params.Description = functionObj.description;
    }

    if ('memorySize' in functionObj && !_.isObject(functionObj.memorySize)) {
      params.MemorySize = functionObj.memorySize;
    } else if ('memorySize' in providerObj && !_.isObject(providerObj.memorySize)) {
      params.MemorySize = providerObj.memorySize;
    }

    if ('timeout' in functionObj && !_.isObject(functionObj.timeout)) {
      params.Timeout = functionObj.timeout;
    } else if ('timeout' in providerObj && !_.isObject(providerObj.timeout)) {
      params.Timeout = providerObj.timeout;
    }

    if (functionObj.onError && !_.isObject(functionObj.onError)) {
      params.DeadLetterConfig = {
        TargetArn: functionObj.onError,
      };
    }

    if (functionObj.environment || providerObj.environment) {
      params.Environment = {};
      params.Environment.Variables = Object.assign(
        {},
        providerObj.environment,
        functionObj.environment
      );

      if (_.some(params.Environment.Variables, value => _.isObject(value))) {
        delete params.Environment;
      } else {
        Object.keys(params.Environment.Variables).forEach((key) => {
          // taken from the bash man pages
          if (!key.match(/^[A-Za-z_][a-zA-Z0-9_]*$/)) {
            const errorMessage = 'Invalid characters in environment variable';
            throw new this.serverless.classes.Error(errorMessage);
          }

          if (!_.isString(params.Environment.Variables[key])) {
            params.Environment.Variables[key] = _.toString(params.Environment.Variables[key]);
          }
        });
      }
    }

    if (functionObj.vpc || providerObj.vpc) {
      const vpc = functionObj.vpc || providerObj.vpc;
      params.VpcConfig = {};

      if (_.isArray(vpc.securityGroupIds) && !_.some(vpc.securityGroupIds, _.isObject)) {
        params.VpcConfig.SecurityGroupIds = vpc.securityGroupIds;
      }

      if (_.isArray(vpc.subnetIds) && !_.some(vpc.subnetIds, _.isObject)) {
        params.VpcConfig.SubnetIds = vpc.subnetIds;
      }

      if (_.isEmpty(params.VpcConfig)) {
        delete params.VpcConfig;
      }
    }

    if ('role' in functionObj && !_.isObject(functionObj.role)) {
      return this.normalizeArnRole(functionObj.role).then(roleArn => {
        params.Role = roleArn;

        return this.callUpdateFunctionConfiguration(params);
      });
    } else if ('role' in providerObj && !_.isObject(providerObj.role)) {
      return this.normalizeArnRole(providerObj.role).then(roleArn => {
        params.Role = roleArn;

        return this.callUpdateFunctionConfiguration(params);
      });
    }

    if (_.isEmpty(_.omit(params, 'FunctionName'))) {
      return BbPromise.resolve();
    }

    return this.callUpdateFunctionConfiguration(params);
  }