interface WaiterStateMachineOptions
Language | Type name |
---|---|
![]() | Amazon.CDK.IntegTests.Alpha.WaiterStateMachineOptions |
![]() | github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#WaiterStateMachineOptions |
![]() | software.amazon.awscdk.integtests.alpha.WaiterStateMachineOptions |
![]() | aws_cdk.integ_tests_alpha.WaiterStateMachineOptions |
![]() | @aws-cdk/integ-tests-alpha ยป WaiterStateMachineOptions |
Options for creating a WaiterStateMachine.
Example
#!/usr/bin/env node
import * as path from 'path';
import * as firehose from 'aws-cdk-lib/aws-kinesisfirehose';
import * as kms from 'aws-cdk-lib/aws-kms';
import * as lambdanodejs from 'aws-cdk-lib/aws-lambda-nodejs';
import * as logs from 'aws-cdk-lib/aws-logs';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as cdk from 'aws-cdk-lib';
import { AwsApiCall, ExpectedResult, IntegTest } from '@aws-cdk/integ-tests-alpha';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-cdk-firehose-delivery-stream-s3-all-properties');
const bucket = new s3.Bucket(stack, 'FirehoseDeliveryStreamS3AllPropertiesBucket', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
});
const backupBucket = new s3.Bucket(stack, 'FirehoseDeliveryStreamS3AllPropertiesBackupBucket', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
});
const logGroup = new logs.LogGroup(stack, 'LogGroup', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
const dataProcessorFunction = new lambdanodejs.NodejsFunction(stack, 'DataProcessorFunction', {
entry: path.join(__dirname, 'lambda-data-processor.js'),
timeout: cdk.Duration.minutes(1),
});
const processor = new firehose.LambdaFunctionProcessor(dataProcessorFunction, {
bufferInterval: cdk.Duration.seconds(60),
bufferSize: cdk.Size.mebibytes(1),
retries: 1,
});
const key = new kms.Key(stack, 'Key', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
const backupKey = new kms.Key(stack, 'BackupKey', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
const deliveryStream = new firehose.DeliveryStream(stack, 'DeliveryStream', {
destination: new firehose.S3Bucket(bucket, {
loggingConfig: new firehose.EnableLogging(logGroup),
processor: processor,
compression: firehose.Compression.GZIP,
dataOutputPrefix: 'regularPrefix',
errorOutputPrefix: 'errorPrefix',
bufferingInterval: cdk.Duration.seconds(60),
bufferingSize: cdk.Size.mebibytes(1),
encryptionKey: key,
s3Backup: {
mode: firehose.BackupMode.ALL,
bucket: backupBucket,
compression: firehose.Compression.ZIP,
dataOutputPrefix: 'backupPrefix',
errorOutputPrefix: 'backupErrorPrefix',
bufferingInterval: cdk.Duration.seconds(60),
bufferingSize: cdk.Size.mebibytes(1),
encryptionKey: backupKey,
},
}),
});
new firehose.DeliveryStream(stack, 'ZeroBufferingDeliveryStream', {
destination: new firehose.S3Bucket(bucket, {
compression: firehose.Compression.GZIP,
dataOutputPrefix: 'regularPrefix',
errorOutputPrefix: 'errorPrefix',
bufferingInterval: cdk.Duration.seconds(0),
}),
});
const testCase = new IntegTest(app, 'integ-tests', {
testCases: [stack],
regions: ['us-east-1'],
});
testCase.assertions.awsApiCall('Firehose', 'putRecord', {
DeliveryStreamName: deliveryStream.deliveryStreamName,
Record: {
Data: 'testData123',
},
});
const s3ApiCall = testCase.assertions.awsApiCall('S3', 'listObjectsV2', {
Bucket: bucket.bucketName,
MaxKeys: 1,
}).expect(ExpectedResult.objectLike({
KeyCount: 1,
})).waitForAssertions({
interval: cdk.Duration.seconds(30),
totalTimeout: cdk.Duration.minutes(10),
});
if (s3ApiCall instanceof AwsApiCall && s3ApiCall.waiterProvider) {
s3ApiCall.waiterProvider.addToRolePolicy({
Effect: 'Allow',
Action: ['s3:GetObject', 's3:ListBucket'],
Resource: ['*'],
});
}
Properties
Name | Type | Description |
---|---|---|
backoff | number | Backoff between attempts. |
interval? | Duration | The interval (number of seconds) to wait between attempts. |
total | Duration | The total time that the state machine will wait for a successful response. |
backoffRate?
Type:
number
(optional, default: 1 (no backoff))
Backoff between attempts.
This is the multiplier by which the retry interval increases after each retry attempt.
By default there is no backoff. Each retry will wait the amount of time
specified by interval
.
interval?
Type:
Duration
(optional, default: Duration.seconds(5))
The interval (number of seconds) to wait between attempts.
totalTimeout?
Type:
Duration
(optional, default: Duration.minutes(30))
The total time that the state machine will wait for a successful response.