sst: Default tags for SNS problem

Heyall! I’m using SST for lots of projects in Prod since early 2022, and everything’s flawless so far. Yesterday our builds (for dev and PRs - prob PROD as well [haven’t tested it yet]) started to break in one part of the code that was not changed in a long time. We have a very simple SNS topic in our stack:

const guestEventTopic = new sst.Topic(this, 'guest-event-sns', {
    cdk: {
      topic: {
        topicName: RESOURCE.SNS.GUEST_EVENT,
      },
    },
  });

And since yesterday we are getting this error:

***stackname*** failed: Properties validation failed for resource guesteventsnsTopic1FRD23DS with message:
#/Tags/0/Key: failed validation constraint for keyword [pattern]
#/Tags/1/Key: failed validation constraint for keyword [pattern]

Is there any known problem around this? Or am I missing something?


Investigation points so far: 1 - There are only 2 default tags created for all the resources: sst:app and sst:stack.

2 - Version used:

"@aws-cdk/aws-apigatewayv2-alpha": "2.24.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "2.24.0-alpha.0",
"@serverless-stack/cli": "1.2.18",
"@serverless-stack/resources": "1.2.18",
"aws-cdk-lib": "2.24.0"

Tried with latest versions as well, but no luck:

"@aws-cdk/aws-apigatewayv2-alpha": "2.32.0-alpha.0",
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "2.32.0-alpha.0",
"@serverless-stack/cli": "1.7.0",
"@serverless-stack/resources": "1.7.0",
"aws-cdk-lib": "2.32.0"

3 - For local deployment, I tried to modify the library’s synth method of the resources/src/App.ts and change this part of the code:

//cdk.Tags.of(child).add("sst:app", this.name);
//cdk.Tags.of(child).add("sst:stage", this.stage);
cdk.Tags.of(child).add("sst_app", this.name);
cdk.Tags.of(child).add("sst_stage", this.stage);

Since as mentioned in the tags doc: The key name of the tag. You can specify a value that's 1 to 128 Unicode characters in length and can't be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -. After this modification, the deployment was successful.

Error happening in Seed.run and local.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 15 (5 by maintainers)

Most upvoted comments

We are running into the same error all of a sudden trying to deploy our sst app using sst deploy command. Specifically any resource of type AWS::SNS::Topic is failing to be created.

❌  Stack failed: Properties validation failed for resource ______TopicD47D1D42 with message:
#/Tags/0/Key: failed validation constraint for keyword [pattern]
#/Tags/1/Key: failed validation constraint for keyword [pattern]

was having the same problem too randomly. I was able to reproduce consistently after I added additional tags to the app in the main function. As a workaround I ended up removing the tags and that allowed me to deploy again.

import { App } from "@serverless-stack/resources";
import { Tags } from "aws-cdk-lib";

import { ApiStack } from "./ApiStack";
import { AuthStack } from "./AuthStack";
import { StorageStack } from "./StorageStack";

export default function main(app: App) {
  app.setDefaultFunctionProps({
    runtime: "nodejs16.x",
    srcPath: "services",
    bundle: {
      format: "esm",
    },
  });

  Tags.of(app).add("sst-app", "summari-sst");
  Tags.of(app).add("sst-stage", `${app.stage}`);

  // these tags are added by default and does not follow the allowed characters for tagging in aws shared resource tags
  Tags.of(app).remove("sst:app");
  Tags.of(app).remove("sst:stage");

  app.stack(StorageStack).stack(AuthStack).stack(ApiStack);
}

Is it still happening for you @asqwrd ? It went back to normal for me after a day 🤯

removing the tags actually messed up the console so that might not be the best solution. Taking all the Tags removal code out fixes it and it looks like deploys are working for me as well with the default

was having the same problem too randomly. I was able to reproduce consistently after I added additional tags to the app in the main function. As a workaround I ended up removing the tags and that allowed me to deploy again.

import { App } from "@serverless-stack/resources";
import { Tags } from "aws-cdk-lib";

import { ApiStack } from "./ApiStack";
import { AuthStack } from "./AuthStack";
import { StorageStack } from "./StorageStack";

export default function main(app: App) {
  app.setDefaultFunctionProps({
    runtime: "nodejs16.x",
    srcPath: "services",
    bundle: {
      format: "esm",
    },
  });

  Tags.of(app).add("sst-app", "summari-sst");
  Tags.of(app).add("sst-stage", `${app.stage}`);

  // these tags are added by default and does not follow the allowed characters for tagging in aws shared resource tags
  Tags.of(app).remove("sst:app");
  Tags.of(app).remove("sst:stage");

  app.stack(StorageStack).stack(AuthStack).stack(ApiStack);
}

Yeah, keep me posted. Thanks @brunorib0