{"id":9575,"library":"cdktf-cdktf-provider-aws","title":"CDK for Terraform AWS Provider","description":"The `cdktf-cdktf-provider-aws` library provides a Pythonic interface to the AWS Terraform provider within the Cloud Development Kit for Terraform (CDKTF) ecosystem. It allows users to define AWS infrastructure using familiar Python constructs, which CDKTF then synthesizes into Terraform HCL for deployment. This library, currently at version 21.22.1, is updated frequently to reflect new versions of the underlying AWS Terraform provider and the `cdktf` core library.","status":"active","version":"21.22.1","language":"en","source_language":"en","source_url":"https://github.com/cdktf/cdktf-provider-aws.git","tags":["cdktf","terraform","aws","infrastructure-as-code","iac","cloud"],"install":[{"cmd":"pip install cdktf-cdktf-provider-aws","lang":"bash","label":"Install `cdktf-cdktf-provider-aws`"},{"cmd":"npm i -g cdktf-cli","lang":"bash","label":"Install CDKTF CLI (required)"}],"dependencies":[{"reason":"Required to define and synthesize Terraform configurations.","package":"cdktf","optional":false},{"reason":"Core dependency for CDKTF's construct-based architecture.","package":"constructs","optional":false}],"imports":[{"note":"The generated Python package uses `cdktf_cdktf_provider_aws` as its root namespace.","wrong":"from cdktf_aws import AwsProvider","symbol":"AwsProvider","correct":"from cdktf_cdktf_provider_aws.provider import AwsProvider"},{"note":"Each Terraform resource type typically resides in its own module named after the resource (e.g., `s3_bucket.py`).","wrong":"from cdktf_cdktf_provider_aws.s3 import S3Bucket","symbol":"S3Bucket","correct":"from cdktf_cdktf_provider_aws.s3_bucket import S3Bucket"}],"quickstart":{"code":"from constructs import Construct\nfrom cdktf import App, TerraformStack, TerraformOutput\nfrom cdktf_cdktf_provider_aws.provider import AwsProvider\nfrom cdktf_cdktf_provider_aws.s3_bucket import S3Bucket\nimport os\n\nclass MyAwsStack(TerraformStack):\n    def __init__(self, scope: Construct, id: str):\n        super().__init__(scope, id)\n\n        # Configure AWS Provider\n        AwsProvider(self, \"AWS\", \n                    region=os.environ.get('AWS_REGION', 'us-east-1'),\n                    access_key=os.environ.get('AWS_ACCESS_KEY_ID', ''),\n                    secret_key=os.environ.get('AWS_SECRET_ACCESS_KEY', ''))\n\n        # Create an S3 Bucket\n        bucket = S3Bucket(self, \"my-cdktf-unique-bucket\",\n                          bucket_prefix=\"my-cdktf-prefix-\",\n                          acl=\"private\",\n                          tags={\n                              \"Environment\": \"Development\",\n                              \"Project\": \"CDKTF-Demo\"\n                          })\n\n        # Output the bucket name\n        TerraformOutput(self, \"bucket_name\",\n                        value=bucket.bucket_domain_name,\n                        description=\"The domain name of the created S3 bucket\")\n\napp = App()\nMyAwsStack(app, \"my-cdktf-aws-stack\")\napp.synth()\n\n# To deploy, run: cdktf deploy my-cdktf-aws-stack","lang":"python","description":"This quickstart defines a `TerraformStack` that provisions a simple AWS S3 bucket using the `cdktf-cdktf-provider-aws` library. It configures the AWS provider and creates an S3 bucket with a unique prefix and tags. The bucket's domain name is then exported as a Terraform output. Ensure `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY` environment variables are set for deployment, or configure them via other AWS credential methods. After running `python main.py` (assuming the code is in `main.py`), use `cdktf deploy my-cdktf-aws-stack` to provision the resources."},"warnings":[{"fix":"Refer to the `cdktf` and Terraform AWS provider release notes. Upgrade `cdktf-cdktf-provider-aws` and `cdktf` to compatible versions, reviewing changelogs for attribute name changes or type changes. Use `cdktf diff` before `cdktf deploy` to see proposed changes.","message":"Provider regeneration (breaking changes in underlying Terraform AWS provider). The `cdktf-cdktf-provider-aws` library is a generated wrapper around the official Terraform AWS provider. When the upstream Terraform AWS provider introduces significant changes, or when the `cdktf` core library is updated, the provider library is regenerated. This can lead to breaking changes in resource attributes, arguments, or behavior.","severity":"breaking","affected_versions":"All versions, especially when upgrading `cdktf-cdktf-provider-aws` or `cdktf` across major/minor versions."},{"fix":"Check the `cdktf-cdktf-provider-aws` changelog or documentation for the bundled Terraform provider version. If necessary, you can override the provider version in your `cdktf.json` by adding `terraform.required_providers` for `aws`, but ensure compatibility with your installed `cdktf-cdktf-provider-aws` version.","message":"Terraform Provider versioning. `cdktf-cdktf-provider-aws` bundles a specific version of the Terraform AWS provider. If you need a different provider version (e.g., for a new AWS feature, bug fix, or to align with other Terraform configurations) or run into conflicts, you might need to manually configure provider requirements.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Ensure your development environment uses Python 3.9 or a newer version (e.g., 3.10, 3.11, 3.12). Using `pyenv` or `conda` can help manage multiple Python versions and virtual environments.","message":"Python version compatibility. The `cdktf-cdktf-provider-aws` library specifically requires Python `~=3.9`. Using an incompatible Python version (e.g., Python 3.8 or lower, or potentially Python 4.x in the future) will lead to installation failures or runtime errors.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Activate your Python virtual environment (if using one) and run `pip install cdktf-cdktf-provider-aws`. Ensure you are running your script from the correct environment.","cause":"The `cdktf-cdktf-provider-aws` library is not installed in the active Python environment, or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'cdktf_cdktf_provider_aws'"},{"fix":"Configure AWS credentials using environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`), an AWS config/credentials file (`~/.aws/credentials`), or by assuming an IAM role. Ensure the region is also correctly set either via environment variable or explicitly in the `AwsProvider` constructor.","cause":"AWS credentials are not configured or found by the AWS provider when `cdktf deploy` attempts to provision resources. The specific error message might vary slightly but indicates authentication failure.","error":"Error: creating S3 Bucket: NoCredentialProviders: no valid providers in chain. Deprecated."},{"fix":"Consult the `cdktf-cdktf-provider-aws` documentation for the specific resource (e.g., `S3Bucket`) or the official Terraform AWS provider documentation to find the correct attribute names. Use IDE autocompletion for guidance.","cause":"Attempting to access or set a non-existent, misspelled, or read-only attribute on a `cdktf-cdktf-provider-aws` resource or provider object. The generated Python classes strictly enforce the underlying Terraform schema.","error":"AttributeError: 'S3Bucket' object has no attribute 'bucket_name'"},{"fix":"Ensure that when you instantiate any construct, you provide both a parent scope (e.g., `self` within a `TerraformStack`) and a unique string `id`. For example: `S3Bucket(self, \"my-unique-bucket-id\", ...) `.","cause":"All Constructs in CDKTF (including providers and resources like `AwsProvider` or `S3Bucket`) require a `scope` (parent construct) and a unique `id` during instantiation.","error":"TypeError: __init__() missing 1 required positional argument: 'id'"}]}