mbonig / state-machine

a CDK construct for Step Functions State Machines that allows for easy integration with Workflow Studio
MIT License
40 stars 4 forks source link

Update to not use deprecated prop `StateMachineProps#definition` #30

Closed emmapatterson closed 11 months ago

emmapatterson commented 11 months ago

When using this dependency for our stepfunctions we are seeing this error:

[WARNING] aws-cdk-lib.aws_stepfunctions.StateMachineProps#definition is deprecated.
  use definitionBody: DefinitionBody.fromChainable()
  This API will be removed in the next major release.

Any chance of updating to not use this deprecated prop?

Thanks!

mbonig commented 11 months ago

Thanks for bringing this up. Please give it a try and let me know if there are any issues.

emmapatterson commented 11 months ago

Thanks for bringing this up. Please give it a try and let me know if there are any issues.

Hey Matt! Thanks for the quick response and update here! For some reason though I am still getting the warnings after updating

For your ref:

"aws-cdk": "^2.99.1",
"aws-cdk-lib": "^2.99.1",
"@matthewbonig/state-machine": "^0.0.29",

Seems like there are 2 warnings for every statemachine we have if that helps somehow!

mbonig commented 11 months ago

Can you share your output of:

cat node_modules/@matthewbonig/state-machine/package.json | grep version
cat node_modules/@matthewbonig/state-machine/lib/StateMachine.js
emmapatterson commented 11 months ago

Can you share your output of:

cat node_modules/@matthewbonig/state-machine/package.json | grep version
cat node_modules/@matthewbonig/state-machine/lib/StateMachine.js

Sure thing :

"standard-version": "^9",
"version": "0.0.29",

and


"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StateMachine = void 0;
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
const aws_stepfunctions = require("aws-cdk-lib/aws-stepfunctions");
const aws_stepfunctions_1 = require("aws-cdk-lib/aws-stepfunctions");
const yaml = require("js-yaml");
// eslint-disable-next-line @typescript-eslint/no-require-imports
const merge = require('lodash.merge');
class StateMachine extends aws_stepfunctions.StateMachine {
    constructor(scope, id, props) {
        const mergedDefinition = merge(props.definition, { States: props.overrides });
        let definitionString;
        if (props.aslYaml) {
            definitionString = yaml.dump(mergedDefinition);
        }
        else {
            definitionString = JSON.stringify(mergedDefinition);
        }
        const propsMinusDefinition = {
            ...props,
            definition: undefined,
        };
        super(scope, id, {
            ...propsMinusDefinition,
            definitionBody: aws_stepfunctions_1.DefinitionBody.fromString(definitionString),
        });
    }
}
exports.StateMachine = StateMachine;
_a = JSII_RTTI_SYMBOL_1;
StateMachine[_a] = { fqn: "@matthewbonig/state-machine.StateMachine", version: "0.0.29" };
mbonig commented 11 months ago

Yup, that's the right code. I just didn't test the fix properly... one second.

mbonig commented 11 months ago

Please try again

emmapatterson commented 11 months ago

That's us sorted now! Nice one!