serverless-aws-alias icon indicating copy to clipboard operation
serverless-aws-alias copied to clipboard

Invalid tag when deploying masterAlias

Open kortac opened this issue 5 years ago • 4 comments
trafficstars

When deploying masterAlias with command

SLS_DEBUG=* sls deploy --verbose --masterAlias

it fails with the following error:

ServerlessError: Expected params.Tags[1].Value to be a string
      at /Users/***/WebstormProjects/***/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:327:27
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:94:5)

Reason for this is because serverless-aws-alias tries to add a tag with a boolean value:

Serverless: [AWS cloudformation undefined 0.004s 0 retries] createStack({
  StackName: '***',
  OnFailure: 'DELETE',
  Capabilities: [ 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM', [length]: 2 ],
  Parameters: [ [length]: 0 ],
  TemplateBody: '{"AWSTemplateFormatVersion":"2010-09-09","Description":"Alias stack for *** (true)","Resources":{"ServerlessAliasLogGroup":{"Type":"AWS::Logs::LogGroup","Properties":{"LogGroupName":"/serverless/***-true","RetentionInDays":7}}},"Outputs":{"ServerlessAliasName":{"Description":"Alias the stack represents.","Value":"true"},"ServerlessAliasLogGroup":{"Description":"Log group for alias.","Value":{"Ref":"ServerlessAliasLogGroup"},"Export":{"Name":"***-true-LogGroup"}}}}',
  Tags: [
    { Key: 'STAGE', Value: 'production' },
    { Key: 'ALIAS', Value: true },
    [length]: 2
  ]
})

Versions: serverless 1.61.2 serverless-aws-alias 1.8.0 serverless-domain-manager 4.0.0

kortac avatar May 11 '20 20:05 kortac

Applying this patch file fixes the error:

diff --git a/node_modules/serverless-aws-alias/lib/createAliasStack.js b/node_modules/serverless-aws-alias/lib/createAliasStack.js
index adadc43..2a674f0 100644
--- a/node_modules/serverless-aws-alias/lib/createAliasStack.js
+++ b/node_modules/serverless-aws-alias/lib/createAliasStack.js
@@ -16,7 +16,7 @@ module.exports = {
 
 		this._serverless.cli.log(`Creating Alias Stack '${this._alias}' ...`);
 		const stackName = `${this._provider.naming.getStackName()}-${this._alias}`;
-		let stackTags = { STAGE: this._options.stage, ALIAS: this._alias };
+		let stackTags = { STAGE: this._options.stage, ALIAS: this._alias.toString() };
 
 		// Merge additional stack tags
 		if (_.isObject(this._serverless.service.provider.stackTags)) {
diff --git a/node_modules/serverless-aws-alias/lib/updateAliasStack.js b/node_modules/serverless-aws-alias/lib/updateAliasStack.js
index 15e7ec2..76b0c80 100644
--- a/node_modules/serverless-aws-alias/lib/updateAliasStack.js
+++ b/node_modules/serverless-aws-alias/lib/updateAliasStack.js
@@ -13,7 +13,7 @@ module.exports = {
 		this._serverless.cli.log('Creating alias stack...');
 
 		const stackName = `${this._provider.naming.getStackName()}-${this._alias}`;
-		let stackTags = { STAGE: this._options.stage, ALIAS: this._alias };
+		let stackTags = { STAGE: this._options.stage, ALIAS: this._alias.toString() };
 		const templateUrl = `https://s3.amazonaws.com/${this.bucketName}/${this._serverless.service.package.artifactDirectoryName}/compiled-cloudformation-template-alias.json`;
 		// Merge additional stack tags
 		if (_.isObject(this._serverless.service.provider.stackTags)) {
@@ -49,7 +49,7 @@ module.exports = {
 
 		this.serverless.cli.log('Updating alias stack...');
 		const stackName = `${this._provider.naming.getStackName()}-${this._alias}`;
-		let stackTags = { STAGE: this._options.stage, ALIAS: this._alias };
+		let stackTags = { STAGE: this._options.stage, ALIAS: this._alias.toString() };
 
 		// Merge additional stack tags
 		if (_.isObject(this._serverless.service.provider.stackTags)) {

kortac avatar May 11 '20 20:05 kortac

I got the same issues too on serverless-aws-alias 1.8.0. think this bug will affect not only me and issues writer but also many users using 1.8.0 version. 😭

m0ai avatar Jun 03 '20 10:06 m0ai

@SpaceHeroGuide, how thinking about considering opening a pull request for it?

m0ai avatar Jun 03 '20 10:06 m0ai

Same issue

njdullea avatar Jan 25 '21 23:01 njdullea