import cloudwatch = require('@aws-cdk/aws-cloudwatch'); import events = require('@aws-cdk/aws-events'); import iam = require('@aws-cdk/aws-iam'); import logs = require('@aws-cdk/aws-logs'); import s3n = require('@aws-cdk/aws-s3-notifications'); import cdk = require('@aws-cdk/cdk'); import { FunctionArn } from './lambda.generated'; import { Permission } from './permission'; /** * Represents a Lambda function defined outside of this stack. */ export interface FunctionRefProps { /** * The ARN of the Lambda function. * Format: arn::lambda:::function: */ functionArn: FunctionArn; /** * The IAM execution role associated with this function. * If the role is not specified, any role-related operations will no-op. */ role?: iam.Role; } export declare abstract class FunctionRef extends cdk.Construct implements events.IEventRuleTarget, logs.ILogSubscriptionDestination, s3n.IBucketNotificationDestination { /** * Creates a Lambda function object which represents a function not defined * within this stack. * * Lambda.import(this, 'MyImportedFunction', { lambdaArn: new LambdaArn('arn:aws:...') }); * * @param parent The parent construct * @param name The name of the lambda construct * @param ref A reference to a Lambda function. Can be created manually (see * example above) or obtained through a call to `lambda.export()`. */ static import(parent: cdk.Construct, name: string, ref: FunctionRefProps): FunctionRef; /** * Return the given named metric for this Lambda */ static metricAll(metricName: string, props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of Errors executing all Lambdas * * @default sum over 5 minutes */ static metricAllErrors(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the Duration executing all Lambdas * * @default average over 5 minutes */ static metricAllDuration(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of invocations of all Lambdas * * @default sum over 5 minutes */ static metricAllInvocations(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of throttled invocations of all Lambdas * * @default sum over 5 minutes */ static metricAllThrottles(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of concurrent executions across all Lambdas * * @default max over 5 minutes */ static metricAllConcurrentExecutions(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of unreserved concurrent executions across all Lambdas * * @default max over 5 minutes */ static metricAllUnreservedConcurrentExecutions(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * The name of the function. */ abstract readonly functionName: FunctionName; /** * The ARN fo the function. */ abstract readonly functionArn: FunctionArn; /** * The IAM role associated with this function. */ abstract readonly role?: iam.Role; /** * Whether the addPermission() call adds any permissions * * True for new Lambdas, false for imported Lambdas (they might live in different accounts). */ protected abstract readonly canCreatePermissions: boolean; /** * Indicates if the policy that allows CloudWatch logs to publish to this lambda has been added. */ private logSubscriptionDestinationPolicyAddedFor; /** * Adds a permission to the Lambda resource policy. * @param id The id ƒor the permission construct */ addPermission(id: string, permission: Permission): void; addToRolePolicy(statement: cdk.PolicyStatement): void; /** * Returns a RuleTarget that can be used to trigger this Lambda as a * result from a CloudWatch event. */ asEventRuleTarget(ruleArn: events.RuleArn, ruleId: string): events.EventRuleTargetProps; /** * Return the given named metric for this Lambda */ metric(metricName: string, props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the Errors executing this Lambda * * @default sum over 5 minutes */ metricErrors(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the Duration of this Lambda * * @default average over 5 minutes */ metricDuration(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of invocations of this Lambda * * @default sum over 5 minutes */ metricInvocations(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; /** * Metric for the number of throttled invocations of this Lambda * * @default sum over 5 minutes */ metricThrottles(props?: cloudwatch.MetricCustomization): cloudwatch.Metric; logSubscriptionDestination(sourceLogGroup: logs.LogGroup): logs.LogSubscriptionDestination; /** * Export this Function (without the role) */ export(): FunctionRefProps; /** * Allows this Lambda to be used as a destination for bucket notifications. * Use `bucket.onEvent(lambda)` to subscribe. */ asBucketNotificationDestination(bucketArn: cdk.Arn, bucketId: string): s3n.BucketNotificationDestinationProps; private parsePermissionPrincipal; } export declare class FunctionName extends cdk.Token { }