aws-toolkit-azure-devops icon indicating copy to clipboard operation
aws-toolkit-azure-devops copied to clipboard

Are Inline defined Parameter types in Azure DevOps Pipeline configuration type safe, when passed in to CloudFormationCreateOrUpdateStack@1?

Open j0nathontayl0r opened this issue 3 years ago • 3 comments

Edit: changed the code to include a simple CloudFormation template that deploys an S3 bucket.

Are Inline defined Parameter types in Azure DevOps Pipeline configuration, correctly passed in to CloudFormationCreateOrUpdateStack@1? Passing in the number type parameter from Azure Pipelines to AWS Toolkit I get the error:

I get the error: ##[error]InvalidParameterType: Expected params.Parameters[1].ParameterValue to be a string

I don't know if the Azure Pipelines service is losing/incorrectly specifying the incorrect parameter type here even though it's explicitly defined as a number or string type. Or if the AWS Toolkit is not parsing the inputs correctly.

Here's my CloudFormation template: cloudformation-template.txt

It takes two parameters as inputs.

  • String Type - String type parameter
  • NumberType - Number type parameter
NumberType:
    Type: Number
    Description: A Number type parameter
    Default: 1

  StringType:
    Type: String
    Description: A string type parameter, captured as a number
    Default: astring

The pipeline that executes the CloudFormation template as attached below, the parameters are also in the code block as follows.

- name: NumberType
  displayName: BucketPrefix
  type: number
  default: 1

- name: StringType
  displayName: StringType
  type: string
  default: "1"

The CloudFormation template will deploy with the default values in the CloudFormation console. But when I try to deploy it with the Azure Pipeline shown below, I get the error: ##[error]InvalidParameterType: Expected params.Parameters[1].ParameterValue to be a string

Pipeline config: pipeline.txt

I've attached the full error output from this step (refer to step.log). pipeline.log

I'm not sure where or how, but it seems the parameter types from the Pipeline are being lost, or not respected by AWS Toolkit. Any suggestions?

j0nathontayl0r avatar May 12 '21 03:05 j0nathontayl0r

Edit: updated original comment with a simpler CloudFormation template. You should be able to execute the Pipeline to deploy the CloudFormation template and replicate the parameter type error I'm shown.

j0nathontayl0r avatar May 12 '21 03:05 j0nathontayl0r

@JDTAY Apologies for the delay here, looks like we're coercing this value into a string: https://github.com/aws/aws-toolkit-azure-devops/blob/master/src/lib/sdkutils.ts#L254

I'm assuming that you're expecting the Adding tag. Key 'ServiceLayerTag', Value '1' lines in your logs to be numeric rather than a string? Regardless, will take a look.

bryceitoc9 avatar Jul 27 '21 16:07 bryceitoc9

No need to apologise @bryceitoc9, I missed your reply too. :)

* InvalidParameterType: Expected params.Parameters[0].ParameterValue to be a string
* InvalidParameterType: Expected params.Parameters[1].ParameterValue to be a string

I haven't been able to cause the same bugs when iterating through tags, only parameters. Since tags should always be a string anyway. I haven't spent the time debugging the toolkit to find the bug and had to re-familiarise myself with how I replicated the issue again today. I'm working my way through the source now.

j0nathontayl0r avatar Aug 22 '21 05:08 j0nathontayl0r