title: How can I deploy cdk python to multiple environment to self.node.try_get_context('env') and some logic to specify where the stack gets deployed
body: <p>I have created the following vpc class using python aws cdk, I need help understanding how to dynamicaly set the env  variable through self.node.try_get_context('env') to represent the environment where the stack will be deployed, for example prod,dev,stg etc. since I'm reusing it in my logic to formulate naming convention for the stack.</p>
  <p>I have assigned env variables in the cdk.json as
  &quot;env_stg&quot;: &quot;stg&quot;,
  &quot;env_prd&quot;: &quot;prd&quot;,</p>
  <p>I can call them individually but lack understanding calling them dynamically to affect my environments on the fly.</p>
  <p>I really appreciate any help</p>
  <pre class="lang-py prettyprint-override"><code>class VPC(Stack):
  
      def __init__(self, scope: Construct, construct_id: str, **kwargs) -&gt; None:
          super().__init__(scope, construct_id, **kwargs)
  
          env = self.node.try_get_context('env')
  
          self.vpc =ec2.Vpc(self, &quot;Stg&quot;,
              cidr = '10.0.0.0/16',
              max_azs = 2,
              enable_dns_support = True,
              enable_dns_hostnames = True,
                  subnet_configuration = [
                      ec2.SubnetConfiguration(
                          name = 'Public',
                          subnet_type = ec2.SubnetType.PUBLIC,
                          cidr_mask = 24
                      ),
                      ec2.SubnetConfiguration(
                          name = 'Isolated',
                          subnet_type = ec2.SubnetType.PRIVATE_ISOLATED,
                          cidr_mask = 24                      
                      )
                  ]       
          )
  
          # Store all private subnets in Parameter store 
  
          private_subnets = [subnet.subnet_id for subnet in self.vpc.private_subnets]
  
          # public_subnets = [subnet.subnet_id for subnet in self.vpc.public_subnets]
          count = 1 
          for subnets in private_subnets:
              ssm.StringParameter(self, 'private-subnet-'+str(count),
              string_value = subnets,
              parameter_name = '/'+env+'/pivate-subnet-'+str(count)
              )
              count += 1
  </code></pre>