Exemple #1
0
        public static async Task <bool> Deploy(ILogger log, Context context)
        {
            var stack    = Build();
            var template = context.JsonStackSerializer.Serialize(stack);
            var cwd      = Path.Combine(context.Config.BuildPath, "src", Namespace);

            var baseStack = await Cloudformation.GetExistingStackAsync(context.Cloudformation, BaseStack.Name(context.Config)).ConfigureAwait(false);

            if (baseStack == null)
            {
                log.Error("Deploy the {stackName} stack first.", BaseStack.Name(context.Config));
                return(false);
            }

            var bucket = baseStack.GetStackOutput("DeploymentsBucket");
            var role   = baseStack.GetStackOutput("CloudFormationServiceRole");

            var parameters = new Dictionary <string, string>
            {
                ["Environment"]       = context.Config.Env,
                ["DeploymentsBucket"] = bucket
            };

            return(await LambdaDeployer.DeployStackAsync(log, context, Name(context.Config), template, cwd, parameters, bucket, role).ConfigureAwait(false));
        }
Exemple #2
0
        public static async Task <bool> Destroy(ILogger log, Context context)
        {
            var baseStack = await Cloudformation.GetExistingStackAsync(context.Cloudformation, BaseStack.Name(context.Config)).ConfigureAwait(false);

            if (baseStack == null)
            {
                log.Error("Deploy the {stackName} stack first.", BaseStack.Name(context.Config));
                return(false);
            }

            var role   = baseStack.GetStackOutput("CloudFormationServiceRole");
            var bucket = baseStack.GetStackOutput("DeploymentsBucket");

            try
            {
                await AmazonS3Util.DeleteS3BucketWithObjectsAsync(context.S3, bucket);
            }
            catch (Exception ex)
            {
                log.Error(ex, "Error deleting S3 bucket {bucket}. Message: {message}", bucket, ex.Message);
                return(false);
            }

            var result = await Cloudformation.DeleteStackAsync(log, context.Cloudformation, Name(context.Config), role);

            return(result);
        }
Exemple #3
0
        public static async Task <bool> Destroy(ILogger log, Context context)
        {
            var baseStack = await Cloudformation.GetExistingStackAsync(context.Cloudformation, BaseStack.Name(context.Config)).ConfigureAwait(false);

            if (baseStack == null)
            {
                log.Error("Deploy the {stackName} stack first.", BaseStack.Name(context.Config));
                return(false);
            }

            var role = baseStack.GetStackOutput("CloudFormationServiceRole");

            var result = await Cloudformation.DeleteStackAsync(log, context.Cloudformation, Name(context.Config), role);

            return(result);
        }