Skip to content

Commit

Permalink
fix(lambda): compute platform missing for autocreated profiling group (
Browse files Browse the repository at this point in the history
…#9716)

follow up fix to #9285

currently the lambda construct provides support for profiling group creation via a boolean prop. however, the profiling group creation doesn't set the ComputePlatform value which is required to profile in lambda compute environment.

this PR explicitly sets the ComputePlatform when defining the profiling group in the Function construct. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
SeekerWing committed Aug 17, 2020
1 parent 90de605 commit a8f4c9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/@aws-cdk/aws-lambda/lib/function.ts
@@ -1,5 +1,5 @@
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import { IProfilingGroup, ProfilingGroup } from '@aws-cdk/aws-codeguruprofiler';
import { IProfilingGroup, ProfilingGroup, ComputePlatform } from '@aws-cdk/aws-codeguruprofiler';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as iam from '@aws-cdk/aws-iam';
import * as logs from '@aws-cdk/aws-logs';
Expand Down Expand Up @@ -572,7 +572,9 @@ export class Function extends FunctionBase {
};
} else if (props.profiling) {
this.validateProfilingEnvironmentVariables(props);
const profilingGroup = new ProfilingGroup(this, 'ProfilingGroup');
const profilingGroup = new ProfilingGroup(this, 'ProfilingGroup', {
computePlatform: ComputePlatform.AWS_LAMBDA,
});
profilingGroup.grantPublish(this.role);
profilingGroupEnvironmentVariables = {
AWS_CODEGURU_PROFILER_GROUP_ARN: profilingGroup.profilingGroupArn,
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda/test/test.function.ts
Expand Up @@ -197,6 +197,7 @@ export = testCase({

expect(stack).to(haveResource('AWS::CodeGuruProfiler::ProfilingGroup', {
ProfilingGroupName: 'MyLambdaProfilingGroupC5B6CCD8',
ComputePlatform: 'AWSLambda',
}));

expect(stack).to(haveResource('AWS::IAM::Policy', {
Expand Down

0 comments on commit a8f4c9f

Please sign in to comment.