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; capabilitycloudwatch; identity is the raw selectedargs.<capability>.name, or for resource policiesargs.resourcePolicy.policyNamethenargs.resourcePolicy.resourceArn; target${env}-${projectHash}-cloudwatch-${sanitiseNamePart(identity)}. - Provider children have parent
AwsCloudwatchand 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
nameusesstackAndPurpose${env}-${projectHash}-${purpose}throughbuildAwsNameFromCamelCasePurpose(...). 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
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. Usenew AwsCloudwatch(args, options).The component logical name is derived from the selected capability identity field. Identity fields must be plain strings, notpulumi.Input,pulumi.Output, or promises.options(ComponentResourceOptions, optional) — Optional settings controlling resource behaviour.
Returns
AwsCloudwatch
Hierarchy
ComponentResourceAwsCloudwatch
Properties
lambdaInvokePermissions: Resource[]
Lambda invoke permissions created for managed alarm actions and subscription destinations.
logGroup: LogGroup
Optional log-group capability created by this component.
logGroupName: Output<string>
Effective log-group name when logGroup capability is used.
logStream: LogStream
Optional log-stream capability created by this component.
metricAlarm: MetricAlarm
Optional metric-alarm capability created by this component.
metricFilter: LogMetricFilter
Optional metric-filter capability created by this component.
metricFilterMetricName: Output<string>
Metric-filter metric name when metricFilter capability is used.
metricFilterMetricNamespace: Output<string>
Metric-filter metric namespace when metricFilter capability is used.
resourcePolicy: LogResourcePolicy
Optional resource-policy capability created by this component.
subscriptionFilter: LogSubscriptionFilter
Optional subscription-filter capability created by this component.
urn: Output<string>
Inherited from urn
The stable logical URN used to distinctly address a resource, both before and after deployments.
Methods
getData(): Promise<any>
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>
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
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>
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>