Closed drernie closed 9 months ago
The best option is to use EventBridge Schema Registry to discover, create, and manage schemas for the events used by both services.
Events:
OrderConfirmed:
Type: CloudWatchEvent # More info about CloudWatchEvent Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#cloudwatchevent
Properties:
EventBusName: custom-event-bus #Uncomment this if your events are not on the 'default' event bus
Pattern:
source:
- edu.svc.orders
detail-type:
- Order Confirmed
Specifically:
When this S3 bucket creates or updates a file under s3://bucket/.quilt/named_packages/
import { S3EventSource } from 'aws-cdk-lib/aws-lambda-event-sources'
import { Topic } from 'aws-cdk-lib/aws-sns'
import { EmailSubscription } from 'aws-cdk-lib/aws-sns-subscriptions'
import {
AccountPrincipal,
ManagedPolicy,
PolicyStatement,
Role,
ServicePrincipal
} from 'aws-cdk-lib/aws-iam'
// SNS Topic for failure notifications
const topicName = `${APP_NAME}_workflow_status_topic`
this.statusTopic = new Topic(this, topicName, {
displayName: topicName,
topicName: topicName
})
// Create an EventBridge rule that sends SNS notification on failure
const ruleWorkflowStatusTopic = new Rule(
this,
`${APP_NAME}_rule_workflow_status_topic`,
{
eventPattern: {
source: ['aws.omics'],
detailType: ['Run Status Change'],
detail: {
status: ['FAILED', 'COMPLETED', 'CREATED']
}
}
}
)
ruleWorkflowStatusTopic.addTarget(new SnsTopic(this.statusTopic))
const servicePrincipal = new ServicePrincipal('events.amazonaws.com')
this.statusTopic.grantPublish(servicePrincipal)
this.statusTopic.grantPublish(this.principal) // for debugging purposes
this.statusTopic.addSubscription(new EmailSubscription(props.email))
import {
Bucket,
BlockPublicAccess,
EventType,
BucketEncryption,
BucketPolicy
} from 'aws-cdk-lib/aws-s3'
const fastqWorkflowLambda = this.makeLambda('wf1_fastq', {})
// Add S3 event source to Lambda
fastqWorkflowLambda.addEventSource(
new S3EventSource(this.inputBucket, {
events: [EventType.OBJECT_CREATED],
filters: [
{ prefix: this.manifest_prefix, suffix: this.manifest_suffix }
]
})
)
Parameters
Actions