1

I'm writing my first CF stacks and I'm running into failed deploys on the first try of course because I don't know the syntax and available parameters yet fully. I am validating my json and the template itself via the CLI but it can still run into issues at deployment and cause a rollback or failure. Now when it's a brand new stack and not an update, the deployment just fails and I can't update it, I have to completely destroy the stack and redeploy it brand new.

I was wondering how to go about this issue. Even tho the deleted stack is not in the console, the CLI will still list all of the stacks that have been created and destroyed previously and it's just not clean. I can't update the stack of course after fixing the issue that caused it to fail because it's in the failed state, I have to redeploy everything as if it was a completely new stack.

Any thoughts on this? How did you go about creating your first stacks?

1 Answer 1

0

Your first "create" of the stack needs to succeed, if it doesn't it must be deleted. Later updates can fail and be rolled back without having to delete the stack. I tend to delete in the console, but you can of course use "aws cloudformation delete-stack".

I don't bother to list stacks in the CLI, I just use the console, so I don't know what it displays. As soon as a stack is deleted you can create it again. You can detect that state with the command

aws cloudformation wait stack-delete-complete --profile profilename --stack-name stack-name

The key for you could be to deploy a simple stack that you know will deploy, then add the complexity in later. You can do that by commenting out everything except one resource to deploy, which you can copy and paste from an AWS example. Visual Studio Code makes this easy with "Control - Shift - /" combination to comment / uncomment large blocks.

You should considering using YAML formatted CloudFormation, I find it much easier.

1
  • Thank you for the insights. This is actually what I ended up doing by a recommendation from a friend. I deployed a single S3 bucket with no options and started building from there, it worked really well. Indeed I went with YAML as per recommended by the same friend, it really is a ton easier than JSON (except for Lists of Strings, which I still don't get the syntax for lol). Thank you!
    – Chris
    Jun 1, 2020 at 22:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .