I'm trying to delete a stack on Cloudformation but it return a rollback UPDATE_ROLLBACK_COMPLETE.
I have removed all dependencies from the template and all the outputs as well but the error persists.
Is there a way to force a delete? or even better just to delete the outpus?
I removed the outputs from the template and ran update-stack but without success. The error persist.
Have you created a circular reference issue? I’ve run into this in the past, even referencing an export from the current stack in that stack (easy to do when you make updates). The solution is to modify the stacks that are referencing The export, and removing the resource(s) that has the reference. Update the stack with the reference(s) removed and then you can do the delete. If you no longer have the start template you can modify it in the console by editing the existing stack, or you can copy the template from the console and edit it elsewhere. Any way you go about it, the key is updating the stack(s) with ImportValue references removed, then deleting the stack(s).
Related
I'm importing an ARN from another stack with the cdk.Fn.importValue method. This works fine if I know that the output value is always present, but I don't know how to handle the case when the value I try to import is optional.
How can I get something similar to: (checking if the value exists before importing it)
if(value exists) {
cdk.Fn.importValue("value")
}
AFAIK there currently is no way in CDK to perform a lookup of a CloudFormation exports during synthesis time.
If you don't want to fiddle around with performing CloudFormation API calls with the aws-sdk before creating the CDK stack, in my opinion the most elegant way to share conditional values between stacks, is to use SSM parameters instead of CloudFormation exports.
SSM parameters can be looked up during synthesis time. See docs: https://docs.aws.amazon.com/cdk/v2/guide/get_ssm_value.html
So, with StringParameter.valueFromLookup you are then able to only use the value if it exists (IIRC the method throws an error if the parameter doesn't exist, so try-catch is your friend here, but not 100% sure).
To help people create a Cloudformation stack, I can generate links to parameterized Cloudformation templates:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stacks-quick-create-links.html
Question: Is there a way to generate another link to update the previously created Cloudformation stack?
What I tried and what doesn't work:
I generated a link to create stack "ABC" using template Template1.
I generated a link to create stack "ABC", with a slightly modified template Template2.
What happens is that Cloudformation creates the first "ABC" stack based on Template1, but then complains that the "ABC" stack already exists when trying to create a stack with the same name using Template2.
I kind of expected this behavior, but I assumed that -- since stack names are unique -- that it would offer to apply updates instead of trying to create (and fail) to create the stack.
If I submit two change sets one right after the other, is the first guaranteed to complete before the second?
It is a bit unclear what you mean by submitting a changeset. If you're talking about creating changesets, then this shouldn't be a problem, since it won't actually execute anything on your stack.
If you're talking about executing a changeset on a stack, CloudFormation will probably not accept the second changeset you have submitted since you cannot update a stack that has an in-progress status.
After the first changeset is executed successfully, the second changeset will automatically be removed as it is no longer valid for the stack after the update has been applied. Hence, if you try to use the ID of the old changeset, you will get a ChangeSetNotFound error.
What I'm sure won't happen, is CloudFormation will execute both changesets sequentially.
My application currently intakes cloudformation jsons/yamls and create stacks out of them. Currently, the struggles we are having are concerning the updating, since it's impossible to update a stack that contains custom-named resources.
My question is the following: is there a clean/smart way to remove custom names from those templates, and either service-aware or service-agnostic?
I've considered some regex/replacement but I wanted to see if there were a smarter way.
TIA
I have a question regarding Fn::ImportValue function in CloudFormation. For example, one SNS Topic from Stack 1 is imported in Stack 2. What happens, if I try to change name of this topic in Stack 1? Will it trigger redeployment of Stack 2? If not, will the changes be recognized anyhow by resources created by Stack 2? Thank you.
Kind regard
Oleksii
Your update probably will fail, as you can't modify exported values if they are imported by other stacks. From docs:
After another stack imports an output value, you can't delete the stack that is exporting the output value or modify the exported output value. All of the imports must be removed before you can delete the exporting stack or modify the output value.