In my Lambda CDK stack, I want to setup an event rule to send an event to my Lambda every 10 minutes.
This works and deploys the rule with the lambda as the target
// ... setup lambdaFunction construct...
// -- EVENTBRIDGE RULES --
const meetingSyncEvent = {
path: "/v1/meeting/sync",
httpMethod: "GET"
};
const eventTarget = new awsEventTarget.LambdaFunction(lambdaFunction, {
event: awsEvents.RuleTargetInput.fromObject(meetingSyncEvent)
});
/**
TODO how do I add target to ARN with alias/version
* */
const eventRule = new awsEvents.Rule(this, generateConstructName("event-rule"), {
enabled: true,
description: "event to invoke GET /meeting/sync",
ruleName: "meeting-sync-rule",
targets : [
eventTarget
],
schedule: awsEvents.Schedule.rate(EVENT_MEETING_SYNC_RATE)
});
// -- end EVENTBRIDGE RULES --
The problem is this only targets the base ARN without an Alias or version (effectively always pointing to $Latest). There is this option in AWS console to set an Alias or version for a target (pics below), how can I do this in the CDK?
aws console UI allows alias and version for target target arn has alias when configured through UI