Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codeguruprofiler): add support for ComputePlatform in ProfilingGroup #9391

Merged
merged 5 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-codeguruprofiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ const publishAppRole = new Role(stack, 'PublishAppRole', {
const profilingGroup = new ProfilingGroup(stack, 'MyProfilingGroup');
profilingGroup.grantPublish(publishAppRole);
```

### Compute Platform configuration

Code Guru Profiler supports multiple compute environments.
They can be configured when creating a Profiling Group by using the `computePlatform` property:

```ts
const profilingGroup = new ProfilingGroup(stack, 'MyProfilingGroup', {
computePlatform: ComputePlatform.AWS_LAMBDA,
});
```
24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-codeguruprofiler/lib/profiling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ import { Grant, IGrantable } from '@aws-cdk/aws-iam';
import { Construct, IResource, Lazy, Resource, Stack } from '@aws-cdk/core';
import { CfnProfilingGroup } from './codeguruprofiler.generated';

/**
* The compute platform of the profiling group.
*/
export enum ComputePlatform {
/**
* Use AWS_LAMBDA if your application runs on AWS Lambda.
*/
AWS_LAMBDA = 'AWSLambda',

/**
SeekerWing marked this conversation as resolved.
Show resolved Hide resolved
* Use Default if your application runs on a compute platform that is not AWS Lambda,
* such an Amazon EC2 instance, an on-premises server, or a different platform.
*/
DEFAULT = 'Default',
}

/**
* IResource represents a Profiling Group.
*/
Expand Down Expand Up @@ -97,6 +113,13 @@ export interface ProfilingGroupProps {
*/
readonly profilingGroupName?: string;

/**
* The compute platform of the profiling group.
SeekerWing marked this conversation as resolved.
Show resolved Hide resolved
*
* @default ComputePlatform.DEFAULT
*/
readonly computePlatform?: ComputePlatform;

}

/**
Expand Down Expand Up @@ -158,6 +181,7 @@ export class ProfilingGroup extends ProfilingGroupBase {

const profilingGroup = new CfnProfilingGroup(this, 'ProfilingGroup', {
profilingGroupName: this.physicalName,
computePlatform: props.computePlatform,
});

this.profilingGroupName = this.getResourceNameAttribute(profilingGroup.ref);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from '@aws-cdk/assert';
import { expect, haveResourceLike } from '@aws-cdk/assert';
import { AccountRootPrincipal, Role } from '@aws-cdk/aws-iam';
import { Stack } from '@aws-cdk/core';
import { ProfilingGroup } from '../lib';
import { ProfilingGroup, ComputePlatform } from '../lib';

/* eslint-disable quote-props */

Expand Down Expand Up @@ -188,6 +188,18 @@ describe('profiling group', () => {
});
});

test('allows setting its ComputePlatform', () => {
const stack = new Stack();
new ProfilingGroup(stack, 'MyProfilingGroup', {
profilingGroupName: 'MyAwesomeProfilingGroup',
computePlatform: ComputePlatform.AWS_LAMBDA,
});

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

test('default profiling group without name', () => {
const stack = new Stack();
new ProfilingGroup(stack, 'MyProfilingGroup', {
Expand Down