Fresh iteration of AWS CDK synthesizerjuvenates

After setting up the CDKToolKit stack for a new "StyleStackSynthesis", I included the following field in cdk.json:

"@aws-cdk/core:newStyleStackSynthesis": "true"

The CDKToolKit stack was successfully deployed to AWS using the command:

cdk bootstrap  --toolkit-stack-name custom-cdktoolkit

However, when attempting to deploy my CDK application stack using the CDKToolKit stack, an error message is displayed:

Error: Could not assume role in target account (did you bootstrap the environment with the right '--trust's?)

I tried deploying the CDK application stack using this command:

cdk deploy --toolkit-stack-name custom-cdktoolkit

I also added the following to the CDK application stack:

"@aws-cdk/core:newStyleStackSynthesis": "true"

Do I need to add any additional configuration or make other adjustments?

Answer №1

I have gone through everything you shared on a brand new account with no prior activity.

My setup includes AWS CDK version: 1.70.0 (the latest update as of 2020/10/28)

  1. To resolve this, make sure to include
    "@aws-cdk/core:newStyleStackSynthesis": "true"
    in the cdk.json
  2. Execute
    cdk bootstrap --toolkit-stack-name custom-cdktoolkit
    based on your previous instructions.
cdk bootstrap --toolkit-stack-name custom-cdktoolkit

'@aws-cdk/core:newStyleStackSynthesis' context is set for new-style bootstrapping
 ⏳  Bootstrapping environment aws://xxxxxx/us-east-1...
 ❌  Environment aws://xxxxxx/us-east-1 encountered bootstrapping failure: Error: Please pass '--cloudformation-execution-policies' to specify deployment permissions. Try using a managed policy 'arn:aws:iam::aws:policy/<PolicyName>'.

However, I faced issues while attempting to reproduce the error on my end.

Since more specific details are lacking, the subsequent steps are open-ended.

  1. Include the necessary cf-execution-policies:
cdk bootstrap \
--toolkit-stack-name custom-cdktoolkit \
--cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess

'@aws-cdk/core:newStyleStackSynthesis' context set for new-style bootstrapping
 ⏳  Bootstrapping environment aws://xxxxx/us-east-1...
Trusted accounts:   (none)
Execution policies: arn:aws:iam::aws:policy/AdministratorAccess
custom-cdktoolkit: proposing CloudFormation changes...
[██████████████████████████████████████████████████████████] (11/11)
 ✅  Environment aws://xxxxx/us-east-1 has been successfully bootstrapped.
  1. Let's examine an example stack (without any cross-account access) quickly:
// file: lib/cdk-playground-stack.ts
import * as cdk from "@aws-cdk/core";
import * as s3 from "@aws-cdk/aws-s3";
export class CdkPlaygroundStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new s3.Bucket(this, "id", {
      accessControl: s3.BucketAccessControl.PRIVATE,
      encryption: s3.BucketEncryption.S3_MANAGED,
      versioned: false,
      blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
    });
  }
}
// file: app/app.ts

#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core';
import { CdkPlaygroundStack } from '../lib/cdk-playground-stack';

const app = new cdk.App();
// no cross-account environment arguments (like account) passed to the stack!
new CdkPlaygroundStack(app, 'CdkPlaygroundStack');
  1. Deploy the stack using the provided command (due to the non-default cdk-bootstrap-name)
cdk deploy --toolkit-stack-name custom-cdktoolkit

CdkPlaygroundStack: deploying...
[0%] start: Publishing dbfc18c149132627081b768fbbfc4bc345aeba4259514174fcd302d8b3926a90:current_account-current_region
[100%] success: Published dbfc18c149132627081b768fbbfc4bc345aeba4259514174fcd302d8b3926a90:current_account-current_region
CdkPlaygroundStack: creating CloudFormation changeset...
[██████████████████████████████████████████████████████████] (3/3)

 ✅  CdkPlaygroundStack

Stack ARN:
arn:aws:cloudformation:us-east-1:xxxxxxx:stack/CdkPlaygroundStack/9b8d4460-1940-11eb-abd9-0e794c84352f

There seem to be no conflicts, and it's challenging to troubleshoot given the limited information provided.

Here are a few suggestions:

  • Update to the latest CDK version
  • Verify your Stack creation process and ensure no additional arguments/props are being passed concerning alternate accounts as specified in your AWS profile/environment variables. Cross-Account deployments require specific setup, hence the inquiry.
  • Delete the bootstrapped CloudFormation stack
  • Revisit the steps taken for accurate replication

Answer №2

My experience has shown that the following approaches have been effective, particularly the second one involving cross-account trust and assume role scenarios.

Prior to provisioning the pipeline, you must first bootstrap the environment in which you intend to create it. If you are deploying your application across multiple environments, you must also bootstrap those environments and establish a trust relationship.

To bootstrap an environment for provisioning the pipeline:

$ env CDK_NEW_BOOTSTRAP=1 npx cdk bootstrap
[--profile admin-profile-1]
--cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
aws://111111111111/us-east-1

To bootstrap another environment for deploying CDK applications using a pipeline within account 111111111111:

$ env CDK_NEW_BOOTSTRAP=1 npx cdk bootstrap
[--profile admin-profile-2]
--cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
--trust 11111111111
aws://222222222222/us-east-2

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Invoke cloud functions independently of waiting for a response

Attempting a clever workaround with cloud functions, but struggling to pinpoint the problem. Currently utilizing now.sh for hosting serverless functions and aiming to invoke one function from another. Let's assume there are two functions defined, fet ...

What are the differences between Modules and Typings in Typescript?

I have been searching far and wide for information on the variances between modules and typings in TypeScript, but I'm still struggling to grasp the concept. As a newcomer to TypeScript, could someone please provide a concise explanation of these diff ...

The modal dialog from angular/material is unable to function properly when a shape on Google Maps is clicked

I have incorporated Google Maps into my application in order to showcase shapes (polygons/circles) and markers. To interact with Google Maps in Angular, I am utilizing the type definition "npm install --save @types/googlemaps". Upon clicking a shape, I nee ...

Exploring Angular14: A guide to efficiently looping through the controls of strictly typed FormGroups

Currently, I am working on upgrading my formGroups to be strictly typed in Angular v14. Within my FormGroup, there is a specific block of logic that iterates through all the controls and performs an action (this part is not crucial as I am facing issues be ...

Is it possible to automatically open the Tinymce Comments sidebar without the need for a manual button click?

After successfully implementing the Tinymce comments plugin into our configuration, we have come across a request from our users. They would like the 'showcomments' button to automatically trigger on page load, displaying the sidebar containing t ...

React TypeScript Context - problem with iterating through object

Can someone please help me with an error I am encountering while trying to map an object in my code? I have been stuck on this problem for hours and despite my efforts, I cannot figure out what is causing the issue. Error: const categoriesMap: { item: ...

Modify the color of the chosen value on the sidebar using Angular 6

I am looking to update the color of the selected value in the sidebar. Sample <div class="card c-setting"> <div class="card-header" title="Data Uploader"(click)="clickDataloader()"> <a class="card-link" data-toggle="collapse" href="# ...

I encountered an eslint error when I was trying to configure Vue 3 + Quasar with a Firebase config.ts file. The error stated that there was an unsafe assignment of an `

Recently, I set up a new Vue 3 project with Quasar using the Quasar CLI. In order to store my firebase configuration, I created a new file called src/firebase/config.ts, which looks like this: // Import necessary functions from SDKs import { initializeApp ...

Retrieving Identifiers with Typescript from an object

I'm a newcomer to Typescript and I'm looking to extract ids from an observable Here's the observable data: let myObj = [{ "id": 1, "text": "Mary" }, { "id": 2, "text": "Nancy" }, { "id": 3, "text": "Paul" }, { "id": 4, "tex ...

Angular error: Trying to access the sort property of an undefined value

I am currently working on creating a sorting function and pipe for a table. I found guidance on how to do this by following a tutorial at this link, and here is the plunker example. In the example, the table header should be clickable to trigger the sort() ...

resolved after a new promise returned nothing (console.log will output undefined)

Here is my Promise Function that iterates through each blob in Azure BlobStorage and reads each blob. The console.log(download) displays the values as JSON. However, when trying to close the new Promise function, I want the resolve function to return the ...

Building a React TypeScript project is successful on Windows, but encounters issues when attempted on a

Currently, I am immersed in a project that involves React TypeScript. Here is the content of the package.json: { "version": "0.1.0", "private": true, "dependencies": { ///... "react": "^16.8.6", "react-scripts-ts": "3.1.0", }, "scri ...

Testing Angular Components with Jasmine and Karma: When handling the 'onChange' event, the changeEvent parameter of type MatRadioChange should not be void and must be assigned to a parameter of type

Hey there, I was working on a test for a call where I am using to emit the event: onChange(eventName: MatRadioChange): void { this.eventName.emit(eventName.value); } Here is the test I have written for it: describe('onChange', (eventName: ...

Enhancing systemjs-builder with DefinitelyTyped

Is there a dedicated TypeScript definition file for systemjs-builder available? https://github.com/systemjs/builder I encountered an issue where the systemjs.d.ts file does not seem to cover it, leading to a "cannot find module" error when trying to impor ...

Developing an Angular 2 Cordova plugin

Currently, I am in the process of developing a Cordova plugin for Ionic 2. The plugin is supposed to retrieve data from an Android device and display it either on the console or as an alert. However, I am facing difficulty in displaying this data on the HT ...

Typescript with Angular: Despite having 7 values in the map, Map.get is returning undefined

Why does Map.get always return undefined when using a number from a form element (extra1) in this code snippet? extraById = new Map<number,Extra>(); @Input() extra1: number = -1; formChanged(carConfigurationFormChanged : any) { const index ...

Observable subscription does not result in updating the value

One of the challenges I'm currently facing in my Angular application is the synchronization of data from a server. To keep track of when the last synchronization took place, I have implemented a function to retrieve this information: fetchLastSyncDate ...

Generate a commitment from the function

I know the basics of JavaScript Promise and promise chain, but I'm looking to deepen my understanding. For example, take a look at the method provided below. It's in TypeScript, but can be adjusted for JavaScript ES6. private InsertPersonInDB(p ...

Tips for utilizing JavaScript object destructuring to extract a specific portion of an argument while still keeping a reference to the rest of the properties in a single value

In my current project, I am exploring the possibility of using TypeScript/Javascript object destructuring to target only certain properties of an object while preserving the rest of the properties in a separate variable. I am specifically looking for a way ...

Is Angular 6 with typescript the golden recipe for layout design?

I've been utilizing the golden layout in conjunction with Angular 6, following the steps outlined in this particular guide. The issue arises when I try to execute GoldenLayoutModule.forRoot(config) The error message states that 'config' ...