Skip to content

Commit 8bfa695

Browse files
authored
fix(codeguruprofiler): imported profiling group environment configured with stack region (#23568)
This resource missed the common pattern of configuring the resource environment from the arn, which results in the region being that of the stack and not the profiling group. This means that integrations that look at this (like the lambda profiling integration) will configure the wrong region for the resource. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 94102c1 commit 8bfa695

File tree

12 files changed

+486
-84
lines changed

12 files changed

+486
-84
lines changed

packages/@aws-cdk/aws-codeguruprofiler/lib/profiling-group.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ export enum ComputePlatform {
2525
export interface IProfilingGroup extends IResource {
2626

2727
/**
28-
* A name for the profiling group.
28+
* The name of the profiling group.
2929
*
3030
* @attribute
3131
*/
3232
readonly profilingGroupName: string;
3333

34+
/**
35+
* The ARN of the profiling group.
36+
*
37+
* @attribute
38+
*/
39+
readonly profilingGroupArn: string;
40+
3441
/**
3542
* Grant access to publish profiling information to the Profiling Group to the given identity.
3643
*
@@ -158,7 +165,9 @@ export class ProfilingGroup extends ProfilingGroupBase {
158165
public readonly profilingGroupArn = profilingGroupArn;
159166
}
160167

161-
return new Import(scope, id);
168+
return new Import(scope, id, {
169+
environmentFromArn: profilingGroupArn,
170+
});
162171
}
163172

164173
/**

packages/@aws-cdk/aws-codeguruprofiler/test/integ.profiler-group-import-functions.js.snapshot/ProfilingGroupTestStack.assets.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"version": "21.0.0",
2+
"version": "22.0.0",
33
"files": {
4-
"49d6a3151509f39124c2f82b21cf55a8a1364289fce8b6f8b764af6e204c6647": {
4+
"379c030c914943b66d3323572f1c454b9868c7d89ff12a9dbc092112c6580e80": {
55
"source": {
66
"path": "ProfilingGroupTestStack.template.json",
77
"packaging": "file"
88
},
99
"destinations": {
1010
"current_account-current_region": {
1111
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12-
"objectKey": "49d6a3151509f39124c2f82b21cf55a8a1364289fce8b6f8b764af6e204c6647.json",
12+
"objectKey": "379c030c914943b66d3323572f1c454b9868c7d89ff12a9dbc092112c6580e80.json",
1313
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
1414
}
1515
}

packages/@aws-cdk/aws-codeguruprofiler/test/integ.profiler-group-import-functions.js.snapshot/ProfilingGroupTestStack.template.json

+6
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
"Value": {
9393
"Ref": "ProfilingGroupWithImplicitlySetNameProfilingGroup21CDF1FC"
9494
}
95+
},
96+
"ImportedFromArnProfilingGroupName": {
97+
"Value": "MyAwesomeProfilingGroup"
98+
},
99+
"ImportedFromArnProfilingGroupArn": {
100+
"Value": "arn:aws:codeguru-profiler:a-region-1:1234567890:profilingGroup/MyAwesomeProfilingGroup"
95101
}
96102
},
97103
"Parameters": {

0 commit comments

Comments
 (0)