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

aws-cdk: direct deploy return error when there are no stack updates #23141

Closed
enpatrik opened this issue Nov 29, 2022 · 15 comments
Closed

aws-cdk: direct deploy return error when there are no stack updates #23141

enpatrik opened this issue Nov 29, 2022 · 15 comments
Assignees
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@enpatrik
Copy link

Describe the bug

Using cdk deploy --method=direct when there are no stack updates:

  • On a stack that resolves SSM parameters (during deployment).

It return ❌ Deployment failed and exit code 1.

Compared to cdk deploy that return ✅ HelloCdkStack (no changes) and exit code 0.

Expected Behavior

cdk deploy --method=direct
  • Message: ✅ HelloCdkStack (no changes)
  • Exit code: 0

When there are no updates.

Current Behavior

cdk deploy --method=direct

Debug output:

HelloCdkStack: some parameters come from SSM so we have to assume they may have changed
HelloCdkStack: deploying...
HelloCdkStack: updating stack...
Call failed: updateStack({"StackName":"HelloCdkStack", ...}) => No updates are to be performed. (code=ValidationError)

Result:

 ❌  HelloCdkStack failed: Error [ValidationError]: No updates are to be performed.
    at Request.extractError (/hello-cdk/node_modules/aws-sdk/lib/protocol/query.js:50:29)
    at Request.callListeners (/hello-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/hello-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/hello-cdk/node_modules/aws-sdk/lib/request.js:686:14)
    at Request.transition (/hello-cdk/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/hello-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /hello-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/hello-cdk/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/hello-cdk/node_modules/aws-sdk/lib/request.js:688:12)
    at Request.callListeners (/hello-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
  code: 'ValidationError',
  time: 2022-11-29T12:11:36.798Z,
  requestId: 'f2b0b91f-c7a9-4707-a71b-d015f4283d55',
  statusCode: 400,
  retryable: false,
  retryDelay: 843.8278571993974
}

 ❌ Deployment failed: Error: Stack Deployments Failed: ValidationError: No updates are to be performed.
    at deployStacks (/hello-cdk/node_modules/aws-cdk/lib/deploy.ts:61:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at CdkToolkit.deploy (/hello-cdk/node_modules/aws-cdk/lib/cdk-toolkit.ts:338:7)
    at initCommandLine (/hello-cdk/node_modules/aws-cdk/lib/cli.ts:364:12)

Stack Deployments Failed: ValidationError: No updates are to be performed.

Exit code: 1

Reproduction Steps

Modified sample app:

mkdir hello-cdk
cd hello-cdk
npx aws-cdk@2.x init sample-app --language typescript

Modify stack:

import { Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import * as ssm from "aws-cdk-lib/aws-ssm";

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

    ssm.StringParameter.valueForStringParameter(this, "/foo/bar");
  }
}
aws ssm put-parameter --name /foo/bar --value hello

Deploy first time:

cdk deploy --method=direct

Second time (no updates):

cdk deploy --method=direct

Possible Solution

Check if this.cfn.updateStack in directDeployment() return "no updates to be performed"-ValidationError then return noOp: true.

Additional Information/Context

It works as expected on stacks that doesn't resolve SSM parameters.

CDK CLI Version

2.53.0 (build 7690f43)

Framework Version

2.53.0

Node.js Version

v16.18.1

OS

Mac OS

Language

Typescript

Language Version

No response

Other information

We would like to use this nice new direct deploy feature #22079 👏 in our CI/CD process, and it would therefor be nice if it doesn't return error when there are no updates.

@enpatrik enpatrik added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2022
@github-actions github-actions bot added the @aws-cdk/aws-ssm Related to AWS Systems Manager label Nov 29, 2022
@peterwoodworth
Copy link
Contributor

I was able to reproduce this with the sample you posted, thanks for reporting!

What's interesting is that I tried to reproduce this first using a bucket (with auto delete set to true, which will create a custom resource), and wasn't able to reproduce. I wonder if there's something specific with the SSM parameter that is messing things up here

@peterwoodworth peterwoodworth added p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 29, 2022
@ChrisSargent
Copy link

Okay as far as I can see, I think this is the problem:

From:

public async performDeployment(): Promise<DeployStackResult> {

    switch (deploymentMethod.method) {
      case 'change-set':
        return this.changeSetDeployment(deploymentMethod);

      case 'direct':
        return this.directDeployment();
    }

But only changeSetDeployment uses the changeSetHasNoChanges function which kind of suppresses the error, from here:

export function changeSetHasNoChanges(description: CloudFormation.DescribeChangeSetOutput) {
, added in this PR by @rix0rrr.

So seems like some of that code should be reused in the directDeployment function.

@o-alexandrov
Copy link

o-alexandrov commented Jul 23, 2023

Started to experience this issue when deploying only DynamoDB tables stack after bumping: aws-cdk-lib from 2.87.0 to 2.88.0. When the stack has no changes, this cli cmd fails:

cdk deploy --method=direct

with:

STACK_NAME_HERE failed: Error [ValidationError]: No updates are to be performed

{
  code: 'ValidationError',
  time: 2023-07-23T10:33:54.575Z,
  requestId: '13368caf-1f89-4761-a37f-20ee12c38a6f',
  statusCode: 400,
  retryable: false,
  retryDelay: 631.5026618550738
}

@LCSsuper
Copy link

I'm experiencing the same error on version 2.99.0... The first deployment works just fine and the second throws the No updates are to be performed error.

It seems like an easy bug to fix, by adding support for a --no-fail-on-empty-changeset flag, just like the aws cloudformation deploy cli command supports. Could this be done?

@polothy
Copy link
Contributor

polothy commented Oct 5, 2023

Just ran into this trying to speed up the deployment of a large project (100s of stacks) by avoiding ChangeSet creation.

@uncledru
Copy link

+1 also experiencing the same issue

@wakeupmh
Copy link

dropped here in the same situation as @polothy

@o-alexandrov
Copy link

@otaviomacedo could you please share: is there an ETA for this issue?

@tvb
Copy link

tvb commented Oct 23, 2023

Got the same issue, how to proceed?
Deploying without the --method=direct solved it for me.

@Lewenhaupt
Copy link

Yeah same here, the weird thing is it doesn't happen for all our stacks, only some.

@Lewenhaupt
Copy link

And it comes back from time to time -> i.e. sometimes --method=direct works as expected when there are no changes, and sometimes it causes failures.

@tristanharms-cb
Copy link

We're having the same issue by the way. Deploying without --method=direct is not an option for us as we're trying to speed up deployment time.

@ChrisSargent
Copy link

Seems a fix went in this release: https://github.com/aws/aws-cdk/releases/tag/v2.118.0

@enpatrik
Copy link
Author

enpatrik commented Jan 4, 2024

Awesome, thanks for letting us know @ChrisSargent !

I've tried it with my reproduction scenario and it is now working as intended when upgraded to CDK 2.118.0. 🎉

Closing this, resolved by: #28523 and released in v2.118.0

@enpatrik enpatrik closed this as completed Jan 4, 2024
Copy link

github-actions bot commented Jan 4, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ssm Related to AWS Systems Manager bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

No branches or pull requests