-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws_stepfunctions_tasks): HttpInvoke task does not permit reference path and intrinsic function in the apiEndpoint #29925
Comments
Reproducible using below code: import { SecretValue, Stack, StackProps } from 'aws-cdk-lib';
import * as events from 'aws-cdk-lib/aws-events';
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
import { Construct } from 'constructs';
export class Issue29925Stack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const connection = new events.Connection(this, 'Connection', {
authorization: events.Authorization.basic('username', SecretValue.unsafePlainText('password')),
});
const task = new tasks.HttpInvoke(this, 'Invoke HTTP API', {
apiRoot: 'https://api.stripe.com',
apiEndpoint: sfn.TaskInput.fromText(
sfn.JsonPath.format('v1/customers/{}', sfn.JsonPath.stringAt('$.customer_id')),
),
body: sfn.TaskInput.fromObject({ foo: 'bar' }),
connection,
headers: sfn.TaskInput.fromObject({ 'Content-Type': 'application/json' }),
method: sfn.TaskInput.fromText('POST'),
queryStringParameters: sfn.TaskInput.fromObject({ id: '123' }),
urlEncodingFormat: tasks.URLEncodingFormat.BRACKETS,
});
new sfn.StateMachine(this, 'MyStateMachine', {
definitionBody: sfn.DefinitionBody.fromChainable(task)
});
}
} Running
|
It's going to be a little awkward to resolve with the current props design. Even if we join the "ApiEndpoint": "https://api.stripe.com/States.Format('v1/customers/{}', $.customer_id)" Looking at the docs, I'm pretty sure this would be the accepted format: "ApiEndpoint.$": "States.Format('https://api.stripe.com/v1/customers/{}', $.customer_id)" We both need to prepend the first format parameter and change the |
I propose this patch but I don't know if the const parameters: TaskParameters = {
ApiEndpoint:
sfn.JsonPath.isEncodedJsonPath(this.props.apiEndpoint.value)
? sfn.JsonPath.format(`${this.props.apiRoot}/{}`, this.props.apiEndpoint.value)
: `${this.props.apiRoot}/${this.props.apiEndpoint.value}`,
Authentication: { This code generates : "Parameters":{
"ApiEndpoint.$":"States.Format('https://api.stripe.com/{}', States.Format('v1/customers/{}', $.customer_id))",
"Authentication":{
[...] |
The $ suffix is already added automatically? That makes it a little easier. And I think we should first test whether the |
Has there been any progress on this? I've faced this problem and it's a real blocker |
I have a draft PR to fix this here and just need to figure out how to update the integration test without breaking CI. |
@Tohaker Temporary fix in TS can use patch-package:
Only real change is Hope that helps |
Describe the bug
As describe in the AWS step function documentation, the
ApiEndpoint
parameter of the HttpInvoke task can be configured with intrinsic function and reference path. An example from the AWS documentation :In AWS CDK, the
ApiEndpoint
is generated by concatenatingapiRoot
andapiEndpoint
. But, when using an intrinsic function in the apiEndpoint property, the synth process fails with this error :Error: Field references must be the entire string, cannot concatenate them
I think the issue is with this concatenation here in the code with :
Expected Behavior
The API endpoint should be configurable with reference path and intrinsic function.
Current Behavior
Example from the AWS step functions documentation
I have this error :
Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.138.0
Framework Version
No response
Node.js Version
18
OS
Linux
Language
TypeScript
Language Version
Typescript 4.9
Other information
No response
The text was updated successfully, but these errors were encountered: