Skip to content

Commit

Permalink
fix(lambda): generate correct metrics for aliases
Browse files Browse the repository at this point in the history
Lambda supports metrics on individual aliases by specifying the metric
dimensions with `FunctionName` set to the underlying function's `Name`,
and `ResourceName` set to the qualified function `Name` (i.e:
`FunctionName:aliasName`).

The previous iteration of this code used the function's ARN instead of
it's name, resulting in incorrect metrics.

Fixes #3724
  • Loading branch information
RomainMuller committed Aug 20, 2019
1 parent ab07af1 commit aee2fcf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-lambda/lib/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ export class Alias extends QualifiedFunctionBase implements IAlias {
return super.metric(metricName, {
dimensions: {
FunctionName: this.lambda.functionName,
// construct the ARN from the underlying lambda so that alarms on an alias
// construct the name from the underlying lambda so that alarms on an alias
// don't cause a circular dependency with CodeDeploy
// see: https://github.com/aws/aws-cdk/issues/2231
Resource: `${this.lambda.functionArn}:${this.aliasName}`
Resource: `${this.lambda.functionName}:${this.aliasName}`
},
...props
});
Expand Down
7 changes: 1 addition & 6 deletions packages/@aws-cdk/aws-lambda/test/test.alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,7 @@ export = {
'Fn::Join': [
'',
[
{
"Fn::GetAtt": [
"MyLambdaCCE802FB",
"Arn"
]
},
{ Ref: "MyLambdaCCE802FB" },
':prod'
]
]
Expand Down

0 comments on commit aee2fcf

Please sign in to comment.