Skip to content

Commit

Permalink
fix(stepfunctions-tasks): Stage field not included in CallApiGatewayH…
Browse files Browse the repository at this point in the history
…ttpApiEndpoint task definition (aws#15755)

`this.stageName` was not initialized by `props.stageName` when calling `CallApiGatewayHttpApiEndpoint`'s constructor, therefore causing the `Stage` field to not get rendered even though we specified that property.

fixes aws#14242

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jihndai authored and TikiTDO committed Aug 3, 2021
1 parent 193c2fd commit 28830f6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class CallApiGatewayHttpApiEndpoint extends CallApiGatewayEndpointBase {

this.apiEndpoint = this.getApiEndpoint();
this.arnForExecuteApi = this.getArnForExecuteApi();
this.stageName = props.stageName;

this.taskPolicies = this.createPolicyStatements();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,59 @@ describe('CallApiGatewayHttpApiEndpoint', () => {
});
}).toThrow(/Unsupported service integration pattern./);
});

test('render Stage field', () => {
// GIVEN
const stack = new cdk.Stack();
const httpApi = new apigatewayv2.HttpApi(stack, 'HttpApi');

// WHEN
const task = new CallApiGatewayHttpApiEndpoint(stack, 'Call', {
apiId: httpApi.apiId,
apiStack: cdk.Stack.of(httpApi),
method: HttpMethod.GET,
stageName: 'stage',
});

// THEN
expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
End: true,
Parameters: {
ApiEndpoint: {
'Fn::Join': [
'',
[
{
Ref: 'HttpApiF5A9A8A7',
},
'.execute-api.',
{
Ref: 'AWS::Region',
},
'.',
{
Ref: 'AWS::URLSuffix',
},
],
],
},
AuthType: 'NO_AUTH',
Method: 'GET',
Stage: 'stage',
},
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::apigateway:invoke',
],
],
},
});
});
});

0 comments on commit 28830f6

Please sign in to comment.