-
Notifications
You must be signed in to change notification settings - Fork 26
/
cdk.py
39 lines (28 loc) · 1.07 KB
/
cdk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
from aws_cdk import Environment, Stack, App
from aws_cdk import aws_ec2 as ec2
from constructs import Construct
# https://docs.aws.amazon.com/cdk/latest/guide/environments.html
env_profile = Environment(
account=os.environ.get('CDK_DEPLOY_ACCOUNT', os.environ['CDK_DEFAULT_ACCOUNT']),
region=os.environ.get('CDK_DEPLOY_REGION', os.environ['CDK_DEFAULT_REGION'])
)
class DebugStack(Stack):
def __init__(self, scope: Construct, id_: str, props, **kwargs) -> None:
super().__init__(scope, id_, **kwargs)
vpc = ec2.Vpc.from_lookup(self, "VPC", is_default=True)
print(f">>> vpc_id: {vpc.vpc_id}")
print(">>> vpc.public_subnets: ")
for subnet in vpc.public_subnets:
print(subnet.subnet_id)
class DebugApp(App):
def __init__(self):
super().__init__()
DebugStack(self, "debug-stack", props={}, env=env_profile)
if __name__ == '__main__':
DebugApp().synth()
# Usage:
# aws sso login --profile dev
# yawsso -p dev
# npx cdk synth --app "python cdk.py" --profile dev
# npx cdk context -j | jq