Describe the bug
When setting { profiling: true }, the CDK creates a Profiling Group with an autogenerated name. This name is never set to AWS_CODEGURU_PROFILER_GROUP_NAME environment variable as stated in the official docs. This causes the Lambda to create another profiling group with a default name aws-lambda-<LAMBDA_FUNCTION_NAME>. Therefore, the Lambda runs into permissions issues when submitting profiles, as the CDK does not create permissions to submit to aws-lambda-<LAMBDA_FUNCTION_NAME>.
Expected Behavior
When setting { profiling: true }, Lambda submits profiles to Profiling Group created by CDK.
Current Behavior
When setting { profiling: true }, Lambda fails with permissions issues. Example errors:
INFO: Could not find a profiling group name from environment variable AWS_CODEGURU_PROFILER_GROUP_NAME. Using default profiling group name aws-lambda-<LAMBDA_FUNCTION_NAME>
codegurushadow.software.amazon.awssdk.services.codeguruprofiler.model.CodeGuruProfilerException: User: <USER_ARN> is not authorized to perform: codeguru-profiler:ConfigureAgent on resource: arn:aws:codeguru-profiler:<REGION>:<AWS_ACCOUNT_ID>:profilingGroup/aws-lambda-<LAMBA_FUNCTION_NAME> (Service: CodeGuruProfiler, Status Code: 403, Request ID: <REQUEST_ID>)
Reproduction Steps
Create Lambda function with Java runtime and { profiling: true }
Possible Solution
Set AWS_CODEGURU_PROFILER_GROUP_NAME: props.profilingGroup.profilingGroupName in
|
profilingGroupEnvironmentVariables = { |
and AWS_CODEGURU_PROFILER_GROUP_NAME: profilingGroup.profilingGroupName in
|
profilingGroupEnvironmentVariables = { |
Additional Information/Context
No response
CDK CLI Version
1.186.0 and 2.58.0
Framework Version
No response
Node.js Version
18.11.0
OS
MacOS
Language
Typescript
Language Version
No response
Other information
No response
Describe the bug
When setting
{ profiling: true }, the CDK creates a Profiling Group with an autogenerated name. This name is never set toAWS_CODEGURU_PROFILER_GROUP_NAMEenvironment variable as stated in the official docs. This causes the Lambda to create another profiling group with a default nameaws-lambda-<LAMBDA_FUNCTION_NAME>. Therefore, the Lambda runs into permissions issues when submitting profiles, as the CDK does not create permissions to submit toaws-lambda-<LAMBDA_FUNCTION_NAME>.Expected Behavior
When setting
{ profiling: true }, Lambda submits profiles to Profiling Group created by CDK.Current Behavior
When setting
{ profiling: true }, Lambda fails with permissions issues. Example errors:Reproduction Steps
Create Lambda function with Java runtime and
{ profiling: true }Possible Solution
Set
AWS_CODEGURU_PROFILER_GROUP_NAME: props.profilingGroup.profilingGroupNameinaws-cdk/packages/@aws-cdk/aws-lambda/lib/function.ts
Line 725 in fc70535
and
AWS_CODEGURU_PROFILER_GROUP_NAME: profilingGroup.profilingGroupNameinaws-cdk/packages/@aws-cdk/aws-lambda/lib/function.ts
Line 739 in fc70535
Additional Information/Context
No response
CDK CLI Version
1.186.0 and 2.58.0
Framework Version
No response
Node.js Version
18.11.0
OS
MacOS
Language
Typescript
Language Version
No response
Other information
No response