feat: Cloudformation + RDS
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
ListRulesCommand,
|
||||
ListTargetsByRuleCommand,
|
||||
PutRuleCommand,
|
||||
PutEventsCommand,
|
||||
PutTargetsCommand,
|
||||
RemoveTargetsCommand,
|
||||
type EventBridgeClient,
|
||||
@@ -25,6 +26,8 @@ import type {
|
||||
EventBridgeRuleInput,
|
||||
EventBridgeRuleOverview,
|
||||
EventBridgeRuleTarget,
|
||||
EventBridgePutEventInput,
|
||||
EventBridgePutEventResult,
|
||||
ResourceQuery,
|
||||
ServiceSchema,
|
||||
} from '../cloud-spi/types'
|
||||
@@ -152,6 +155,24 @@ export class AwsEventBridgeAdapter implements CloudServiceAdapter {
|
||||
await this.eventbridge.send(new DeleteRuleCommand({Name: name, ...eventBusInput(busName)}))
|
||||
}
|
||||
|
||||
async putEventBridgeEvent(eventBusId: string, input: EventBridgePutEventInput): Promise<EventBridgePutEventResult> {
|
||||
const source = requiredValue(input.source, 'source')
|
||||
const detailType = requiredValue(input.detailType, 'detailType')
|
||||
const detail = requiredValue(input.detail, 'detail')
|
||||
try {
|
||||
const parsed: unknown = JSON.parse(detail)
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) throw new Error('not an object')
|
||||
} catch {
|
||||
throw new ValidationError('detail must be a JSON object')
|
||||
}
|
||||
const response = await this.eventbridge.send(new PutEventsCommand({Entries: [{
|
||||
EventBusName: eventBusName(eventBusId), Source: source, DetailType: detailType, Detail: detail,
|
||||
...(input.resources?.length ? {Resources: input.resources} : {}),
|
||||
}]}))
|
||||
const entry = response.Entries?.[0]
|
||||
return {eventId: entry?.EventId ?? null, errorCode: entry?.ErrorCode ?? null, errorMessage: entry?.ErrorMessage ?? null}
|
||||
}
|
||||
|
||||
private async listTargets(ruleName: string, busName: string): Promise<Target[]> {
|
||||
const targets: Target[] = []
|
||||
let nextToken: string | undefined
|
||||
|
||||
Reference in New Issue
Block a user