# EventField

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.

Extends: EventField
Implements: IResolvable

- Source: [`aws-events/lib/input.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-events/lib/input.ts#L330)

## 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

- `account`: string (static) — Extract the account from the event.

- `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.

- `detailType`: string (static) — Extract the detail type from the event.

- `displayHint`: string — Human readable display hint about the event pattern.

- `eventId`: string (static) — Extract the event ID from the event.

- `path`: string — the path to a field in the event pattern.

- `region`: string (static) — Extract the region from the event.

- `source`: string (static) — Extract the source from the event.

- `time`: string (static) — Extract the time from the event.

## Methods

- `fromPath(path: string): string` (static) — Extract a custom JSON path from the event.

- `resolve(_ctx: IResolveContext): any` — Produce the Token's value at resolution time.

- `toJSON(): string` — Convert the path to the field in the event pattern to JSON.

- `toString(): string` — Return a string representation of this resolvable object.

  Returns a reversible string representation.
