Example #1
0
 public Transcoder()
 {
     transcoder = new AmazonElasticTranscoderClient(new AmazonElasticTranscoderConfig()
     {
         RegionEndpoint = RegionEndpoint.EUWest1
     });
 }
        public TranscoderService()
        {
            _pipelineId   = WebConfigurationManager.AppSettings["AWSPipelineId"];
            _jobKeepLimit = WebConfigurationManager.AppSettings["AWSJobKeepLimit"].ToInt();

            _transcoderClient = new AmazonElasticTranscoderClient();
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonElasticTranscoderConfig config = new AmazonElasticTranscoderConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonElasticTranscoderClient client = new AmazonElasticTranscoderClient(creds, config);

            ListPipelinesResponse resp = new ListPipelinesResponse();

            do
            {
                ListPipelinesRequest req = new ListPipelinesRequest
                {
                    PageToken = resp.NextPageToken
                };

                resp = client.ListPipelines(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.Pipelines)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextPageToken));
        }
 public static void BuildRuntimePipeline(TestContext t)
 {
     _client = new MockElasticTranscoderClient(new BasicAWSCredentials("access_key", "secret_key"),
                                               new AmazonElasticTranscoderConfig
     {
         ServiceURL = @"http://EtsListPresets"
     });
 }
Example #5
0
    public static void Transcode(string inputS3Key, string outputS3Key, string bucketName)
    {
        var email = "*****@*****.**";

        // Create a topic the the pipeline to used for notifications
        var topicArn = CreateTopic(email);

        // Create the IAM role for the pipeline
        var role = CreateIamRole();



        var etsClient = new AmazonElasticTranscoderClient();

        var notifications = new Notifications()
        {
            Completed   = topicArn,
            Error       = topicArn,
            Progressing = topicArn,
            Warning     = topicArn
        };

        // Create the Elastic Transcoder pipeline for transcoding jobs to be submitted to.
        //var pipeline = etsClient.CreatePipeline(new CreatePipelineRequest
        //{
        //    Name = "MyVideos" + UNIQUE_POSTFIX,
        //    InputBucket = bucketName,
        //    OutputBucket = bucketName,
        //    Notifications = notifications,
        //    Role = role.Arn
        //}).Pipeline;
        var listPipeLines = etsClient.ListPipelines();
        var pipeline      = listPipeLines.Pipelines[0];

        // Create a job to transcode the input file
        etsClient.CreateJob(new CreateJobRequest
        {
            PipelineId = pipeline.Id,
            Input      = new JobInput
            {
                AspectRatio = "auto",
                Container   = "auto",
                FrameRate   = "auto",
                Interlaced  = "auto",
                Resolution  = "auto",
                Key         = inputS3Key
            },
            Output = (new CreateJobOutput
            {
                ThumbnailPattern = "",
                Rotate = "0",
                // Generic 720p: Go to http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/create-job.html#PresetId to see a list of some
                // of the support presets or call the ListPresets operation to get the full list of available presets
                PresetId = "1351620000000-100010",
                Key = outputS3Key.Substring(0, outputS3Key.LastIndexOf(".")) + ".mp4"
            })
        });
    }
        protected IAmazonElasticTranscoder CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonElasticTranscoderConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonElasticTranscoderClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
        protected virtual void PerformProcessVideos()
        {
            base.ExecuteMethod("PerformProcessVideos", delegate()
            {
                List <Asset> assetsFailed = this.API.Direct.Assets.GetVideosFailedProcessingAfter(MaximumRetries + 1, DateTime.UtcNow.AddMinutes(-1));
                if (assetsFailed.Count > 0)
                {
                    INotifyAdmin notifyAdmin = this.IFoundation.SafeResolve <INotifyAdmin>();
                    if (notifyAdmin != null)
                    {
                        string body = string.Empty;
                        foreach (var item in assetsFailed)
                        {
                            body += string.Format("asset_id: {0}\nraw_url: {1}\nlog:: {2} \n\n--------------------\n\n", item.asset_id, item.raw_url, item.encode_log);
                        }
                        notifyAdmin.SendAdminEmail("Videos Have Failed To Encode", body);
                    }
                }
                List <Asset> assetsToQueue = this.API.Direct.Assets.GetVideosForProcessing(EncoderStatus.not_processed.ToString(), true);

                if (assetsToQueue.Count > 0)
                {
                    using (AmazonElasticTranscoderClient client = new AmazonElasticTranscoderClient(this.AmazonKeyID, this.AmazonSecret, RegionEndpoint.USEast1))
                    {
                        foreach (Asset item in assetsToQueue)
                        {
                            PerformProcessVideo(client, item);
                        }
                    }
                }

                DateTime minimumAttemptTime = DateTime.UtcNow.AddMinutes(-RetryWindow);
                List <Asset> assetsToRetry  = this.API.Direct.Assets.GetVideosForRetrying(MaximumRetries + 1, minimumAttemptTime);

                if (assetsToRetry.Count > 0)
                {
                    using (AmazonElasticTranscoderClient client = new AmazonElasticTranscoderClient(this.AmazonKeyID, this.AmazonSecret, RegionEndpoint.USEast1))
                    {
                        foreach (var item in assetsToRetry)
                        {
                            PerformProcessVideo(client, item);
                        }
                    }
                }
            });
        }
Example #8
0
 public static void ConvertHDtoLD_Video(string fileName, string pipeLineID, string presetID)
 {
     AmazonElasticTranscoderClient etsClient = new AmazonElasticTranscoderClient();
     var response = etsClient.CreateJob(new CreateJobRequest()
     {
         PipelineId = pipeLineID, //pipeline.Id,
         Input      = new JobInput()
         {
             AspectRatio = "auto",
             Container   = "mp4",
             FrameRate   = "auto",
             Interlaced  = "auto",
             Resolution  = "auto",
             Key         = fileName
         },
         Output = new CreateJobOutput()
         {
             ThumbnailPattern = "",
             Rotate           = "0",
             PresetId         = presetID,
             Key = fileName
         }
     });
 }
        public static string UploadVideoToLocation(Stream fs, String folder, String subFolder, String filename)
        {
            filename = filename.Replace("+", "");
            String filePath = folder.Replace("+", "") + "/" + subFolder.Replace("+", "") + "/" + Guid.NewGuid() + filename;

            if (string.IsNullOrEmpty(Path.GetExtension(filePath)))
            {
                filePath += ".mp4";
            }

            var client = s3Client;
            {
                PutObjectRequest request = new PutObjectRequest {
                    BucketName  = "videoToconvert",
                    CannedACL   = S3CannedACL.PublicRead,
                    Key         = filePath,
                    InputStream = fs
                };
                client.PutObject(request);
            }
            String finalOriginalPath = UrlPublic + filePath;

            finalOriginalPath = finalOriginalPath.Replace("+", "%2B");

            var etsClient = new AmazonElasticTranscoderClient(bucketRegion);

            var notifications = new Notifications()
            {
                Completed   = "arn:aws:sns:us-west-2:277579135337:Transcode",
                Error       = "arn:aws:sns:us-west-2:277579135337:Transcode",
                Progressing = "arn:aws:sns:us-west-2:277579135337:Transcode",
                Warning     = "arn:aws:sns:us-west-2:277579135337:Transcode"
            };

            var pipeline = new Pipeline();

            if (etsClient.ListPipelines().Pipelines.Count == 0)
            {
                pipeline = etsClient.CreatePipeline(new CreatePipelineRequest()
                {
                    Name          = "MyTranscodedVideos",
                    InputBucket   = "videoToconvert",
                    OutputBucket  = "videoToconvert",
                    Notifications = notifications,
                    Role          = "arn:aws:iam::277579135337:role/Elastic_Transcoder_Default_Role",
                }).Pipeline; //createpipelineresult
            }
            else
            {
                pipeline = etsClient.ListPipelines().Pipelines.First();
            }

            etsClient.CreateJob(new CreateJobRequest()
            {
                PipelineId = pipeline.Id,
                Input      = new JobInput()
                {
                    AspectRatio = "auto",
                    Container   = "mp4", //H.264
                    FrameRate   = "auto",
                    Interlaced  = "auto",
                    Resolution  = "auto",
                    Key         = filePath
                },
                Output = new CreateJobOutput()
                {
                    ThumbnailPattern = "thumbnnail{count}",
                    Rotate           = "0",
                    PresetId         = "1351620000001-000010", //Generic-720 px
                    Key = finalOriginalPath
                }
            });

            var delClient = s3Client;

            {
                //delClient.DeleteObject("VideoToConvert", filePath);
            }

            return(finalOriginalPath);
        }
Example #10
0
        private static bool UploadVideoToLocation()
        {
            try
            {
                var strSamplePath = GetAppSetting("SamplePath");
                var strFilePath   = strSamplePath;
                var strFilename   = Path.GetFileName(strSamplePath);
                var strExtension  = Path.GetExtension(strFilePath);
                var strRand       = GetRandomString();
                var strKey        = $"mwstag/ElasticTranscoder/Video/{strRand}/{strFilename}";

                if (string.IsNullOrEmpty(strExtension))
                {
                    strFilePath += ".mp4";
                }

                //Upload the video to the input bucket
                if (!UploadFile(strFilePath, strKey))
                {
                    Console.WriteLine("The video upload did not go well!!");
                    return(false);
                }

                //Create the pipelines
                var      strAWSAccessKey = GetAppSetting("AWSAccessKeyID");
                var      strAWSSecretKey = GetAppSetting("AWSSecretKey");
                var      objAmazonElasticTranscoderClient = new AmazonElasticTranscoderClient(strAWSAccessKey, strAWSSecretKey, RegionEndpoint.EUWest1);
                var      lstPipelines = objAmazonElasticTranscoderClient.ListPipelines();
                Pipeline objPipeline;
                if (!objAmazonElasticTranscoderClient.ListPipelines().Pipelines.Any())
                {
                    objPipeline = objAmazonElasticTranscoderClient.CreatePipeline(new CreatePipelineRequest
                    {
                        Name         = GetAppSetting("PipelineName"),
                        InputBucket  = GetAppSetting("Bucket"),
                        OutputBucket = GetAppSetting("Bucket"),
                        Role         = GetAppSetting("AWSRole")
                    }).Pipeline; //createpipelineresult
                }
                else
                {
                    objPipeline = objAmazonElasticTranscoderClient.ListPipelines().Pipelines.First();
                }


                //Create the job
                objAmazonElasticTranscoderClient.CreateJob(new CreateJobRequest
                {
                    PipelineId = objPipeline.Id,
                    Input      = new JobInput
                    {
                        AspectRatio = "auto",
                        Container   = "mp4", //H.264
                        FrameRate   = "auto",
                        Interlaced  = "auto",
                        Resolution  = "auto",
                        Key         = strKey
                    },
                    Output = new CreateJobOutput
                    {
                        ThumbnailPattern = $"{GetRandomString()}{{count}}",
                        Rotate           = "0",
                        PresetId         = "1351620000001-000010", //Generic-720 px
                        Key = $"mwstag/ElasticTranscoder/Video/{strRand}/output/{strFilename}"
                    }
                });
                return(true);
            }
            catch (Exception objException)
            {
                WriteToLog(objException.Message);
                return(false);
            }
        }
        protected virtual void PerformProcessVideo(AmazonElasticTranscoderClient client, Asset asset)
        {
            base.ExecuteMethod("PerformProcessVideo", delegate()
            {
                try
                {
                    string actualFile = asset.raw_url;

                    // strip bucket
                    int ix = actualFile.ToLower().IndexOf(this.AmazonBucket.ToLower());
                    if (ix > -1)
                    {
                        actualFile = actualFile.Substring(ix + this.AmazonBucket.Length).Trim('/');
                    }

                    // strip cloud front
                    if (!string.IsNullOrEmpty(this.AmazonCloudFrontUrl))
                    {
                        ix = actualFile.ToLower().IndexOf(this.AmazonCloudFrontUrl.ToLower());
                        if (ix > -1)
                        {
                            actualFile = actualFile.Substring(ix + this.AmazonCloudFrontUrl.Length).Trim('/');
                        }
                        ix = asset.raw_url.LastIndexOf('/');
                    }
                    string prefix = asset.raw_url.Substring(0, ix) + "/";

                    CreateJobResponse response = client.CreateJob(new CreateJobRequest()
                    {
                        PipelineId      = this.AmazonPipeLineID,
                        OutputKeyPrefix = OUTPUT_PREFIX + asset.asset_id.ToString() + "/",
                        Input           = new JobInput()
                        {
                            Key         = actualFile,
                            AspectRatio = "auto",
                            Container   = "auto",
                            FrameRate   = "auto",
                            Interlaced  = "auto",
                            Resolution  = "auto"
                        },
                        Outputs = new List <CreateJobOutput>()
                        {
                            new CreateJobOutput()
                            {
                                Key              = actualFile,
                                PresetId         = this.AmazonPresetID,
                                ThumbnailPattern = "thumb_{count}",
                                Rotate           = "auto"
                            }
                        }
                    });

                    if (response.Job != null)
                    {
                        HealthReporter.Current.UpdateMetric(HealthTrackType.Each, HealthReporter.VIDEO_TRANSCODE_QUEUE_SUCCESS, 0, 1);
                        this.API.Direct.Assets.UpdateEncodingInfo(asset.asset_id, response.Job.Id, true, EncoderStatus.queued.ToString(), "Amazon Queued on " + DateTime.UtcNow.ToString(), true);
                    }
                    else
                    {
                        HealthReporter.Current.UpdateMetric(HealthTrackType.Each, HealthReporter.VIDEO_TRANSCODE_QUEUE_FAILED, 0, 1);
                        this.API.Direct.Assets.UpdateEncodingInfo(asset.asset_id, string.Empty, false, EncoderStatus.raw.ToString(), "Amazon Queue Failed on " + DateTime.UtcNow.ToString(), true);
                    }
                }
                catch (Exception ex)
                {
                    this.API.Direct.Assets.UpdateEncodingInfo(asset.asset_id, string.Empty, false, EncoderStatus.raw.ToString(), CoreUtility.FormatException(ex), true);
                    HealthReporter.Current.UpdateMetric(HealthTrackType.Each, HealthReporter.VIDEO_TRANSCODE_QUEUE_FAILED, 0, 1);
                    this.IFoundation.LogError(ex, "PerformProcessVideo");
                }
            });
        }
Example #12
0
        public async Task CreateCustomResourceWithHandlerTest()
        {
            // ARRANGE
            string AccountNumber      = "123456789012";
            string Region             = "us-east-1";
            string InputBucket        = $"{Environment.UserName}-rawvideo";
            string OutputBucket       = $"{Environment.UserName}-video";
            string PresignedUrlBucket = $"{Environment.UserName}-presigned-url-test";
            string ThumbnailBucket    = $"{Environment.UserName}-thumbnails";
            string IAMRole            = $"arn:aws:iam::{AccountNumber}:role/LambdaElasticTranscoderPipeline";
            string NotificationTopic  = $"arn:aws:sns:{Region}:{AccountNumber}:ElasticTranscoderNotifications";
            string Key = "result.txt";

            AWSConfigs.AWSProfilesLocation = $"{Environment.GetEnvironmentVariable("UserProfile")}\\.aws\\credentials";

            Mock <IAmazonS3> s3Client = new Mock <IAmazonS3>();

            s3Client.Setup(x => x.GetPreSignedURL(It.IsAny <GetPreSignedUrlRequest>())).Returns($"https://{PresignedUrlBucket}.s3.amazonaws.com/{Key}?AWSAccessKeyId=AKIA1234567890123456&Expires=1559247929&Signature=OTgL4H7i%2FQOcTFpLM%2AV2LsFjONE%3D");

            GetPreSignedUrlRequest preSignedUrlRequest = new GetPreSignedUrlRequest()
            {
                BucketName = PresignedUrlBucket,
                Key        = Key,
                Expires    = DateTime.Now.AddMinutes(2),
                Protocol   = Protocol.HTTPS,
                Verb       = HttpVerb.PUT
            };

            string PreSignedUrl = s3Client.Object.GetPreSignedURL(preSignedUrlRequest);
            string Json         = $@"
{{
""requestType"":""create"",
""responseUrl"":""{PreSignedUrl}"",
""stackId"":""arn:aws:cloudformation:{Region}:{AccountNumber}:stack/stack-name/{Guid.NewGuid().ToString()}"",
""requestId"":""12345678"",
""resourceType"":""Custom::TestResource"",
""logicalResourceId"":""MyTestResource"",
""resourceProperties"":{{
""Role"":""{IAMRole}"",
""Name"":""TestPipeline"",
""InputBucket"":""{InputBucket}"",
""Notifications"":{{
""Error"": ""{NotificationTopic}"",
}},
""ContentConfig"":{{
""Bucket"":""{OutputBucket}""
}},
""ThumbnailConfig"":{{
""Bucket"":""{ThumbnailBucket}""
}}
}}
}}";

            Json = Json.Trim().Replace("\r", "").Replace("\n", "").Replace("\t", "");

            Func <CustomResourceRequest, ILambdaContext, Task <CustomResourceResponse> > Create = async(request, context) =>
            {
                try
                {
                    //AmazonElasticTranscoderConfig Config = new AmazonElasticTranscoderConfig();
                    //IAmazonElasticTranscoder Client = new AmazonElasticTranscoderClient(Config);
                    Mock <IAmazonElasticTranscoder> mockClient = new Mock <IAmazonElasticTranscoder>();
                    mockClient.Setup(x => x.CreatePipelineAsync(It.IsAny <CreatePipelineRequest>(), default(CancellationToken)))
                    .ReturnsAsync(new CreatePipelineResponse()
                    {
                        HttpStatusCode = HttpStatusCode.OK
                    });

                    context.LogInfo("Attempting to create a pipeline.");
                    CreatePipelineRequest  PipelineRequest = JsonConvert.DeserializeObject <CreatePipelineRequest>(JsonConvert.SerializeObject(request.ResourceProperties));
                    CreatePipelineResponse CreateResponse  = await mockClient.Object.CreatePipelineAsync(PipelineRequest);

                    if ((int)CreateResponse.HttpStatusCode < 200 || (int)CreateResponse.HttpStatusCode > 299)
                    {
                        return(new CustomResourceResponse(CustomResourceResponse.RequestStatus.FAILED, $"Received HTTP status code {(int)CreateResponse.HttpStatusCode}.", request));
                    }
                    else
                    {
                        return(new CustomResourceResponse(
                                   CustomResourceResponse.RequestStatus.SUCCESS,
                                   $"See the details in CloudWatch Log Stream: {context.LogStreamName}.",
                                   CreateResponse.Pipeline.Id,
                                   request.StackId,
                                   request.RequestId,
                                   request.LogicalResourceId,
                                   false,
                                   new Dictionary <string, object>()
                        {
                            { "Name", CreateResponse.Pipeline.Name },
                            { "Arn", CreateResponse.Pipeline.Arn },
                            { "Id", CreateResponse.Pipeline.Id }
                        }
                                   ));
                    }
                }
                catch (AmazonElasticTranscoderException e)
                {
                    context.LogError(e);

                    return(new CustomResourceResponse(
                               CustomResourceResponse.RequestStatus.FAILED,
                               e.Message,
                               Guid.NewGuid().ToString(),
                               request.StackId,
                               request.RequestId,
                               request.LogicalResourceId
                               ));
                }
                catch (Exception e)
                {
                    context.LogError(e);

                    return(new CustomResourceResponse(
                               CustomResourceResponse.RequestStatus.FAILED,
                               e.Message,
                               Guid.NewGuid().ToString(),
                               request.StackId,
                               request.RequestId,
                               request.LogicalResourceId
                               ));
                }
            };

            Func <CustomResourceRequest, ILambdaContext, Task <CustomResourceResponse> > Update = async(request, context) =>
            {
                try
                {
                    context.LogInfo("Initiating update for pipeline.");

                    UpdatePipelineRequest PipelineRequest = JsonConvert.DeserializeObject <UpdatePipelineRequest>(JsonConvert.SerializeObject(request.ResourceProperties));

                    ListPipelinesRequest Listing = new ListPipelinesRequest();

                    List <Pipeline>       Pipelines = new List <Pipeline>();
                    ListPipelinesResponse Pipes;

                    AmazonElasticTranscoderConfig Config = new AmazonElasticTranscoderConfig();
                    IAmazonElasticTranscoder      Client = new AmazonElasticTranscoderClient(Config);

                    do
                    {
                        Pipes = await Client.ListPipelinesAsync(Listing);

                        Pipelines.AddRange(Pipes.Pipelines.Where(x => x.Name.Equals(request.ResourceProperties["Name"] as string) &&
                                                                 x.InputBucket.Equals(request.ResourceProperties["InputBucket"]) &&
                                                                 x.Role.Equals(request.ResourceProperties["Role"])
                                                                 ));
                    } while (Pipes.NextPageToken != null);

                    if (Pipelines.Count > 1)
                    {
                        context.LogWarning($"{Pipelines.Count} pipelines were found matching the Name, InputBucket, and Role specified.");
                    }

                    if (Pipelines.Count > 0)
                    {
                        PipelineRequest.Id = Pipelines.First().Id;

                        UpdatePipelineResponse UpdateResponse = await Client.UpdatePipelineAsync(PipelineRequest);

                        if ((int)UpdateResponse.HttpStatusCode < 200 || (int)UpdateResponse.HttpStatusCode > 299)
                        {
                            return(new CustomResourceResponse(CustomResourceResponse.RequestStatus.FAILED, $"Received HTTP status code {(int)UpdateResponse.HttpStatusCode}.", request));
                        }
                        else
                        {
                            return(new CustomResourceResponse(
                                       CustomResourceResponse.RequestStatus.SUCCESS,
                                       $"See the details in CloudWatch Log Stream: {context.LogStreamName}.",
                                       request,
                                       false,
                                       new Dictionary <string, object>()
                            {
                                { "Name", UpdateResponse.Pipeline.Name },
                                { "Arn", UpdateResponse.Pipeline.Arn },
                                { "Id", UpdateResponse.Pipeline.Id }
                            }
                                       ));
                        }
                    }
                    else
                    {
                        return(new CustomResourceResponse(
                                   CustomResourceResponse.RequestStatus.FAILED,
                                   "No pipelines could be found with the matching characteristics.",
                                   request
                                   ));
                    }
                }
                catch (AmazonElasticTranscoderException e)
                {
                    return(new CustomResourceResponse(
                               CustomResourceResponse.RequestStatus.FAILED,
                               e.Message,
                               request
                               ));
                }
                catch (Exception e)
                {
                    return(new CustomResourceResponse(
                               CustomResourceResponse.RequestStatus.FAILED,
                               e.Message,
                               request
                               ));
                }
            };

            Func <CustomResourceRequest, ILambdaContext, Task <CustomResourceResponse> > Delete = async(request, context) =>
            {
                try
                {
                    context.LogInfo("Attempting to delete a pipeline.");

                    ListPipelinesRequest Listing = new ListPipelinesRequest();

                    List <Pipeline>       Pipelines = new List <Pipeline>();
                    ListPipelinesResponse Pipes;

                    AmazonElasticTranscoderConfig Config = new AmazonElasticTranscoderConfig();
                    IAmazonElasticTranscoder      Client = new AmazonElasticTranscoderClient(Config);

                    do
                    {
                        Pipes = await Client.ListPipelinesAsync(Listing);

                        Pipelines.AddRange(Pipes.Pipelines.Where(x => x.Name.Equals(request.ResourceProperties["Name"] as string) &&
                                                                 x.InputBucket.Equals(request.ResourceProperties["InputBucket"]) &&
                                                                 x.Role.Equals(request.ResourceProperties["Role"])
                                                                 ));
                    } while (Pipes.NextPageToken != null);

                    if (Pipelines.Count > 1)
                    {
                        context.LogWarning($"{Pipelines.Count} pipelines were found matching the Name, InputBucket, and Role specified.");
                    }

                    if (Pipelines.Count > 0)
                    {
                        DeletePipelineRequest PipelineRequest = new DeletePipelineRequest()
                        {
                            Id = Pipelines.First().Id
                        };

                        DeletePipelineResponse DeleteResponse = await Client.DeletePipelineAsync(PipelineRequest);

                        if ((int)DeleteResponse.HttpStatusCode < 200 || (int)DeleteResponse.HttpStatusCode > 299)
                        {
                            return(new CustomResourceResponse(CustomResourceResponse.RequestStatus.FAILED, $"Received HTTP status code {(int)DeleteResponse.HttpStatusCode}.", request));
                        }
                        else
                        {
                            return(new CustomResourceResponse(
                                       CustomResourceResponse.RequestStatus.SUCCESS,
                                       $"See the details in CloudWatch Log Stream: {context.LogStreamName}.",
                                       request,
                                       false
                                       ));
                        }
                    }
                    else
                    {
                        return(new CustomResourceResponse(
                                   CustomResourceResponse.RequestStatus.SUCCESS,
                                   "No pipelines could be found with the matching characteristics.",
                                   request
                                   ));
                    }
                }
                catch (AmazonElasticTranscoderException e)
                {
                    // If the pipeline doesn't exist, consider it deleted
                    if (e.StatusCode == HttpStatusCode.NotFound)
                    {
                        return(new CustomResourceResponse(
                                   CustomResourceResponse.RequestStatus.SUCCESS,
                                   $"See the details in CloudWatch Log Stream: {context.LogStreamName}.",
                                   request
                                   ));
                    }
                    else
                    {
                        return(new CustomResourceResponse(
                                   CustomResourceResponse.RequestStatus.FAILED,
                                   e.Message,
                                   request
                                   ));
                    }
                }
                catch (Exception e)
                {
                    return(new CustomResourceResponse(
                               CustomResourceResponse.RequestStatus.FAILED,
                               e.Message,
                               request
                               ));
                }
            };

            CustomResourceRequest        customResourceRequest = JsonConvert.DeserializeObject <CustomResourceRequest>(Json);
            Mock <ICustomResourceHelper> mockHelper            = new Mock <ICustomResourceHelper>();

            mockHelper.Setup(x => x.PutCustomResourceResponseAsync(It.IsAny <CustomResourceRequest>(), It.IsAny <CustomResourceResponse>()))
            .ReturnsAsync(new CustomResourceResult(customResourceRequest, new CustomResourceResponse(RequestStatus.SUCCESS, "", customResourceRequest), new HttpResponseMessage(HttpStatusCode.OK)));

            ICustomResourceHandler Handler = new CustomResourceFactory(Create, Update, Delete, mockHelper.Object);

            TestLambdaLogger  TestLogger    = new TestLambdaLogger();
            TestClientContext ClientContext = new TestClientContext();

            TestLambdaContext Context = new TestLambdaContext()
            {
                FunctionName    = "ElasticTranscoderPipelineCreation",
                FunctionVersion = "1",
                Logger          = TestLogger,
                ClientContext   = ClientContext,
                LogGroupName    = "aws/lambda/ElasticTranscoderPipeline",
                LogStreamName   = Guid.NewGuid().ToString()
            };

            // ACT

            CustomResourceResult Response = await Handler.ExecuteAsync(customResourceRequest, Context);

            // ASSERT
            Assert.NotNull(Response);
            Assert.NotNull(Response.Response);
            Assert.NotNull(Response.S3Response);
            Assert.True(Response.IsSuccess);
        }