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

Is there a way I can obtain the code for a message box?

When I refer to a message box, I am talking about a container that gives users the ability to input their text and access different features like BOLD, ITALIC, color, justify, etc., in order to customize their message's appearance! (Think of it as the ...

Error Encountered: Unable to locate angular/core module in Angular 2

I have encountered an issue while setting up a new Angular2 app from the quickstart folder on the Angular website. Despite following all suggested solutions, I am still facing errors. After running npm install, everything seems fine as I can see my node_mo ...

Dealing with submit errors in React Redux forms

I am facing a challenge with handling exceptions properly when submitting in redux forms. I want to display a toast message when an error occurs. LogIn.js: class LogIn extends PureComponent { onSubmit = (values) => { const { login } = this.props; ...

Using Higher Order Components (HOC) in combination with Redux compose and Typescript

I am trying to leverage two Higher Order Components (HOC) with Redux compose, but the compiler is not generating the correct types. The Compose function is defined in the Redux source code here source code. To better understand how the code works, you ca ...

Unable to retrieve the value from the selected radio button

Below is the provided HTML: <form> <div class="form-group"> <div class="checkbox-detailed male_input"> <input type="radio" name="gender" id="male" value="male"> <label for="male"> ...

Issue with Yup and Formik not validating checkboxes as expected

I'm struggling to figure out why the validation isn't functioning as expected: export default function Check() { const label = { inputProps: { "aria-label": "termsOfService" } }; const formSchema = yup.object().shape({ ...

Which HTML tags can be activated with JavaScript to be interactive?

I'm currently diving into the world of JavaScript and one of the initial code snippets I've encountered is onclick. So far, I've seen it utilized in form buttons like this: <input type="button" onclick="checkName()" value="Check name" / ...

Is There a Name Clash Issue with Dependency Injection in AngularJS?

Let's say I have two modules, finance2 and finance3, both of which define a service called currencyConverter. If I specify that my main module only depends on finance2, I can inject the service like this: angular.module('invoice2', [' ...

What could be causing certain users to not see the updates once they are deployed on AWS ElasticBeanstalk?

After successfully deploying my Node.js app (actually a React application wrapped by Node.js/Express) to AWS Elasticbeanstalk, I encountered an issue where only some testers were able to see the updates, while others couldn't. Personally, I could see ...

Showcasing a single object in an IONIC/Angular application using the ngIF directive

I am in need of assistance as I have encountered an issue. Essentially, I am fetching an object from an external API (Strapi) using the GET method, but when attempting to display it on Views with ngIF, it fails to show up. Below is the code snippet: word ...

How do I customize the appearance of console.log messages stored in a string variable?

Looking to enhance the appearance of my console log output in a JavaScript script by utilizing different styling options. Here's a sample scenario: s=`Title 1 \n This is some text that follows the first title`; s=`${s} \n Title 2 \n T ...

The ngx-treeview is displaying an inaccurate tree structure. Can you pinpoint where the issue lies?

I have structured my JSON data following the format used in ngx-treeview. Here is the JSON file I am working with: [ { "internalDisabled": false, "internalChecked": false, "internalCollapsed": false, "text": "JOURNEY", "value": 1 } ...

Troubleshooting Observable data in Angular 2/Typescript - A Comprehensive Guide

After going through the Angular 2 tutorial, I managed to create a search feature that asynchronously displays a list of heroes. <div *ngFor="let hero of heroes | async"> {{hero.name}} </div> In my component, I have an observable array of ...

The PKIJS digital signature does not align with the verification process

Explore the code snippet below const data = await Deno.readFile("./README.md"); const certificate = (await loadPEM("./playground/domain.pem"))[0] as Certificate; const privateKey = (await loadPEM("./playground/domain-pk ...

Deploying CSS/JS files in Magento 2 is a crucial

Hello, I recently set up magento2 with the sample data included. After attempting to deploy static css/JS using the command php bin/magento setup:static-content:deploy, I didn't receive any errors but the issue persists. Additionally, I am unable to l ...

What allows mapped types to yield primitive outputs when using {[P in keyof T]}?

Check out this innovative mapped type example that utilizes the power of keyof: type Identity<T> = { [P in keyof T]: T[P]; }; Have you ever wondered why Identity<number> results in the primitive number type, rather than an object type? Is th ...

What is the best way to load $cookies into an Angular service?

After defining an Angular service where I need to access a cookie, I noticed that the $cookieStore is deprecated and that it's recommended to use $cookies instead. This is how my service is set up: 'use strict'; var lunchrServices = angul ...

A guide on using jCrop to resize images to maintain aspect ratio

Utilizing Jcrop to resize an image with a 1:1 aspect ratio has been mostly successful, but I've encountered issues when the image is wider. In these cases, I'm unable to select the entire image. How can I ensure that I am able to select the whole ...

The Webstorm AngularJS extension appears to be malfunctioning, as it is not able to recognize the keyword 'angular'

As a beginner in Angularjs and web development, I have been using Webstorm to develop my projects. I have already installed the Angularjs plugin, which seems to be working fine in my HTML files. However, I am facing an issue with my .js file. In this file, ...

Tips for managing lag caused by large raw image re-renders in a React application

When trying to change the background position of a user-uploaded background image that is in raw Data URI format using CSS, I noticed that re-rendering becomes slow if the image size exceeds 1mb. This issue does not occur with smaller images. Is there a ...