-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
aws_cdk.aws_stepfunctions_tasks.HttpInvoke: Get API Endpoint from state input #30749
Comments
Reproducible. Below is the equivalent code in TypeScript: import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as events from 'aws-cdk-lib/aws-events';
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
export class TypescriptStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const connection = new events.Connection(this, 'Connection', {
authorization: events.Authorization.basic('username', cdk.SecretValue.unsafePlainText('password'))
});
const task = new tasks.HttpInvoke(this, "Invoke HTTP API", {
apiRoot:"States.Format('https://api.stripe.com')", // Static API root, adjust as necessary,
apiEndpoint: sfn.TaskInput.fromText("rest/v1/{}.json',$.detail.object_name"), // Use the constructed URL
body: sfn.TaskInput.fromJsonPathAt('$.detail.object'),
connection: connection,
headers: sfn.TaskInput.fromObject({"Content-Type": "application/json"}),
method: sfn.TaskInput.fromJsonPathAt('$.detail.object_method'),
urlEncodingFormat: tasks.URLEncodingFormat.BRACKETS
});
const sfMarketo_sync = new sfn.StateMachine(this, 'sfMarketo-sync', {
stateMachineName: 'sfMarketo-sync-test',
definitionBody: sfn.DefinitionBody.fromChainable(task),
timeout: cdk.Duration.minutes(5),
stateMachineType: sfn.StateMachineType.STANDARD
});
}
} Running
The This could be related to the other issue #29925 as well. |
I was able to work around the issue until the fix is ready with the following code in Python CDK:
I also altered the api_root and api_endpoint values to have a valid States.Format expression after the concatenation. |
Describe the bug
Get API Endpoint from state input is not working throwing this error.
SCHEMA_VALIDATION_FAILED: The value for the 'ApiEndpoint' field is not valid at /States/Invoke HTTP API/Parameters' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition
Expected Behavior
It should create stepfunction shown in below image with below definition.
Current Behavior
When we add code for step function httpinvoke task cdk python. it's throwing below error.
Reproduction Steps
Possible Solution
When we run synth or deploy on backend it creates cloud formation template in cdk.out folder. The template should add ".$" suffix to "ApiEndpoint" parameter but it's not adding. For reference see the parameter "Method" which has suffix ".$". if it add that suffix it should work.
Additional Information/Context
No response
CDK CLI Version
2.146.0 (build b368c78)
Framework Version
No response
Node.js Version
v22.3.0
OS
Mac OS
Language
Python
Language Version
Python 3.12.3
Other information
No response
The text was updated successfully, but these errors were encountered: