Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/lib/custom-resources/cdk-s3-template/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ async function onCreate(event: CloudFormationCustomResourceEvent) {
} catch (e) {
throw new Error(`Unable to put S3 object s3://${outputBucketName}/${outputPath}: ${e}`);
}

try {
// Waiting for the template available in s3
// default delay is 5 seconds and max retry attempts is 20
console.debug(`Waiting for ${outputBucketName}/${outputPath}`);
await throttlingBackOff(() =>
s3
.waitFor('objectExists', {
Bucket: outputBucketName,
Key: outputPath,
$waiter: {
maxAttempts: 1,
},
})
.promise(),
);
} catch (error) {
throw new Error(`Unable to find S3 object s3://${outputBucketName}/${outputPath}: ${error}`);
}
}

async function onUpdate(event: CloudFormationCustomResourceEvent) {
Expand Down