JamesMatson
JamesMatson

Reputation: 2932

Azure DevOps Cloudformation update stack fails using parameters file (##[error]ValidationError: Parameters: do not exist in the template)

I have an Azure DevOps build pipeline that uses the AWS CloudFormation update stack task. The CF Template refers to parameters stored in a parameters file. When deploying, the build fails as the task cannot find the parameters that I have referenced in my parameters file.

E.g. The file itself:

[
  {
    "ParameterKey": "EnvironmentParameter",
    "ParameterValue": "dev"
  },
  {
    "ParameterKey": "DBHost",
    "ParameterValue": "xxxxxxxxx.amazonaws.com"
  }
]

The task references my template parameters file:

enter image description here

Here is the reference in the template itself:

"dbhostparameter"      : {
    "Type" : "AWS::SSM::Parameter",
    "Properties" : {
        "Name" : "/LCS/Database/host",
        "Type" : "String",
        "Value" : {
            "Fn::Sub" : [
                "${env}", 
                {
                    "env" : {
                        "Ref" : "DBHost"
                    }
                }
            ]
        },

And here is the failure output (which shows it successfully loads the template parameters file)

2020-06-29T22:37:36.2709027Z Updating stack with template file d:\a\1\s\parameters\parameters.template
2020-06-29T22:37:36.2709794Z Loading template file from 'd:\a\1\s\parameters\parameters.template'
2020-06-29T22:37:36.2713615Z Loading template parameters file 'd:\a\1\s\parameters_ssm_dev.json'
2020-06-29T22:37:36.2715581Z Successfully loaded template parameters
2020-06-29T22:37:36.2716132Z Setting capability CAPABILITY_IAM for stack
2020-06-29T22:37:36.2716592Z Setting capability CAPABILITY_NAMED_IAM for stack
2020-06-29T22:37:36.4072822Z Stack update request failed with error: 'Parameters: [DBHost] do not exist in the template' { ValidationError: Parameters: [DBHost] do not exist in the template
2020-06-29T22:37:36.4074350Z     at constructor.extractError (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:87664)
2020-06-29T22:37:36.4077291Z     at constructor.callListeners (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:95965)
2020-06-29T22:37:36.4078548Z     at constructor.emit (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:95675)
2020-06-29T22:37:36.4079603Z     at constructor.emitEvent (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:167913)
2020-06-29T22:37:36.4080477Z     at constructor.e (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:163452)
2020-06-29T22:37:36.4083390Z     at r.runTo (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:169755)
2020-06-29T22:37:36.4084174Z     at d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:169961
2020-06-29T22:37:36.4086749Z     at constructor.<anonymous> (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:163722)
2020-06-29T22:37:36.4087643Z     at constructor.<anonymous> (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:167969)
2020-06-29T22:37:36.4088469Z     at constructor.callListeners (d:\a\_tasks\CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99\1.7.0\CloudFormationCreateOrUpdateStack.js:2:96071)
2020-06-29T22:37:36.4089053Z   message: 'Parameters: [DBHost] do not exist in the template',
2020-06-29T22:37:36.4089378Z   code: 'ValidationError',

Upvotes: 3

Views: 2274

Answers (2)

Marcin
Marcin

Reputation: 238747

Based on the comments.

The issue was missing Parameters section section.

The solution was to add the section.

Upvotes: 3

JamesMatson
JamesMatson

Reputation: 2932

Was missing the Parameters section of the actual CF Template. Without this, there was no reference point for the parameters file, therefore, the deployment failed.

Upvotes: 2

Related Questions