aws / aws/aws-toolkit-azure-devops

'Expected params.Parameters to be an Array' When Using CloudFormationCreateOrUpdateStack@1 Task with Template Parameters File

Open
#554 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
258
Forks
114
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

I receive the following error when I attempt to create or update a stack using the CloudFormationCreateOrUpdateStack@1 task and specifying a template parameters file:

```
Loading template parameters file '/home/vsts/work/1/a/CloudFormation/parameters/parameters.dev.json'
##[debug]Attempting parse as json content
##[debug]Successfully parsed template parameters
Successfully loaded template parameters
Setting capability CAPABILITY_IAM for stack
Setting capability CAPABILITY_NAMED_IAM for stack
Adding tag. Key 'key1', Value 'value1'
Adding tag. Key 'key2', Value 'value2'
Adding tag. Key 'application', Value 'pipeline-poc'
Adding tag. Key 'environment', Value 'dev'
##[debug]AWS updateStack request ID: undefined
Stack update request failed with error: 'Expected params.Parameters to be an Array' { InvalidParameterType: Expected params.Parameters to be an Array
##[debug]task result: Failed
at constructor.fail (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:29:201)
at constructor.validateType (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:29:3508)
##[error]InvalidParameterType: Expected params.Parameters to be an Array
##[debug]Processed: ##vso[task.issue type=error;]InvalidParameterType: Expected params.Parameters to be an Array
at constructor.validateList (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:29:975)
at constructor.validateMember (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:29:833)
at constructor.validateStructure (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:29:595)
at constructor.validateMember (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:29:785)
at constructor.validate (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:27:3483)
at constructor. (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:16:115446)
at constructor.callListeners (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:16:86263)
at p (/home/vsts/work/_tasks/CloudFormationCreateOrUpdateStack_7ef7cdfa-aa45-42c5-93c8-d7603643dd99/1.14.0/CloudFormationCreateOrUpdateStack.js:16:86148)
message: 'Expected params.Parameters to be an Array',
code: 'InvalidParameterType',
time: 2024-06-21T19:28:38.573Z }

```
Here is the task's definition:
```yaml
- task: CloudFormationCreateOrUpdateStack@1
inputs:
awsCredentials: $(awsServiceConnection)
regionName: "us-east-1"
stackName: "pipeline-poc-stack"
templateSource: "s3"
s3BucketName: "bucket-name"
s3ObjectKey: "main.template.yaml"
templateParametersSource: "file"
templateParametersFile: "$(Build.ArtifactStagingDirectory)/CloudFormation/parameters/parameters.dev.json"
tags: |
key1=value1
key2=value2
application=pipeline-poc
environment=dev
```
Here are the contents of `parameters.dev.json`, formatted according to the [task's documentation](https://docs.aws.amazon.com/vsts/latest/userguide/cloudformation-create-update.html#parameters):
```json
[
{
"ParameterKey": "ClassB",
"ParameterValue": "123"
}
]
```
I have also tried the other two parameter formats that are provided in the [AWS CLI documentation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/deploy/index.html#supported-json-syntax):
```json
[
"ClassB=123"
]
```
```json
[
"Parameters": {
"ClassB": "123"
}
]
```
All three formats seem to be supported by the AWS CLI but error out in Azure DevOps.

When I attempt to use the exact same parameters file with the AWS CLI, the deployment is successful and the parameters are applied:
```bash
$ aws cloudformation deploy --stack-name pipeline-poc-dev-stack --template-file templates/main.template.yaml --s3-bucket bucket-name --parameter-overrides file://./parameters/parameters.dev.json --no-execute-changeset

Waiting for changeset to be created..
Changeset created successfully. Run the following command to review changes:
aws cloudformation describe-change-set --change-set-name arn:aws:cloudformation:us-east-1:123456789012:changeSet/awscli-cloudformation-package-deploy-8526790111/ba3fa778-df9f-425f-acd9-0ccbca7d1b07

$ aws cloudformation describe-change-set --change-set-name arn:aws:cloudformation:us-east-1:123456789012:changeSet/awscli-cloudformation-package-deploy-8526790111/ba3fa778-df9f-425f-acd9-0ccbca7d1b07

{
"Changes": [
{
"Type": "Resource",
"ResourceChange": {
"Action": "Add",
"LogicalResourceId": "vpcStack",
"ResourceType": "AWS::CloudFormation::Stack",
"Scope": [],
"Details": []
}
}
],
"ChangeSetName": "awscli-cloudformation-package-deploy-8526790111",
"ChangeSetId": "arn:aws:cloudformation:us-east-1:123456789012:changeSet/awscli-cloudformation-package-deploy-8526790111/ba3fa778-df9f-425f-acd9-0ccbca7d1b07",
"StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/pipeline-poc-dev-stack/7954f9ef-9334-400f-b7cf-828645105348",
"StackName": "pipeline-poc-dev-stack",
"Description": "Created by AWS CLI at 2024-06-21T19:26:53.123725 UTC",
"Parameters": [
{
"ParameterKey": "ClassB",
"ParameterValue": "123"
}
],
"CreationTime": "2024-06-21T19:26:54.435000+00:00",
"ExecutionStatus": "AVAILABLE",
"Status": "CREATE_COMPLETE",
"StatusReason": null,
"NotificationARNs": [],
"RollbackConfiguration": {},
"Capabilities": [],
"Tags": null,
"ParentChangeSetId": null,
"IncludeNestedStacks": false,
"RootChangeSetId": null,
"OnStackFailure": null,
"ImportExistingResources": null
}
```
**To reproduce**

Steps to reproduce the behavior:
1. Create a pipeline that uses the CloudFormationCreateOrUpdateStack@1 task.
2. Specify a template parameters file, in addition to the template file, in the task's inputs.
3. Execute the task.

**Expected behavior**

The CloudFormationCreateOrUpdateStack@1 passes along the parameters as defined in the template parameters file and successfully creates or updates the stack.

**Your Environment**

- Azure DevOps Services
- Azure DevOps version: Dev19.M240.1 (AzureDevOps_M240_20240619.21)
- AWS Toolkit for Azure DevOps version: 1.14.0 (Latest)

Contributor guide

Open the contributing guide

Research direction

Start at the CloudFormationCreateOrUpdateStack@1 task's template-parameter-file parsing and the updateStack request. Reproduce the failure with the documented JSON examples, then verify that the parameters are passed as expected and the stack creation or update succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, azure, typescript
Domain
cloud, devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.