When my azure-pipelines.yml file defines and passes down a variable with an integer-type value to a AWS Cloudformation template as a parameter, the template fails to use that parameter as a Number type.
This causes my Cloudformation stack to fail. How can I instruct the Azure pipeline to keep the integer type ? Here is the variable definitions in azure-pipelines.yml
(The problematic ones are budget_amount
and amount_threshold
):
variables:
email_recipients: "[email protected]"
budget_amount: 100
amount_threshold: 80
Then sending them down to a azure-pipelines template deploy_env.yml
:
- template: azure-pipelines/stages/deploy_env.yml
parameters:
stage_name: deploy
aws_credentials: $(aws_dev_credentials)
aws_region: $(aws_region)
user_initials: $(user_initials)
email_recipients: $(email_recipients)
budget_amount: $(budget_amount)
amount_threshold: $(amount_threshold)
And the passing of them to the Cloudformation template:
- task: CloudFormationCreateOrUpdateStack@1
displayName: budgets
inputs:
awsCredentials: ${{parameters.aws_credentials}}
regionName: ${{parameters.aws_region}}
stackName: ${{parameters.stack_name}}
templateSource: 'file'
templateFile: $(Pipeline.Workspace)/${{parameters.project_name}}-templates/budgets.yml
templateParametersSource: "inline"
templateParameters: |
- ParameterKey: EmailRecipients
ParameterValue: ${{parameters.email_recipients}}
- ParameterKey: BudgetAmount
ParameterValue: ${{parameters.budget_amount}}
- ParameterKey: AmountThreshold
ParameterValue: ${{parameters.amount_threshold}}
useChangeSet: true
changeSetName: 'role-changeset'
captureStackOutputs: asVariables
captureAsSecuredVars: false
The Cloudformation template budgets.yml
:
Parameters:
EmailRecipients:
Type: String
Description: Name of the Email Recipient
BudgetAmount:
Type: Number
Default: 500
Description: Budget Amount
AmountThreshold:
Type: Number
Default: 80
Description: Budget Threshold
Resources:
BudgetExample:
Type: "AWS::Budgets::Budget"
Properties:
Budget:
BudgetLimit:
Amount: !Sub ${BudgetAmount}
Unit: USD
TimeUnit: MONTHLY
BudgetType: COST
NotificationsWithSubscribers:
- Notification:
NotificationType: ACTUAL
ComparisonOperator: GREATER_THAN
Threshold: !Sub ${AmountThreshold}
Subscribers:
- SubscriptionType: EMAIL
Address: !Sub ${EmailRecipients}
The error thrown is:
##[error]MultipleValidationErrors: There were 2 validation errors:
* InvalidParameterType: Expected params.Parameters[1].ParameterValue to be a string
* InvalidParameterType: Expected params.Parameters[2].ParameterValue to be a string
question from:
https://stackoverflow.com/questions/66061022/pass-azure-pipeline-variable-to-aws-cloudformation-template-as-parameter-with-ty 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…