class LambdaInvokeFunction (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.IntegTests.Alpha.LambdaInvokeFunction |
![]() | github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#LambdaInvokeFunction |
![]() | software.amazon.awscdk.integtests.alpha.LambdaInvokeFunction |
![]() | aws_cdk.integ_tests_alpha.LambdaInvokeFunction |
![]() | @aws-cdk/integ-tests-alpha ยป LambdaInvokeFunction |
Implements
IConstruct
, IDependable
, IApi
An AWS Lambda Invoke function API call.
Use this instead of the generic AwsApiCall in order to invoke a lambda function. This will automatically create the correct permissions to invoke the function
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as integ_tests_alpha from '@aws-cdk/integ-tests-alpha';
import { aws_logs as logs } from 'aws-cdk-lib';
const lambdaInvokeFunction = new integ_tests_alpha.LambdaInvokeFunction(this, 'MyLambdaInvokeFunction', {
functionName: 'functionName',
// the properties below are optional
invocationType: integ_tests_alpha.InvocationType.EVENT,
logRetention: logs.RetentionDays.ONE_DAY,
logType: integ_tests_alpha.LogType.NONE,
payload: 'payload',
});
Initializer
new LambdaInvokeFunction(scope: Construct, id: string, props: LambdaInvokeFunctionProps)
Parameters
- scope
Construct
- id
string
- props
Lambda
Invoke Function Props
Construct Props
Name | Type | Description |
---|---|---|
function | string | The name of the function to invoke. |
invocation | Invocation | The type of invocation to use. |
log | Retention | How long, in days, the log contents will be retained. |
log | Log | Whether to return the logs as part of the response. |
payload? | string | Payload to send as part of the invoke. |
functionName
Type:
string
The name of the function to invoke.
invocationType?
Type:
Invocation
(optional, default: InvocationType.REQUEST_RESPONSE)
The type of invocation to use.
logRetention?
Type:
Retention
(optional, default: no retention days specified)
How long, in days, the log contents will be retained.
logType?
Type:
Log
(optional, default: LogType.NONE)
Whether to return the logs as part of the response.
payload?
Type:
string
(optional, default: no payload)
Payload to send as part of the invoke.
Properties
Name | Type | Description |
---|---|---|
node | Node | The tree node. |
provider | Assertions | access the AssertionsProvider. |
waiter | Assertions | access the AssertionsProvider for the waiter state machine. |
node
Type:
Node
The tree node.
provider
Type:
Assertions
access the AssertionsProvider.
This can be used to add additional IAM policies the the provider role policy
waiterProvider?
Type:
Assertions
(optional)
access the AssertionsProvider for the waiter state machine.
This can be used to add additional IAM policies the the provider role policy Example
declare const apiCall: AwsApiCall;
apiCall.waiterProvider?.addToRolePolicy({
Effect: 'Allow',
Action: ['s3:GetObject'],
Resource: ['*'],
});
Methods
Name | Description |
---|---|
assert | Assert that the ExpectedResult is equal to the result of the AwsApiCall at the given path. |
expect(expected) | Assert that the ExpectedResult is equal to the result of the AwsApiCall. |
get | Returns the value of an attribute of the custom resource of an arbitrary type. |
get | Returns the value of an attribute of the custom resource of type string. |
next(next) | Allows you to chain IApiCalls. This adds an explicit dependency betweent the two resources. |
to | Returns a string representation of this construct. |
wait | Wait for the IApiCall to return the expected response. |
assertAtPath(path, expected)
public assertAtPath(path: string, expected: ExpectedResult): IApiCall
Parameters
- path
string
- expected
Expected
Result
Returns
Assert that the ExpectedResult is equal to the result of the AwsApiCall at the given path.
Providing a path will filter the output of the initial API call.
For example the SQS.receiveMessage api response would look like:
If you wanted to assert the value of Body
you could do
expect(expected)
public expect(expected: ExpectedResult): IApiCall
Parameters
- expected
Expected
Result
Returns
Assert that the ExpectedResult is equal to the result of the AwsApiCall.
getAtt(attributeName)
public getAtt(attributeName: string): Reference
Parameters
- attributeName
string
Returns
Returns the value of an attribute of the custom resource of an arbitrary type.
Attributes are returned from the custom resource provider through the
Data
map where the key is the attribute name.
getAttString(attributeName)
public getAttString(attributeName: string): string
Parameters
- attributeName
string
Returns
string
Returns the value of an attribute of the custom resource of type string.
Attributes are returned from the custom resource provider through the
Data
map where the key is the attribute name.
next(next)
public next(next: IApiCall): IApiCall
Parameters
- next
IApi
Call
Returns
Allows you to chain IApiCalls. This adds an explicit dependency betweent the two resources.
Returns the IApiCall provided as next
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
waitForAssertions(options?)
public waitForAssertions(options?: WaiterStateMachineOptions): IApiCall
Parameters
- options
Waiter
State Machine Options
Returns
Wait for the IApiCall to return the expected response.
If no expected response is specified then it will wait for the IApiCall to return a success