Error in AWS Cloud Development Kit: Cannot access properties of undefined while trying to read 'Parameters'

I am currently utilizing aws cdk 2.132.1 to implement a basic Lambda application.

Within my project, there is one stack named AllStack.ts which acts as the parent stack for all other stacks (DynamoDB, SNS, SQS, StepFunction, etc.), here is an overview:

import * as cfn_inc from 'aws-cdk-lib/cloudformation-include';
import {CfnStateMachine} from 'aws-cdk-lib/aws-stepfunctions';
import {Duration} from 'aws-cdk-lib';

interface AllStackProps {
    readonly env: DeploymentEnvironment;
    readonly lambdaFunction: IFunction;
}

export class AllStack extends DeploymentStack {
    constructor(scope: Construct, id: string, readonly props: AllStackProps) {
        super(scope, id, {
            env: props.env,
            softwareType: SoftwareType.INFRASTRUCTURE,
        });

        const cfnInclude = new cfn_inc.CfnInclude(this, 'Template', {
            templateFile: 'templates/root.yaml',
            // loadNestedStacks: {
            //   StepFunctionStack: {
            //     templateFile: 'templates/step_function.yaml',
            //     preserveLogicalIds: true,
            //     parameters: { 'Domain': props.env }
            //   },
            // },
            // parameters: {
            //     'Domain': props.env
            // }
        });
    }
}

The build process was successful with the loadNestedStack part commented out. However, upon uncommenting these lines, it failed to build and produced errors such as:

TypeError: Cannot read properties of undefined (reading 'Parameters')
    at CfnInclude.createNestedStack (ROOT_TO_MY_WORK_DIR/node_modules/aws-cdk-lib/cloudformation-include/lib/cfn-include.js:1:15080)
    at CfnInclude.getOrCreateResource (ROOT_TO_MY_WORK_DIR/node_modules/aws-cdk-lib/cloudformation-include/lib/cfn-include.js:1:13018)
    at CfnInclude.loadNestedStack (ROOT_TO_MY_WORK_DIR/node_modules/aws-cdk-lib/cloudformation-include/lib/cfn-include.js:1:5353)
    at new AllStack (ROOT_TO_MY_WORK_DIR/dist/lib/allStack.js:26:20)
    at Object.<anonymous> (ROOT_TO_MY_WORK_DIR/dist/lib/app.js:41:18)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)

This is the structure of my entire folder:

-FunServiceCDK
--lib
---allStack.ts
---app.ts
--templates
---root.yaml
---step_function.yaml

This is the content of my root.yaml:

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  Domain:
    Type: String

Resources:
  StepFunctionStack:
    Type: AWS::CloudFormation::Stack

This is the content of my step_function.yaml:

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  Domain:
    Type: String

Resources:
  ComputationStepFunction:
    Type: AWS::StepFunctions::StateMachine

After reviewing the CDK documentation on CfnInclude doc, it seems that the parameters field is optional. Despite supplying this field in both the .ts and .yaml files, the issue persists. Any assistance would be greatly appreciated!

Thank you!

Answer №1

Your main CloudFormation template is missing some required fields for the AWS::CloudFormation::Stack resource. According to the documentation, you need to specify either a StackName or one of TemplateBody and TemplateURL.

You have the option to use a dummy template body or a placeholder template URL, which CDK will later replace with your desired stack configuration.

As stated in the CDK documentation:

The TemplateURL property of the nested stack resource will be updated to point to the specified asset.

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

Ensure that the text is wrapped properly when implementing innerHTML functionality

Within my Angular 5 application, I am faced with a requirement to display HTML content retrieved from a database. An example of the text stored in the database is: <div><u>Documents and Files</u></div><ul><li>These docu ...

The submission form is being triggered immediately upon the page loading

I have a form on the landing page that sends parameters to Vuex actions. It functions correctly when I click the submit button and redirects me to the next page as expected. However, there seems to be a problem. Whenever I open or refresh the page, the par ...

Trigger a Redux action with the following action as the payload in order to display a Material UI snackbar or dialog

Currently, my project involves using React along with Redux and Material UI to develop a web application. The web app consists of numerous pages and components. It is common practice to have a snackbar or dialog interact directly with the user's actio ...

Show two choices in a select box next to each other

I've been attempting to display a select box with two options side by side in a list format. Struggling to find any libraries that can achieve this functionality. Here is an example: <select> <option x><option y> <optio ...

scrollable material ui chips list with navigation arrows

I'm attempting to create a unique scrollable chips array using Material UI version 4 (not version 5). Previous examples demonstrate similar functionality: View Demo Code I would like to update the scrolling bar of this component to include l ...

Execute a JavaScript function when an element loaded via Ajax in a Spring MVC framework triggers the onChange event

I currently have a dropdown list with two values and I am looking to enable or disable four components based on the user's selection. If the user picks the first value, the components should be enabled, otherwise they should be disabled. On the main ...

Is it possible to utilize an alias in conjunction with the NodeJS require function?

I have a JavaScript module written in ES6 that exports two constants: export const apple = "apple"; export const banana = "banana"; In another module, I can import these constants as follows: import { apple as a, banana as b } from 'fruits'; c ...

Unable to add a string to a http get request in Angular

When a specific ID is typed into the input field, it will be saved as searchText: <form class="input-group" ng-submit="getMainData()"> <input type="text" class="form-control" ng-model="searchText" placeholder=" Type KvK-nummer and Press Enter" ...

What is the best way to implement an event listener for every button in a table row outcome?

I have a Rails application where I am populating a table using an @results variable, with each row representing a @result. My goal is to have buttons associated with each @result, and I'm attempting to use a JavaScript event listener for each button a ...

The React Functional Component undergoes exponential re-renders when there is a change in the array

I'm encountering a problem with one of my functional components. Essentially, it maintains an array of messages in the state; when a new message is received from the server, the state should update by adding that new message to the array. The issue ar ...

Understanding how to access POST content in Meteor.js is an important aspect

In my Meteor app, I am trying to retrieve data using POST requests. Here is the code snippet I am using on the server side: __meteor_bootstrap__.app.stack.splice (0, 0, { route: '/input', handle: function(req, res, next) { req.on(' ...

Struggling to Align NAV buttons to the Right in React Framework

My current Mobile Header view can be seen here: https://i.stack.imgur.com/CcspN.png I am looking to achieve a layout similar to this, https://i.stack.imgur.com/pH15p.png. So far, I have only been able to accomplish this by setting specific left margins, ...

In JavaScript, if you check for the existence of a key in an object, it

Recently, I ran into an issue with an undefined error when trying to access a value in a JavaScript object key. I retrieved arrays of objects using the mongoose.find().exec() callback and then checked each object for a specific key. Here is an example obj ...

Solving the issue of "_c is not defined" error in Vue functional component

I've been experimenting with creating functional components in Vue using the render method. Here's an example of how I attempted to do this: import Vue from "vue" const { render, staticRenderFns } = Vue.compile(`<div>Hello World</div&g ...

How to effectively utilize TypeScript in a team environment using both Atom and VSCode?

Our team utilizes TypeScript with both Atom and VSCode as our editors, but we are facing challenges with the tsconfig.json file. VSCode is not recognizing the typings, causing the namespace for 'ng' (for Angular 1.x) to be unknown in VSCode. Wh ...

After the assignment, TypeScript reordered the elements of the array

Dealing with an array of objects for use in a ngFor loop has presented a challenge. The issue arises when the order that was initially set for the array changes unexpectedly due to JavaScript manipulation. Originally, the array is ordered as expected when ...

sanitizing user input in an AngularJS application

I created a feature in angular using ng-repeat <ul class="messages"> <li ng-repeat="e in enquiries"> <img src="/img/avatar.jpg" alt=""> <div> ...

Experiencing an issue with the Web Crypto API in NextJS due to receiving the error message "crypto is not defined."

I was wondering if NextJS supports the use of the web crypto API. Recently, I attempted to utilize it by writing the following code: crypto.subtle.digest('SHA-256', data) However, I encountered an error message that said: ReferenceError: crypto ...

"After clicking the button for the second time, the jQuery on-click function begins functioning properly

(Snippet: http://jsfiddle.net/qdP3j/) Looking at this HTML structure: <div id="addContactList"></div> There's an AJAX call that updates its content like so: <div id="<%= data[i].id %>"> <img src="<%= picture %&g ...

Comparing XDomainRequest and XMLHTTPRequest - which one to choose

Our team is currently developing an application utilizing PixiJS that integrates a dynamic json loader. The .json files are loaded using the following logic: if(window.XDomainRequest) { this.ajaxRequest = new window.XDomainRequest(); } else if (windo ...