{"id":8856,"library":"aws-cdk-aws-codeguruprofiler","title":"AWS CDK CodeGuru Profiler (v1)","description":"The `aws-cdk-aws-codeguruprofiler` library provides AWS CDK (v1) constructs for provisioning AWS CodeGuru Profiler resources. It simplifies the creation and management of profiling groups and related configurations within your CDK applications. This entry is for CDK v1, with the current version being 1.204.0. AWS CDK typically follows a rapid release cadence, often aligning with AWS service updates.","status":"maintenance","version":"1.204.0","language":"en","source_language":"en","source_url":"https://github.com/aws/aws-cdk.git","tags":["aws-cdk","aws","cloud","profiling","codeguru","cdk-v1"],"install":[{"cmd":"pip install aws-cdk.core aws-cdk-aws-codeguruprofiler","lang":"bash","label":"Install for AWS CDK v1"}],"dependencies":[{"reason":"Core AWS CDK v1 library, required for all CDK v1 constructs.","package":"aws-cdk.core","optional":false},{"reason":"Base construct library for all CDK applications.","package":"constructs","optional":false}],"imports":[{"note":"This package is for AWS CDK v1. The `aws_cdk.lib` import pattern is specific to AWS CDK v2. Ensure your entire CDK application is consistently using v1 (`aws-cdk.core` and federated packages) or v2 (`aws-cdk-lib` monolithic package).","wrong":"from aws_cdk.lib.aws_codeguruprofiler import ProfilingGroup","symbol":"ProfilingGroup","correct":"from aws_cdk.aws_codeguruprofiler import ProfilingGroup"},{"note":"For AWS CDK v1, core constructs like App and Stack are directly imported from the top-level `aws_cdk` module (which comes from `aws-cdk.core` PyPI package).","wrong":"from aws_cdk.App import App","symbol":"App","correct":"from aws_cdk import App"}],"quickstart":{"code":"import os\nfrom aws_cdk import App, Stack, Environment\nfrom aws_cdk import aws_codeguruprofiler as codeguruprofiler\nfrom constructs import Construct\n\nclass CodeGuruProfilerStack(Stack):\n    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:\n        super().__init__(scope, construct_id, **kwargs)\n\n        profiling_group_name = os.environ.get(\"CODEGURU_PROFILING_GROUP_NAME\", \"MyDefaultProfilingGroup\")\n\n        # Create a CodeGuru Profiling Group\n        profiling_group = codeguruprofiler.ProfilingGroup(\n            self,\n            \"MyApplicationProfilingGroup\",\n            profiling_group_name=profiling_group_name,\n            # Compute Platform is typically configured via agent or defaults to 'Default'\n            # For AWS Lambda, explicit configuration may be needed or a different construct.\n            # You can add tags, notifications, etc. here.\n        )\n\n        # Output the ARN of the created profiling group\n        # cdk.CfnOutput(self, \"ProfilingGroupArn\", value=profiling_group.profiling_group_arn)\n\napp = App()\nCodeGuruProfilerStack(\n    app, \n    \"CodeGuruProfilerStack\",\n    env=Environment(account=os.environ.get(\"CDK_DEFAULT_ACCOUNT\"), region=os.environ.get(\"CDK_DEFAULT_REGION\"))\n)\napp.synth()","lang":"python","description":"This quickstart demonstrates how to define a basic AWS CodeGuru Profiling Group using the `aws-cdk-aws-codeguruprofiler` library in a CDK v1 application. It creates a `ProfilingGroup` resource with a configurable name. Remember to set `CDK_DEFAULT_ACCOUNT` and `CDK_DEFAULT_REGION` environment variables for deployment."},"warnings":[{"fix":"Migrate your entire CDK application to v2 by installing `aws-cdk-lib` and updating imports, or ensure you are consistently using v1 by installing `aws-cdk.core` and specific service packages like this one.","message":"This package (`aws-cdk-aws-codeguruprofiler`) is part of AWS CDK v1's federated package model. It is not compatible with AWS CDK v2, which uses a single monolithic package (`aws-cdk-lib`). Trying to mix v1 and v2 packages or import patterns will lead to `ModuleNotFoundError` or deployment issues.","severity":"breaking","affected_versions":"All versions of aws-cdk-aws-codeguruprofiler (v1) when used with aws-cdk-lib (v2)."},{"fix":"Attach an IAM policy with required CodeGuru Profiler permissions to the application's execution role and your CDK deployment role. Consider using `iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonCodeGuruProfilerAgentAccess')` for the application role.","message":"AWS CodeGuru Profiler requires appropriate IAM permissions for the application being profiled and the CDK deployment role. Ensure your execution roles have `codeguru-profiler:ConfigureAgent`, `codeguru-profiler:PostAgentProfile`, and other necessary permissions (e.g., `codeguru-profiler:CreateProfilingGroup` for the deployment role).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure profiling group names are unique. Use a dynamic name (e.g., suffixed with a unique ID or hash) for transient environments, or explicitly delete the old profiling group before redeployment.","message":"Profiling Group names must be unique within an AWS account and region. If you attempt to deploy a stack with a name that already exists (even from a previous failed deployment or manual creation), the deployment will fail.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"If targeting CDK v1, ensure you install `aws-cdk.core` and use v1 import patterns (e.g., `from aws_cdk import Stack`). If targeting CDK v2, uninstall all v1 `aws-cdk-*` packages and install `aws-cdk-lib`.","cause":"Attempting to use AWS CDK v2 import patterns (e.g., `from aws_cdk.lib import Stack`) while `aws-cdk-aws-codeguruprofiler` (a v1 package) is installed, or `aws-cdk-lib` is not installed.","error":"ModuleNotFoundError: No module named 'aws_cdk.lib'"},{"fix":"Change the `profiling_group_name` property in your CDK code to a unique name, or manually delete the existing profiling group in the AWS console before redeploying.","cause":"An AWS CodeGuru Profiling Group with the same name already exists in your AWS account and region, preventing the CDK from creating a new one.","error":"Resource handler returned message: \"The specified Profiling Group name already exists.\""},{"fix":"Grant `codeguru-profiler:CreateProfilingGroup`, `codeguru-profiler:TagResource`, and other relevant CodeGuru Profiler permissions to the IAM identity used for CDK deployment.","cause":"The IAM role or user deploying the CDK stack lacks the necessary permissions to create CodeGuru Profiler resources.","error":"User: arn:aws:iam::123456789012:user/myuser is not authorized to perform: codeguru-profiler:CreateProfilingGroup on resource: arn:aws:codeguru-profiler:us-east-1:123456789012:profilingGroup/MyProfilingGroup"}]}