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

(cdk-diff): >=2.11.0 not authorized to perform: cloudformation:ListStackResources #19351

Closed
natevick opened this issue Mar 11, 2022 · 20 comments
Closed
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. p2

Comments

@natevick
Copy link

natevick commented Mar 11, 2022

General Issue

cdk-[QUALIFIER]-deploy-role-[ACCOUNT]-[REGION]/aws-cdk-node is not authorized to perform: cloudformation:ListStackResources

The Question

Prior to 2.11.0 running diff just worked without errors or abnormal output. Starting at 2.11.0 and all the way through 2.15.0 I get cdk-[QUALIFIER]-deploy-role-[ACCOUNT]-[REGION]/aws-cdk-node is not authorized to perform: cloudformation:ListStackResources.

The bootstrap version is 10.
There is a lookup role in IAM.
The trusted account and trusted lookup account is the primary/only account involved in the project.
The project was started at 2.1.0.

I'm not sure what to ask at this point, but I'm currently stuck at 2.10.0.

CDK CLI Version

2.11.0

Framework Version

No response

Node.js Version

16.13.1

OS

Debian Bullseye 11.1

Language

Typescript

Language Version

4.5.2

Other information

I did note this merged PR but I believe that came into CDK at 2.7.0.

@natevick natevick added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Mar 11, 2022
@groner
Copy link

groner commented Mar 11, 2022

I'm also seeing this error with cdk diff (I didn't try deploy) starting in 2.10.0. The cdk bootstrap version here is also 10.

@peterwoodworth
Copy link
Contributor

Wonder if it was this PR?

@peterwoodworth peterwoodworth added bug This issue is a bug. needs-reproduction This issue needs reproduction. and removed guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Mar 11, 2022
@comcalvi
Copy link
Contributor

comcalvi commented Mar 11, 2022

Thanks for the issue @nvick @groner, could you provide a reproduction stack? Do you have issues with just diff, or is it both diff and deploy?

@comcalvi comcalvi self-assigned this Mar 11, 2022
@natevick
Copy link
Author

I'll see if I can put something together that is reproducible this evening. Thanks @comcalvi

@natevick
Copy link
Author

import { Stack, StackProps } from 'aws-cdk-lib'
import { Construct } from 'constructs'
import * as ec2 from 'aws-cdk-lib/aws-ec2'
import * as eks from 'aws-cdk-lib/aws-eks'

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

    const cluster = new eks.Cluster(this, 'staging-eks', {
      clusterName: 'staging',
      version: eks.KubernetesVersion.V1_21,
      defaultCapacity: 0,
      albController: {
        version: eks.AlbControllerVersion.V2_3_0
      }
    })

    cluster.addNodegroupCapacity('staging-node-group', {
      instanceTypes: [new ec2.InstanceType('t3.large')],
      minSize: 1,
      maxSize: 10
    })
  }
}

If I run cdk diff with the above stack on version 2.10.0 no errors, but if I run it with 2.11.0-2.16.0 I get the error.

@natevick
Copy link
Author

natevick commented Mar 16, 2022

I just verified with my reproduction stack it is only diff.

@natevick
Copy link
Author

@comcalvi I also pushed this to a repo with a devcontainer configuration. https://github.com/nvick/cdk-stack-diff-issues

@NGL321 NGL321 added p1 in-progress This issue is being actively worked on. labels Apr 7, 2022
@comcalvi
Copy link
Contributor

comcalvi commented Apr 8, 2022

@nvick I'm unable to reproduce this error on CDK version 2.20.0, 2.10.0, or 2.11.0. I've ran cdk diff against the stack undeployed and after deploying it, with a minor change. I have not been able to reproduce any errors. I haven't been able to reproduce it from the repo you linked either. Can you share specific instructions to reproduce the error?

@comcalvi comcalvi removed the in-progress This issue is being actively worked on. label Apr 8, 2022
@natevick
Copy link
Author

Sure @comcalvi!

  • Fork above repo
  • Start Codespace
  • Run aws configure
  • Run npm install
  • Run cdk diff note full diff output
  • Run npm install -g aws-cdk@2.11.0
  • Run cdk diff note error
  • Run npm install -g aws-cdk
  • Run cdk diff not error

@comcalvi
Copy link
Contributor

Thanks @nvick this reproduces the error. I'll be investigating this issue to determine root cause later.

@comcalvi comcalvi added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-reproduction This issue needs reproduction. labels Apr 19, 2022
@comcalvi
Copy link
Contributor

@nvick The source of the error is the version of aws-cdk-lib in your package.json. In here:

  "devDependencies": {
    // ...
    "aws-cdk": "^2.11.0",
    // ...
  },
  "dependencies": {
    "aws-cdk-lib": "2.3.0",
     // ...
  }

if you change 2.3.0 to 2.11.0 and run npm install, then the error no longer occurs. I'm leaving this issue open so we can fix the error message, but that should unblock you.

@comcalvi comcalvi removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 19, 2022
@comcalvi comcalvi added the in-progress This issue is being actively worked on. label Apr 19, 2022
@natevick
Copy link
Author

Thanks @comcalvi! I'll try it and let you know if I run into anything else. Thanks for taking the time.

@comcalvi
Copy link
Contributor

Any version pair that satisfies this condition:

    "aws-cdk" >= "2.11.0"
    "aws-cdk-lib" <= "2.6.0"

causes the bug. It's because #18207 (introduced in 2.11.0) depends on #18277 (introduced in 2.7.0). The consequence is that aws-cdk >= 2.11.0 depend on aws-cdk-lib >= 2.7.0.

@comcalvi comcalvi added p2 and removed p1 in-progress This issue is being actively worked on. labels Jun 15, 2022
@comcalvi comcalvi removed their assignment Jun 20, 2022
@toduythienluong
Copy link

I'm also seeing this error with cdk diff (I didn't try deploy) starting in 2.10.0. The cdk bootstrap version here is also 10.

I also got with cdk diff, how to fix it?

@ricardosllm
Copy link

I also had this issue, fixed in the interim by adding the policy to the role explicitly, in this case AWSCloudFormationReadOnlyAccess

@toduythienluong
Copy link

I also had this issue, fixed in the interim by adding the policy to the role explicitly, in this case AWSCloudFormationReadOnlyAccess

thanks, that fixes

@aarondodd
Copy link

Same, CDK v2 doesn't let me do cdk diff until I add AWSCloudFormationReadOnlyAccess to the role. Deploy has been working fine, though.

@setu4993
Copy link
Contributor

+1, hitting the same issue with the latest versions of CDK.

@jhkcia
Copy link

jhkcia commented Feb 3, 2023

I also have this problem with last version of aws-cdk

@khushail khushail added the @aws-cdk/core Related to core CDK functionality label Jun 5, 2024
@khushail khushail changed the title diff: >=2.11.0 not authorized to perform: cloudformation:ListStackResources (cdk-diff): >=2.11.0 not authorized to perform: cloudformation:ListStackResources Jun 5, 2024
@mrgrain
Copy link
Contributor

mrgrain commented Nov 1, 2024

This has long been resolved in recent version of CDK. Make sure you update to a recent version for all bugfixes. Also ensure you are using the latest bootstrap version. Closing this here. If anyone is still encountering the issue with up-to-date versions, please open a new issue.

@mrgrain mrgrain closed this as completed Nov 1, 2024
@aws aws locked as resolved and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/core Related to core CDK functionality bug This issue is a bug. p2
Projects
None yet
Development

No branches or pull requests