# AWS::CodeGuruProfiler Construct Library

Amazon CodeGuru Profiler collects runtime performance data from your live applications, and provides recommendations that can help you fine-tune your application performance.

## Installation

Import to your project:

TypeScript:

```ts
import * as codeguruprofiler from 'aws-cdk-lib/aws-codeguruprofiler';
```

Python:

```python
import aws_cdk.aws_codeguruprofiler as codeguruprofiler
```

Java:

```java
import software.amazon.awscdk.services.codeguruprofiler.*;
```

C# / .NET:

```csharp
using Amazon.CDK.AWS.CodeGuruProfiler;
```

Golang:

```go
import codeguruprofiler "github.com/aws/aws-cdk-go/awscdk"
```

## Basic usage

Here's how to setup a profiling group and give your compute role permissions to publish to the profiling group to the profiling agent can publish profiling information:

TypeScript:

```ts
// The execution role of your application that publishes to the ProfilingGroup via CodeGuru Profiler Profiling Agent. (the following is merely an example)
const publishAppRole = new iam.Role(this, 'PublishAppRole', {
  assumedBy: new iam.AccountRootPrincipal(),
});

const profilingGroup = new codeguruprofiler.ProfilingGroup(this, 'MyProfilingGroup');
profilingGroup.grantPublish(publishAppRole);
```

Python:

```python
# The execution role of your application that publishes to the ProfilingGroup via CodeGuru Profiler Profiling Agent. (the following is merely an example)
publish_app_role = iam.Role(self, "PublishAppRole",
    assumed_by=iam.AccountRootPrincipal()
)

profiling_group = codeguruprofiler.ProfilingGroup(self, "MyProfilingGroup")
profiling_group.grant_publish(publish_app_role)
```

Java:

```java
// The execution role of your application that publishes to the ProfilingGroup via CodeGuru Profiler Profiling Agent. (the following is merely an example)
Role publishAppRole = Role.Builder.create(this, "PublishAppRole")
        .assumedBy(new AccountRootPrincipal())
        .build();

ProfilingGroup profilingGroup = new ProfilingGroup(this, "MyProfilingGroup");
profilingGroup.grantPublish(publishAppRole);
```

C# / .NET:

```csharp
// The execution role of your application that publishes to the ProfilingGroup via CodeGuru Profiler Profiling Agent. (the following is merely an example)
var publishAppRole = new Role(this, "PublishAppRole", new RoleProps {
    AssumedBy = new AccountRootPrincipal()
});

var profilingGroup = new ProfilingGroup(this, "MyProfilingGroup");
profilingGroup.GrantPublish(publishAppRole);
```

Golang:

```go
// The execution role of your application that publishes to the ProfilingGroup via CodeGuru Profiler Profiling Agent. (the following is merely an example)
publishAppRole := iam.NewRole(this, jsii.String("PublishAppRole"), &RoleProps{
	AssumedBy: iam.NewAccountRootPrincipal(),
})

profilingGroup := codeguruprofiler.NewProfilingGroup(this, jsii.String("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:

TypeScript:

```ts
const profilingGroup = new codeguruprofiler.ProfilingGroup(this, 'MyProfilingGroup', {
  computePlatform: codeguruprofiler.ComputePlatform.AWS_LAMBDA,
});
```

Python:

```python
profiling_group = codeguruprofiler.ProfilingGroup(self, "MyProfilingGroup",
    compute_platform=codeguruprofiler.ComputePlatform.AWS_LAMBDA
)
```

Java:

```java
ProfilingGroup profilingGroup = ProfilingGroup.Builder.create(this, "MyProfilingGroup")
        .computePlatform(ComputePlatform.AWS_LAMBDA)
        .build();
```

C# / .NET:

```csharp
var profilingGroup = new ProfilingGroup(this, "MyProfilingGroup", new ProfilingGroupProps {
    ComputePlatform = ComputePlatform.AWS_LAMBDA
});
```

Golang:

```go
profilingGroup := codeguruprofiler.NewProfilingGroup(this, jsii.String("MyProfilingGroup"), &ProfilingGroupProps{
	ComputePlatform: codeguruprofiler.ComputePlatform_AWS_LAMBDA,
})
```

## Types

### Constructs (L2)

- [`ProfilingGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.ProfilingGroup.html) Construct (L2) A new Profiling Group.

### Constructs (L1)

- [`CfnProfilingGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.CfnProfilingGroup.html) Construct (L1) Creates a profiling group.

### Structs

- [`CfnProfilingGroup.AgentPermissionsProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.CfnProfilingGroup.AgentPermissionsProperty.html) Struct The agent permissions attached to this profiling group.
- [`CfnProfilingGroup.ChannelProperty`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.CfnProfilingGroup.ChannelProperty.html) Struct Notification medium for users to get alerted for events that occur in application profile.
- [`CfnProfilingGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.CfnProfilingGroupProps.html) Struct Properties for defining a `CfnProfilingGroup`.
- [`ProfilingGroupProps`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.ProfilingGroupProps.html) Struct Properties for creating a new Profiling Group.

### Enums

- [`ComputePlatform`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.ComputePlatform.html) Enum The compute platform of the profiling group.

### Interfaces

- [`IProfilingGroup`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.IProfilingGroup.html) Interface IResource represents a Profiling Group.

### Facades

- [`ProfilingGroupGrants`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codeguruprofiler.ProfilingGroupGrants.html) Facade Collection of grant methods for a IProfilingGroupRef.
