I am trying to create a Budget in an AWS account by deploying the following AWS CloudFormation Template (with Azure DevOps):
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}
But get the following error:
##[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
I have tried changing the Type
from Number
to String
but with the same error.
Also tried resolving the parameter by the other intrinsic function !Ref
without luck.
This is how I set the parameters for the CloudFormation template from a azure-pipelines.yml file:
variables:
email_recipients: "[email protected]"
budget_amount: 100
amount_threshold: 80
And this is how they get passed them to 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
question from:
https://stackoverflow.com/questions/66050456/how-to-pass-cloudformation-parameter-as-type-number 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…