/cdktf-python

Project for exploring TFCDK

Primary LanguagePython

Up and running

First, you need to setup the necessary environment variables on Terraform cloud.

image

Then install pipenv as package management, for installing the dependencies:

pipenv install

Run synth command to verify if the source code is ready.

cdktf synth

Start deploy the infrastructure

cdktf deploy --auto-approve

Clean up command if no longer in use.

cdktf destroy --auto-approve

CDKTF Library Reference

From the CLI:

pipenv shell

import cdktf_cdktf_provider_aws

help(cdktf_cdktf_provider_aws.AwsProvider)

help(cdktf_cdktf_provider_aws.ecs)

From the Constructs website:

https://constructs.dev/packages/@cdktf/provider-aws/v/5.0.48/api/EcsCluster?lang=python&submodule=ecs

Tutorials

Python self: https://www.programiz.com/article/python-self-why

Common errors

Missing the ENV variables for AWS Authentication

╷
│ Error: error configuring Terraform AWS Provider: no valid credential sources for Terraform AWS Provider found.
│
│ Please see https://registry.terraform.io/providers/hashicorp/aws
│ for more information about providing credentials.
│
│ Error: NoCredentialProviders: no valid providers in chain
│ caused by: EnvAccessKeyNotFound: failed to find credentials in the environment.
│ SharedCredsLoad: failed to load profile, .
│ EC2RoleRequestError: no EC2 instance role found
│ caused by: RequestError: send request failed
│ caused by: Get "http://169.254.169.254/latest/meta-data/iam/security-credentials/": dial tcp 169.254.169.254:80: connect: no route to host
│
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on cdk.tf.json line 23, in provider.aws[0]:
│   23:       }
│