Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation, AWS Lambda: Ignore Parameter from Old Template

I am deploying a .Net Core Web API project to AWS Lambda. It works, but I have the following issue:

Previous Template Contains Parameter No Longer Used

A previous deployment of our Lambda created a CloudFormation template with a defined Parameter. For discussion, let's call it "BadParameter".

Now, we don't want to use that parameter anymore. We've updated our serverless.template so that it does not have that parameter anymore.

Now, all our deployments (using the update template) fail with the message:

Error creating CloudFormation change set: Parameters: [BadParameter] do not exist in the template

I can fix this by downloading the template from CloudFormation, manually removing the parameter, then re-uploading the template, but that is tedious and error-prone.

Is there some way I can specify in my new template that the old parameter should be deleted?

like image 712
SouthShoreAK Avatar asked Aug 22 '26 15:08

SouthShoreAK


1 Answers

I ran into this too. I'm going to give details on what I saw and what I did to fix it because my situation doesn't seem to be exactly the same as SouthShoreAK's situation, but is close enough that I'm certain we are experiencing the same issue.

Situation and Error

parent-template.yml is a CloudFormation template which is being deployed as part of the CI/CD process. Inside this template are several AWS::CloudFormation::StackSet resources, child-template-1.yml, child-template-2.yml, etc. Each child-template-*.yml StackSet resource is deploying into multiple accounts.

I was receiving this error on one of the AWS::CloudFormation::StackSet resources:

Parameters: [OldParameter1, OldParameter2] do not exist in the template

Changes Which Caused the Error

Recent changes were:

  1. In child-template-1.yml I removed these two parameters, OldParameter1 and OldParameter2.
  2. In parent-template.yml in one of the AWS::CloudFormation::StackSet resources I had been passing in values for OldParamter1 and OldParameter2. I removed these two ParameterKey-ParameterValues. In other words, I stopped providing these parameters as inputs to the child template.

Steps Taken

  1. I went into child-template-1.yml and added the parameters OldParameter1 and OldParameter2 back into the template.
  2. I gave both parameters a default value, "Dummy".
  3. I re-deployed with aws cloudformation deploy
  4. I went into child-template-1.yml and removed the parameters OldParameter1 and OldParameter2.
  5. I re-deployed

At that point, the parameters have been removed from the templates. I do not know why this is necessary; it seems like a bug in CloudFormation to me.

like image 119
Gregory Ledray Avatar answered Aug 25 '26 09:08

Gregory Ledray