-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[notice] CDK CLI Authentication Issues #1656
Comments
I ran in to the case where a
caused the following error, even though my
Removing the |
I'm trying to run
Is there any reason I would still get an error like:
Is there a new process for running integ tests? |
Answering my own question for the next person. My issue was that at some point |
Another edge case, in case anyone else runs into it. Using
Looking at By changing it to include a region, the issue was resolved and
Maybe updating the error message to be a bit more explicit in what the actual issue is would be helpful? |
Just to add on for MFA: I am having this problem WITHOUT a
error:
|
Hello... I'm having another authentication issue... We use a identity account and a governor account role with MFA enabled... my config file looks like this: [profile default] and I have a [default] credentials with my client and secret keys. I'm running CDK from a AWS Workspace (I don't know if this can be the problem). I get an error saying that I didn't do aws configure ... I did, and I'm providing --profile default to be sure. Any fix/workaround? If I try to deploy the hello-cdk app I get this (with --verbose)
|
CDK not using the Is it expected behaviour that when a The story In order to avoid the problem I now setup an empty CDK is configured with:
|
I'm trying to deploy a CDK app from within a Lambda function. Now it complains with:
Passing Lambda function itself already has a role that has all the permissions to deploy a CDK app. Is this even possible? The final resort is to duplicate CDK's |
I have a CDK app which is deployed from a docker container inside an EC2 instance. The EC2 instance has a role in the target account which does nothing but allow me to assume an other role. I have a CDK plugin which handles assuming the role. When I try to deploy via CDK, the app is loading the plugin, but is not requesting credentials from it. Instead CDK resolves and looks up "default credentials" for the account. Since the role is for the account, CDK moves on and subsequently fails as the instance role has no permissions. Is there a way to tell CDK to not use this account, or better to just use my plugin?
|
@mrgrain I went on with a different approach I described in this #2637 (comment). It might give you some ideas. |
@kadishmal I found a solution for my issue. Since the problem came down to AWS CDK trying to use ec2 meta data credentials by default, we can disable that behaviour by setting I guess what would be nice if that option is explicitly called out in the log. Something like
|
I have two weird issues: My config file is setup like this:
When I run My first issue is I get this error which uses a different region from my default (which is very strange). My second issue is that the CDK also does not assume the role specified in the configuration.
|
Is there any verified way of leverage just the AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID (but no AWS_SESSION_TOKEN) environment variables? |
I believe if you're not using temporary credentials like assumeRole, but something like an IAM User, you don't need to set AWS_SESSION_TOKEN. |
for mfa, I use aws-mfa to make things a bit more bearable. it writes short term credentials into your .credentials file and works with cdk! |
So, just to round out the issue... I have been trying to run |
Detail logs:
A workaround is to |
@kadishmal I got CDK running in a Lambda. Setting the a HOME environment variable to /tmp for the Lambda allows create the credentials files and use the Lambda's role. The CDK CLI also needs |
@SteveHoggNZ just like that? Set the HOME env to /tmp and CDK will stop using the credentials? Can you paste some sample code? |
This workaround may feel slightly less painful if you use the export AWS_SHARED_CREDENTIALS_FILE=/tmp/aws-cdk-1656-workaround
touch $AWS_SHARED_CREDENTIALS_FILE |
@julienlepine is this available on a future version of the cli? |
Not sure if this helps anyone, but in my organization we use AWS SSO, with over 90 AWS Accounts, with MFA, so it was impossible to manage CDK without AWS SSO support. I found a way to solve it, so till its officially relesed, you can use this, it works quite all right: MatsCloud blog - CDK with AWS SSO multi account multi profile |
Encountered this issue today as well on our CI server (GitLab) there is no credentials/config file, setting the ACCESS_KEY and SECRET_KEY works fine until you try to assume a role in another account (https://www.npmjs.com/package/cdk-assume-role-plugin). Also to reproduce this locally. Creating anempty credentials/config file does not help sadly!
|
After banging my head on this for a few days, finally got it working.. Use case
Solution
Hope this won't be needed in the near future.. If theres an easier way, do let me know here or on Twitter @drissamri88 |
that helped a lot, thanks @drissamri ! |
I'm having the same issue, normally I would not bump this as enough people are troubled by this, but I'm using the awsprocesscreds-saml to get access to a corporate account. My config might look like this:
(I changed my emailaddress and my account id) |
Tests with no success (1.70.0): Using --server
Directly
Results
Configuring explicitly account and region I received another error:
Downgrading to 1.59: I'm lost! |
The screenshot looks like a dependency version mismatch. Remove your lockfile and node_modules folder and install again. |
@hoegertn You right, but solving it I get again:
|
Never mind people, this problem is a bed configuration. |
Hi, Hope You all are doing well, need little help, I have created my IAM user and configured every thing fine, but still getting this error, "Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment" any body can help to know what I am doing wrong. here is my .aws/config and .aws/credentials files [default] .aws/config: [default] Regards: usman Naeem. |
This issue was originally intended as an announcement about differences between CDK CLI auth configuration and AWS CLI auth configuration. It has morphed into a thread where everybody posts an error which they think might have something to do with authentication. We will move the original content to the developer guide, and close this thread. If you're not sure if the behavior you're seeing is a bug, come and ask on Slack. Otherwise, we will start using individual issues to start tracking individual bugs. |
|
In case anyone is running into this problem while trying to run the script from Octopus Deploy (using this feature: https://octopus.com/docs/deployments/custom-scripts/aws-cli-scripts) please note: Do not use
from https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html I realized that Octopus was already setting the environment variables (scoped for session) in the script, and simply by removing the --profile, it worked. Specifically the PS1 script below worked for us
|
After spending a couple hours on this authentication issue, I finally figured this out. For everyone who has this issue, you may have a try with the following configurations. What I have done before, it worked perfectly with aws-cli, but NOT CDK. In
When I tried to bootstrap, It seemed CDK cannot read my credentials and profiles. After tons of attempts, it finally worked with the following configurations. In
In
cdk version: 2.21.0 (build 3f74a81) |
Building on this solution, for anyone who came across this issue when trying to run |
The CDK CLI has some limitations compared to the AWS CLI. If you are having authentication issues, they might be covered by one of the following issues. Please use this thread to discuss further.
CDK CLI will not read your region from your [default] profile
If your
~/.aws/config
is set up like this:Even though your profile
MyProfile
does not contain aregion
, the AWS CLI will read the region from the[default]
section. The AWS SDK for JavaScript that the CDK is built on does not do this, so the CDK does not support this. Make sure every profile section contains theregion
.Cannot have a profile named "default" in the config file
The following will not work:
The AWS CLI seems to accept this, but the AWS SDK for JavaScript will fail to load the configuration file properly.
How to properly select AWS CLI profiles for your stacks/accounts
See issue #3961
The text was updated successfully, but these errors were encountered: