Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fifo queue without name in nested stack fails to create #5860

Open
cmckni3 opened this issue Jan 18, 2020 · 5 comments
Open

Fifo queue without name in nested stack fails to create #5860

cmckni3 opened this issue Jan 18, 2020 · 5 comments
Labels
@aws-cdk/aws-sqs Related to Amazon Simple Queue Service bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@cmckni3
Copy link
Contributor

cmckni3 commented Jan 18, 2020

Reproduction Steps

import cdk = require('@aws-cdk/core');

import { NestedStack } from '@aws-cdk/aws-cloudformation';
import { Queue } from '@aws-cdk/aws-sqs';

export class CdkFifoQueueStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new MyNestedStack(this, 'NestedStack');
  }
}

export class MyNestedStack extends NestedStack {
  constructor(scope: cdk.Construct, id: string) {
    super(scope, id);

    new Queue(this, 'MyQueue', {
      fifo: true
    });
  }
}

source

MUST USE cdk deploy. THE STACK SYNTHESIZES FINE.

Error Log

CloudFormation error after running cdk deploy:

The name of a FIFO queue can only include alphanumeric characters, hyphens, or underscores, must end with .fifo suffix and be 1 to 80 in length. (Service: AmazonSQS; Status Code: 400; Error Code: InvalidParameterValue; Request ID: 0079e079-6bf5-5eec-90d9-b6e4eebec170)

Environment

  • CLI Version : 1.19.0
  • Framework Version: 1.19.0
  • OS : macOS
  • Language : TypeScript

This is 🐛 Bug Report

@cmckni3 cmckni3 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 18, 2020
@SomayaB SomayaB added the @aws-cdk/aws-sqs Related to Amazon Simple Queue Service label Jan 21, 2020
@NetaNir
Copy link
Contributor

NetaNir commented Jan 22, 2020

If a queue name is not specified, CloudFormation generates a unique physical ID and uses that ID for the queue name. The generated name will include the containing stack name and the queue resource logical id. To adhere to SQS queue name limitations of max 80 characters CloudFormation will trim the stack name and logical id components in the generated physical ID. When the queue is a fifo queue CloudFormation will append .fifo to the physical ID as required by SQS which might result in a queue name longer than the max 80 characters :/ causing it to fail.

Nested stacks names (generated by CloudFormation) are composed from the parent stack name and the nested stack resource logical ID, resulting in a longer than the average user generated stack name, making fifo queue defined inside a nested stack more likely to hit the max 80 character limit.

I'm not quite sure what is the best way for the CDK to make this experience better for users as it seems the only way to make sure this will not happen is to make the queue name required and add verification which is a breaking change.
@eladb, any thoughts?

@nija-at
Copy link
Contributor

nija-at commented Jan 22, 2020

How about setting the queueName to ${this.node.uniqueId.substr(0, 75)}.fifo when the fifo flag is set to true?

@nija-at nija-at assigned MrArnoldPalmer and unassigned nija-at Jan 23, 2020
@SomayaB SomayaB added needs-discussion This issue/PR requires more discussion with community. and removed needs-triage This issue or PR still needs to be triaged. labels Mar 4, 2020
@moltar
Copy link
Contributor

moltar commented Jul 29, 2020

Just got bit by that too.

Worse yet, the log output doesn't actually tell you what the problem was. Just says "resources could not be created".

And when you go into AWS, the NestedStack is deleted and is hidden.

So for AWS noobs like myself, it's many rabbit holes to go through to find what is wrong.

@NetaNir
Copy link
Contributor

NetaNir commented Jul 29, 2020

The queue name is it's physical ID, when not required, the CDK will not set it, unless provided by the user. Setting a physical name for a resource have implication on the resource update policy, from CloudFormation docs:

If you specify a name, you can't perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.

Which is why we try to avoid setting a physical name for resources when not required. We will follow up with CloudFormation to see if this can be fixed on their side.

In the meantime we can implement @nija-at suggestion above.

@NetaNir NetaNir removed the needs-discussion This issue/PR requires more discussion with community. label Jul 29, 2020
@cmckni3
Copy link
Contributor Author

cmckni3 commented Jul 29, 2020

And when you go into AWS, the NestedStack is deleted and is hidden.

yep, I get the nested stack id using the AWS cli and use the id in the console URL to view events via the console.

Can also view the events with the AWS cli.

@MrArnoldPalmer MrArnoldPalmer added the effort/medium Medium work item – several days of effort label Aug 17, 2020
@MrArnoldPalmer MrArnoldPalmer removed their assignment Jun 21, 2021
@pahud pahud added p2 and removed p1 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-sqs Related to Amazon Simple Queue Service bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

7 participants