Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default credentials can not be used to assume new style deployment roles

Tags:

aws-cdk

Following pipelines readme to set up a deployment pipeline, I ran

$ env CDK_NEW_BOOTSTRAP=1 npx cdk bootstrap \
    --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess \
    aws://[ACCOUNT_ID]/us-west-2

to create the necessary roles. I would assume the roles would automatically add sts assume role permissions from my account principle. However, when I run cdk deploy I get the following warning

current credentials could not be used to assume 'arn:aws:iam::[ACCOUNT_ID]:role/cdk-hnb659fds-file-publishing-role-[ACCOUNT_ID]-us-west-2', but are for the right account. Proceeding anyway.

I have root credentials in ~/.aws/credentials.

Looking at the deploy role policy, I don't see any sts permissions. What am I missing?

like image 739
heckeop Avatar asked Jul 06 '21 18:07

heckeop


People also ask

What is Assume Role policy in AWS?

Assuming a role involves using a set of temporary security credentials that you can use to access AWS resources that you might not normally have access to. These temporary credentials consist of an access key ID, a secret access key, and a security token.

What is bootstrapping in deployment?

Bootstrapping is the deployment of a AWS CloudFormation template to a specific AWS environment (account and region). The bootstrapping template accepts parameters that customize some aspects of the bootstrapped resources (see Customizing bootstrapping).

How does CDK bootstrap work?

The CDK bootstrap command provisions a CloudFormation stack called CDKToolkit . The stack consists of an S3 bucket that stores file assets (i.e. Lambda function code, CloudFormation templates), required for deployments. We have to bootstrap each environment (account and region) separately.

What does CDK synth do?

The cdk synth command executes your app, which causes the resources defined in it to be translated into an AWS CloudFormation template. The displayed output of cdk synth is a YAML-format template; the beginning of our app's output is shown below. The template is also saved in the cdk. out directory in JSON format.

What are the Azure App service deployment credentials?

To secure app deployment from a local computer, Azure App Service supports two types of credentials for local Git deployment and FTP/S deployment. These credentials are not the same as your Azure subscription credentials. User-level credentials: one set of credentials for the entire Azure account.

What are the errors for default credentials cannot be supplied?

Error: Default credentials cannot be supplied for the basic authentication scheme. Error count: 1. You are telling Web Deploy to connect to the Web Management Service on the destination.

Why can’t I publish my profile credentials on webdeploy?

To confirm that the publish profile credentials are blocked on WebDeploy, try publishing a web app using Visual Studio 2019. The API in the previous section is backed Azure role-based access control (Azure RBAC), which means you can create a custom role and assign lower-priveldged users to the role so they cannot enable basic auth on any sites.

What are user-level credentials in azure?

User-level credentials: one set of credentials for the entire Azure account. It can be used to deploy to App Service for any app, in any subscription, that the Azure account has permission to access. It's the default set that's surfaced in the portal GUI (such as the Overview and Properties of the app's resource page ).


Video Answer


5 Answers

You will need to add permission to assume the role to the credentials from which you are trying to execute cdk deploy

{
  "Sid": "assumerole",
  "Effect": "Allow",
  "Action": [
     "sts:AssumeRole",
     "iam:PassRole"
  ],
  "Resource": [
     "arn:aws-cn:iam::*:role/cdk-readOnlyRole",
     "arn:aws-cn:iam::*:role/cdk-hnb659fds-deploy-role-*",
     "arn:aws-cn:iam::*:role/cdk-hnb659fds-file-publishing-*"
  ]
}
like image 65
SAGAR TRIVEDI Avatar answered Oct 26 '22 03:10

SAGAR TRIVEDI


  1. First thing you need to do is enabling the verbose mode to see what is actually happenning.

    cdk deploy --verbose
    

    If you see similar message below. Continue with step 2. Otherwise, you need to address the problem by understanding the error message.

    Could not assume role in target account using current credentials User: arn:aws:iam::XXX068599XXX:user/cdk-access is not authorized to perform: sts :AssumeRole on resource: arn:aws:iam::XXX068599XXX:role/cdk-hnb659fds-deploy-role-XXX068599XXX-us-east-2 . Please make sure that this role exists i n the account. If it doesn't exist, (re)-bootstrap the environment with the right '--trust', using the latest version of the CDK CLI.

  2. Check S3 buckets related to CDK and CloudFormation stacks from AWS Console. Delete them manually.

  3. Enable the new style bootstrapping by one of the method mentioned here

  4. Bootstrap the stack using below command. Then it should create all required roles automatically.

    cdk bootstrap --trust=ACCOUNT_ID --cloudformation-execution-policies=arn:aws:iam::aws:policy/AdministratorAccess --verbose
    

NOTE: If you are working with docker image assets, make sure you have setup your repository before you deploy. New style bootstrapping does not create the repos automatically for you as mentioned in this comment.

like image 32
TRiNE Avatar answered Oct 26 '22 02:10

TRiNE


This may be of use to somebody... The issue could be a mismatch of regions. I spotted it in verbose mode - the roles were created for us-east-1 but I had specified eu-west-2 in the bootstrap. For some reason it had not worked. The solution was to set the region (by adding AWS_REGION=eu-west-2 before the cdk deploy command).

like image 4
Horacio Avatar answered Oct 26 '22 02:10

Horacio


I ran into a similar error. The critical part of my error was

failed: Error: SSM parameter /cdk-bootstrap/<>/version not found.

I had to re-run using the new bootstrap method that creates the SSM parameter. To run the new bootstrap method first set CDK_NEW_BOOTSTRAP via export CDK_NEW_BOOTSTRAP=1

like image 2
timohare Avatar answered Oct 26 '22 03:10

timohare


Don't forget to run cdk bootstrap with those credentials against your account [ACCOUNT_ID].

like image 1
user18109458 Avatar answered Oct 26 '22 02:10

user18109458