Exemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     awsLambdaClient.Dispose();
     fileTransferUtility.Dispose();
     awsS3Client.Dispose();
 }
Exemplo n.º 2
0
        /// <inheritdoc />
        protected override void Dispose(bool disposing)
        {
            if (!_disposed && disposing)
            {
                lambdaClient.Dispose();

                _disposed = true;
            }
            base.Dispose(disposing);
        }
Exemplo n.º 3
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (client != null)
                    {
                        client.Dispose();
                        client = null;
                    }
                }

                disposedValue = true;
            }
        }
Exemplo n.º 4
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            // Dispose of managed resources here.
            if (disposing)
            {
                TearDownAsync().GetAwaiter().GetResult();

                _lambdaClient?.Dispose();
                _iamClient?.Dispose();
            }

            // Dispose of any unmanaged resources not wrapped in safe handles.
            _disposed = true;
        }
Exemplo n.º 5
0
        static async Task <(string topicArn, Func <Task> cleanup)> CreateLambda(LambdaCreationOptions lambdaCreationOptions)
        {
            var    cleanup = new List <Func <Task> >();
            var    log     = lambdaCreationOptions.Verbose;
            string publishTopic;


            var lambdaClient = new AmazonLambdaClient();
            var snsClient    = new AmazonSimpleNotificationServiceClient();
            var iamClient    = new AmazonIdentityManagementServiceClient();

            cleanup.Add(() =>
            {
                lambdaClient.Dispose();
                snsClient.Dispose();
                iamClient.Dispose();
                return(Task.CompletedTask);
            });


            try
            {
                log("Creating IAM Role");
                var(roleArn, _, roleCleanup) =
                    await CreateRole(iamClient, lambdaCreationOptions.Timestamp, lambdaCreationOptions.Name,
                                     lambdaCreationOptions.CancellationToken);

                cleanup.Add(roleCleanup);

                log("Creating Function");
                var(functionArn, _, functionCleanup) =
                    await CreateFunction(roleArn,
                                         lambdaClient,
                                         lambdaCreationOptions);

                cleanup.Add(functionCleanup);

                log("Creating SNS Topic");
                var(topicArn, topicCleanup) =
                    await CreateTopic(snsClient, lambdaCreationOptions.Timestamp, lambdaCreationOptions.Name,
                                      lambdaCreationOptions.CancellationToken);

                cleanup.Add(topicCleanup);
                publishTopic = topicArn;

                log("Creating SNS Subscription");
                var subCleaner = await Subscribe(snsClient, functionArn, topicArn, lambdaCreationOptions.CancellationToken);

                cleanup.Add(subCleaner);

                log("Permissioning SNS to execute the function");
                var permCleanup = await AddExecutionFromSnsPermission(lambdaClient, functionArn, topicArn,
                                                                      lambdaCreationOptions.CancellationToken);

                cleanup.Add(permCleanup);
            }
            catch (Exception)
            {
                log("Cleaning up resources");
                await Cleanup(cleanup);

                throw;
            }

            return(publishTopic, () => Cleanup(cleanup));
        }