Example #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));
        }
Example #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);
        }
Example #3
0
        public static async Task <bool> Deploy(ILogger log, Context context)
        {
            var parameters = new Dictionary <string, string>
            {
                ["Environment"] = context.Config.Env
            };

            Stack stack = Build(context.Config);

            var template = context.JsonStackSerializer.Serialize(stack);

            var result = await Cloudformation.DeployStackAsync(log, context.Cloudformation, DateTime.Now.Ticks, Name(context.Config), context.Config.Tags, parameters, template);

            return(result != DeployStackResult.Failed);
        }
Example #4
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);
        }