IAwsApiCall

class aws_cdk.integ_tests.IAwsApiCall(*args, **kwds)

Bases: IConstruct, Protocol

(experimental) Interface for creating a custom resource that will perform an API call using the AWS SDK.

Stability:

experimental

Methods

assert_at_path(path, expected)

(experimental) Assert that the ExpectedResult is equal to the result of the AwsApiCall at the given path.

For example the SQS.receiveMessage api response would look like:

If you wanted to assert the value of Body you could do

Parameters:
Stability:

experimental

Return type:

None

Example:

# integ: IntegTest
actual = {
    "Messages": [{
        "MessageId": "",
        "ReceiptHandle": "",
        "MD5OfBody": "",
        "Body": "hello",
        "Attributes": {},
        "MD5OfMessageAttributes": {},
        "MessageAttributes": {}
    }]
}
message = integ.assertions.aws_api_call("SQS", "receiveMessage")

message.assert_at_path("Messages.0.Body", ExpectedResult.string_like_regexp("hello"))
expect(expected)

(experimental) Assert that the ExpectedResult is equal to the result of the AwsApiCall.

Parameters:

expected (ExpectedResult) –

Stability:

experimental

Return type:

None

Example:

# integ: IntegTest

invoke = integ.assertions.invoke_function(
    function_name="my-func"
)
invoke.expect(ExpectedResult.object_like({"Payload": "OK"}))
get_att(attribute_name)

(experimental) 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.

Parameters:

attribute_name (str) – the name of the attribute.

Return type:

Reference

Returns:

a token for Fn::GetAtt. Use Token.asXxx to encode the returned Reference as a specific type or use the convenience getAttString for string attributes.

Stability:

experimental

get_att_string(attribute_name)

(experimental) 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.

Parameters:

attribute_name (str) – the name of the attribute.

Return type:

str

Returns:

a token for Fn::GetAtt encoded as a string.

Stability:

experimental

Attributes

node

The construct tree node for this construct.