EventField Class
Represents a field in the event pattern.
Each EventField you reference from a RuleTargetInput becomes an entry in the target's InputPathsMap, keyed by a readable hint derived from the path, and the place you referenced it becomes a matching placeholder in the InputTemplate. Referencing the same path more than once reuses a single entry.
Because these are string tokens, they can be embedded in template literals and composed with other strings.
Example
ts
declare const rule: events.Rule;
declare const topic: sns.Topic;
rule.addTarget(new targets.SnsTopic(topic, {
message: events.RuleTargetInput.fromObject({
// Named shorthands for the standard top-level event envelope fields
account: events.EventField.account,
region: events.EventField.region,
// Any other field is reachable by JSONPath
bucket: events.EventField.fromPath('$.detail.bucket.name'),
// Tokens compose with ordinary strings
summary: `Event ${events.EventField.eventId} from ${events.EventField.source}`,
}),
}));
Properties
Extract the account from the event.
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string#The creation stack of this resolvable which will be appended to errors thrown during resolution.
This may return an array with a single informational element indicating how to get this property populated, if it was skipped for performance reasons.
Extract the detail type from the event.
Human readable display hint about the event pattern.
Extract the event ID from the event.
the path to a field in the event pattern.
Extract the region from the event.
Extract the source from the event.
Extract the time from the event.
Methods
fromPath(path: string): string@staticmethod def from_path(path: str) -> strpublic static String fromPath(String path)public static string FromPath(string path)func FromPath(Path *string) *stringstatic#Extract a custom JSON path from the event.
resolve(_ctx: IResolveContext): anydef resolve(self, _ctx: IResolveContext) -> Anypublic Object resolve(IResolveContext _ctx)public object Resolve(IResolveContext _ctx)func Resolve(_ctx IResolveContext) interface{}#Produce the Token's value at resolution time.
toJSON(): stringdef to_json(self, ) -> strpublic String toJSON()public string ToJSON()func ToJSON() *string#Convert the path to the field in the event pattern to JSON.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#Return a string representation of this resolvable object.
Returns a reversible string representation.