cdk deploy --role-arn error iam:PassRole #19672
-
General Issuecdk deploy by assuming a role failed though added iam:passRole policy The QuestionThis command failed
CDK CLI Version2.10.0 Framework VersionNo response Node.js VersionNo response OSUbuntu 18.0 LanguagePython Language VersionPython 3.8.12 Other informationNo response |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 4 replies
-
Hey @entest-hai, You'll want to pass in a custom DefaultStackSynthesizer to your stack and tell it what deploy role you're using. Here's an example new MyStack(app, 'MyStack', {
synthesizer: new DefaultStackSynthesizer({
deployRoleArn: 'arn:aws:iam::123456789012:role/myrole'
})
}); |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@peterwoodworth I tried your suggestion but still get an error
Then in addition, I pass env
still get another error
|
Beta Was this translation helpful? Give feedback.
-
Is this possible to run cdk deploy by providing an assumed role in CDK stack rather ran configuring AWS CLI with credentials? |
Beta Was this translation helpful? Give feedback.
-
Hi, I ran into this same problem and your solution doesn't quite make sense to me. Why would I want to or need to hardcode my role to use for deployment? What is the point of the --role-arn command line parameter then? I'm doing all this is C# and downgraded to the CDK V1 Nuget libraries and using the exact same command line specifying the role-arn to use for CloudFormation and it worked 100%. I can also see in CloudFormation that the correct role was used to execute the CloudFormation template, which leads me to believe there is something wrong with the V2 implementation of --role-arn. A side note: a policy containing my execution roles needs to be specified in when bootstrapping the CDK using the --cloudformation-execution-policies parameter. This policy is added to the cdk-hnb659fds-cfn-exec-role..... role and not the deploy role. the cdk-hnb659fds-cfn-deploy-role which is what is causing the above error. Is the deploy-role maybe used instead of the exec-role where executing CDK? |
Beta Was this translation helpful? Give feedback.
-
So, since this BUG now turned into a discussion, can we please discuss what the purpose of the --role-arn command line parameter is and why we need to hardcode the deployment role ARN into our CDK's? |
Beta Was this translation helpful? Give feedback.
-
I am also extremely confused by this. What does |
Beta Was this translation helpful? Give feedback.
-
Also interested. I am trying to specify a different deploy role in GHA cdk action to deploy non-developer stacks. |
Beta Was this translation helpful? Give feedback.
-
So interesting and will wait solutions from team, but found that when I user cluster.connections.allow_from(***) for Kafka I have this issue but when I do my cluster without cluster.connections.allow_from it works fine. Maybe it can help. |
Beta Was this translation helpful? Give feedback.
-
@peterwoodworth can you please respond to these questions. The original bug was just closed and moved to this discussion after you provided a solution that does not work and it also doesn't answer any of the questions. I'm currently faced with the issue where I have a lot of stacks that are working 100% using CDK V1, but I'm now getting messages stating that it is soon going into maintenance and I should upgrade to V2, except that converting these CDK's to V2 does not work because --role-arn is no longer working. Apart from it being completely counter intuitive to code the execution ARN into the CDK , it also doesn't doesn't work. Not even the sample application. |
Beta Was this translation helpful? Give feedback.
-
Seems like I found temporary solution, to use --profile with role configuration in a profile instead of --role-arn . Of course it is inconvenient that it will be necessary to generate a aws profile with role before launch, but still a working option. |
Beta Was this translation helpful? Give feedback.
-
Hi there @entest-hai - I was able to get this working. Your error is that
In my case, it was the
it happily deployed. So I think what you'd need to do is to modify your deploy role to allow it to PassRole on your CF execution role. Now, this value is set when you bootstrap, but it looks like rerunning In summary, I think I have a working workaround for you - and we'll confirm/research/prioritize/resolve the bug too. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi there @entest-hai - I was able to get this working. Your error is that
arn:aws:sts::123456:assumed-role/cdk-hnb659fds-deploy-role-123456-ap-southeast-1/aws-cdk-haitran
is not authorized to performiam:PassRole
- so you need to add those permissions to the deploy role, not the CloudFormation execution role. Here's what I was getting when I tried this:In my case, it was the
cdk-h…