modules/mu/clouds/aws.rb in cloud-mu-3.0.0 vs modules/mu/clouds/aws.rb in cloud-mu-3.0.1

- old
+ new

@@ -162,11 +162,10 @@ # Given an AWS region, check the API to make sure it's a valid one # @param r [String] # @return [String] def self.validate_region(r, credentials: nil) - require "aws-sdk-core" begin MU::Cloud::AWS.ec2(region: r, credentials: credentials).describe_availability_zones.availability_zones.first.region_name rescue ::Aws::EC2::Errors::UnauthorizedOperation => e MU.log "Got '#{e.message}' trying to validate region #{r} (hosted: #{hosted?.to_s})", MU::ERR, details: loadCredentials(credentials) raise MuError, "Got '#{e.message}' trying to validate region #{r} with credentials #{credentials ? credentials : "<default>"} (hosted: #{hosted?.to_s})" @@ -1337,11 +1336,11 @@ # Create an AWS API client # @param region [String]: Amazon region so we know what endpoint to use # @param api [String]: Which API are we wrapping? def initialize(region: MU.curRegion, api: "EC2", credentials: nil) - @credentials = MU::Cloud::AWS.credConfig(credentials, name_only: true) @cred_obj = MU::Cloud::AWS.loadCredentials(credentials) + @credentials = MU::Cloud::AWS.credConfig(credentials, name_only: true) if !@cred_obj raise MuError, "Unable to locate valid AWS credentials for #{api} API. #{credentials ? "Credentials requested were '#{credentials}'": ""}" end