AwsCloudwatch

Service-level AWS CloudWatch component.

Remarks

This is the primary component resource for the package. It can orchestrate one CloudWatch capability per instance:

  • log group
  • log stream
  • metric filter
  • metric alarm
  • subscription filter
  • log resource policy

Naming:

  • Root: type ${namespace}:aws:AwsCloudwatch; capability cloudwatch; identity is the raw selected args.<capability>.name, or for resource policies args.resourcePolicy.policyName then args.resourcePolicy.resourceArn; target ${env}-${projectHash}-cloudwatch-${sanitiseNamePart(identity)}.
  • Provider children have parent AwsCloudwatch and the single raw selected identity tuple: LogGroup [args.logGroup.name], LogStream [args.logStream.name], LogMetricFilter [args.metricFilter.name], MetricAlarm [args.metricAlarm.name], LogSubscriptionFilter [args.subscriptionFilter.name], and LogResourcePolicy [args.resourcePolicy.policyName] or [args.resourcePolicy.resourceArn]. Each target is ${env}-${projectHash}-${sanitiseNamePart(identity)}.
  • Lambda invoke permissions are owned by the referenced Lambda component. Metric-alarm relationships use [selected capability identity, alarm state]; subscription-filter relationships use [selected capability identity]. The Lambda component separately adds the function identity and invoking-service discriminator.
  • AWS provider names: LogGroup name uses stackAndPurpose ${env}-${projectHash}-${purpose} through buildAwsNameFromCamelCasePurpose(...). LogStream, LogMetricFilter, MetricAlarm, LogSubscriptionFilter, and LogResourcePolicy names are semantic/external provider values forwarded unchanged from their documented args fields; CloudWatch owns their constraints and validation.

Example

CODE
const logGroup = new AwsCloudwatch({
  logGroup: {
    name: 'ordersApplicationLogs',
    retentionInDays: 30,
  },
});

const metricFilter = new AwsCloudwatch({
  metricFilter: {
    logGroup,
    name: 'ordersErrors',
    pattern: '{ $.level = "ERROR" }',
    metricTransformation: {
      name: 'OrdersErrorCount',
      namespace: 'Jobcloud/Application',
      value: '1',
    },
  },
});

const metricAlarm = new AwsCloudwatch({
  metricAlarm: {
    name: 'ordersErrorsAlarm',
    comparisonOperator: 'GreaterThanOrEqualToThreshold',
    evaluationPeriods: 1,
    period: 60,
    statistic: 'Sum',
    threshold: 1,
    metric: metricFilter,
  },
});

Constructors

new AwsCloudwatch( args: AwsCloudwatchArgs, options?: ComponentResourceOptions, ): AwsCloudwatch

Parameters

  • args (AwsCloudwatchArgs) — Service-level CloudWatch capability inputs. Use new AwsCloudwatch(args, options).The component logical name is derived from the selected capability identity field. Identity fields must be plain strings, not pulumi.Input, pulumi.Output, or promises.
  • options (ComponentResourceOptions, optional) — Optional settings controlling resource behaviour.

Returns

AwsCloudwatch

Hierarchy

  • ComponentResource
  • AwsCloudwatch

Properties

lambdaInvokePermissions: Resource[]

readonly

Lambda invoke permissions created for managed alarm actions and subscription destinations.

logGroup: LogGroup

readonly

Optional log-group capability created by this component.

logGroupName: Output<string>

readonly

Effective log-group name when logGroup capability is used.

logStream: LogStream

readonly

Optional log-stream capability created by this component.

metricAlarm: MetricAlarm

readonly

Optional metric-alarm capability created by this component.

metricFilter: LogMetricFilter

readonly

Optional metric-filter capability created by this component.

metricFilterMetricName: Output<string>

readonly

Metric-filter metric name when metricFilter capability is used.

metricFilterMetricNamespace: Output<string>

readonly

Metric-filter metric namespace when metricFilter capability is used.

resourcePolicy: LogResourcePolicy

readonly

Optional resource-policy capability created by this component.

subscriptionFilter: LogSubscriptionFilter

readonly

Optional subscription-filter capability created by this component.

urn: Output<string>

readonly

Inherited from urn

The stable logical URN used to distinctly address a resource, both before and after deployments.

Methods

getData(): Promise<any>

protectedasync

Inherited from getData

Retrieves the data produces by initialize. The data is immediately available in a derived class's constructor after the super(...) call to ComponentResource.

Returns

  • Promise<any>

getProvider(moduleMember: string): ProviderResource | undefined

Inherited from getProvider

Returns the provider for the given module member, if one exists.

Parameters

  • moduleMember (string)

Returns

  • ProviderResource | undefined

initialize( args: Inputs, opts?: ComponentResourceOptions, name?: string, type?: string, ): Promise<any>

protectedasync

Inherited from initialize

Can be overridden by a subclass to asynchronously initialize data for this component automatically when constructed. The data will be available immediately for subclass constructors to use. To access the data use getData.

Parameters

  • args (Inputs)
  • opts (ComponentResourceOptions, optional)
  • name (string, optional)
  • type (string, optional)

Returns

  • Promise<any>

registerOutputs( outputs?: Inputs | Promise<Inputs> | Output<Inputs>, ): void

protected

Inherited from registerOutputs

Registers synthetic outputs that a component has initialized, usually by allocating other child sub-resources and propagating their resulting property values.

Component resources can call this at the end of their constructor to indicate that they are done creating child resources. This is not strictly necessary as this will automatically be called after the initialize method completes.

Parameters

  • outputs (Inputs | Promise<Inputs> | Output<Inputs>, optional)

Returns

  • void

Static Methods

isInstance(obj: any): obj is ComponentResource<any>

static

Inherited from isInstance

Returns true if the given object is a CustomResource. This is designed to work even when multiple copies of the Pulumi SDK have been loaded into the same process.

Parameters

  • obj (any)

Returns

  • obj is ComponentResource<any>