private async Task InstallAsync(RunningDeployment deployment) { //The bucket should exist at this point Guard.NotNull(deployment, "deployment can not be null"); if (!md5HashSupported) { Log.Info("MD5 hashes are not supported in executing environment. Files will always be uploaded."); } var options = optionsProvider.GetOptions(targetMode); AmazonS3Client Factory() => ClientHelpers.CreateS3Client(awsEnvironmentGeneration); try { (await UploadAll(options, Factory, deployment)).Tee(responses => { var results = responses.Where(z => z.IsSuccess()).ToArray(); if (targetMode == S3TargetMode.EntirePackage && results.FirstOrDefault() != null) { SetOutputVariables(deployment, results.FirstOrDefault()); } else if (targetMode == S3TargetMode.FileSelections) { foreach (var result in results) { var fileName = Path.GetFileName(result.BucketKey); SetOutputVariables(deployment, result, fileName); } } }); } catch (AmazonS3Exception exception) { if (exception.ErrorCode == "AccessDenied") { throw new PermissionException("The AWS account used to perform the operation does not have the " + $"the required permissions to upload to bucket {bucket}"); } throw new UnknownException( $"An unrecognized {exception.ErrorCode} error was thrown while uploading to bucket {bucket}"); } catch (AmazonServiceException exception) { HandleAmazonServiceException(exception); throw; } }
public void Install(RunningDeployment deployment) { //The bucket should exist at this point Guard.NotNull(deployment, "deployment can not be null"); if (!md5HashSupported) { Log.Info("MD5 hashes are not supported in executing environment. Files will always be uploaded."); } var options = optionsProvider.GetOptions(targetMode); AmazonS3Client Factory() => ClientHelpers.CreateS3Client(awsEnvironmentGeneration); try { UploadAll(options, Factory, deployment).Tee(responses => { SetOutputVariables(deployment, responses); }); } catch (AmazonS3Exception exception) { if (exception.ErrorCode == "AccessDenied") { throw new PermissionException("The AWS account used to perform the operation does not have the " + $"the required permissions to upload to bucket {bucket}"); } throw new UnknownException( $"An unrecognised {exception.ErrorCode} error was thrown while uploading to bucket {bucket}"); } catch (AmazonServiceException exception) { HandleAmazonServiceException(exception); throw; } }