AWS cdk with python reading from env file

Table of Contents

  1. create a env file for python
  2. read from env values in your cdk code

Creating a env file in python

Creating a .env file in python is easy, in the root directory of the cdk project we can use the command

vi .env

we need to make sure that it’s in root directory and to really make python use it, we need to import it in requirements.txt and then import the library in python cdk

Lets look at a sample cdk applications, where we use the .env file to dynamically use key value pairs in the cdk, for example – name of the vpc, subnets range etc or environment prefixes


Posted

in

by

Tags: