AWS CDK Infrastructure as Code
Infrastructure as Code AWS CDK (Python default), CloudFormation
Delivery Constraint & Opportunity Analysis · Updated 1 month, 3 weeks ago
Content
Skill: AWS CDK Infrastructure as Code
Capability Domain: Infrastructure as Code
Technology Stack: AWS CDK (Python default), CloudFormation
Linked Activities: Model the Data Lake as CDK Stacks
Language
Greenfield lake repo: Python (aws-cdk-lib, pytest). TypeScript only if the host repo is already TypeScript. Do not mix.
Recipe
- Read
docs/lake-scope-contract.yaml. Stacks instantiate onlysourcesandviewslisted there. - Layout in the starter kit (
https://github.com/FeatureFactory-io/ops-lake-starter):infra/app.py,infra/ops_lake/deploy_stack.py,ingestion_stack.py,catalog_stack.py,eda_stack.py,scope.py. Customize from the filled contract; do not scaffold empty stacks. - Four stacks:
-DeployStack(OpsLakeDeploy): GitHub (or GitLab) OIDC provider + deploy IAM role. Trust bothsubpatterns (name-only and ID-qualified). OutputDeployRoleArn.
-IngestionStack: scoped ingestion Lambdas (GithubWebhookFn,GithubBackfillFn,GithubProjectsPollFnif github scoped), HTTP API, DynamoDB cursor table, raw/curated/athena-results buckets, SQS buffer,ParquetTransformFn.GithubBackfillFntimeout 10 min / 1024 MB.
-CatalogStack: Glue database, one crawler perviewsentry with daily EventBridge schedulecron(0 6 * * ? *), Athena workgroup (5GB scan cap), named preview queries.
-EdaStack: Streamlit mart on ECS Fargate + ALB (not App Runner — WebSockets unsupported). Imagelinux/amd64. Task role: Athena + Glue GetTables +curated_bucket.grant_read+ Athena results read/write. - Bucket encryption:
s3.BucketEncryption.KMS_MANAGED(SSE-KMS) andbucket_key_enabled=True(S3 Bucket Keys). Do not attach a customer-managedkms.Keyto buckets that also have S3→SQS notifications — CloudFormation hitsLakeKey -> RawBucket -> LakeKey. Without Bucket Keys, every PutObject/GetObject is a KMS request; one-file-per-event Parquet plus Glue/Athena reads burns the 20k always-free KMS requests in a single backfill (recapture X-15, 2026-09-15). Bucket Keys apply to new objects only. - pytest:
tests/unit/test_scope_contract.py,test_deploy_stack.py,test_ingestion_stack.py,test_catalog_stack.py,test_eda_stack.py. Use CDK contextskip_bundlingfor synth tests without Docker. Must be green before CI deploy. AssertBucketKeyEnabledis true on all three lake buckets. Copy-this tests stay in the starter kit. cdk deployfrom a laptop is bootstrap + one sandbox mint of OpsLakeDeploy only. Shared env is GHA/cdk deploy --all.
Copy-this tests
Template.from_stack on IngestionStack: 3 buckets, each SSEAlgorithm: aws:kms with BucketKeyEnabled: true, GithubWebhook present, Gitlab/Jira absent. CatalogStack: Glue database name from contract, crawler count == len(views), Athena workgroup name from contract. DeployStack: OIDC provider + IAM role. EdaStack: Fargate service + ALB, no App Runner.
Pitfalls
- Modeling GitlabWebhookFn / JiraPollFn when
sources: [github]. - Customer-managed KMS key shared by bucket + SQS notification (CFN cycle).
- SSE-KMS without S3 Bucket Keys (
bucket_key_enabled=False) — KMS Free Tier gone in one backfill morning. cdk deployfrom a laptop to a shared account after the OIDC role exists.- Putting Streamlit on App Runner (blank skeleton;
/_stcore/stream403). - Scaffolding empty
infra/instead of customizing the starter kit clone.
Details
- Capability Domain:
- Infrastructure as Code
- Technology Stack:
- AWS CDK (Python default), CloudFormation
- Created:
- 2 months ago
- Updated:
- 1 month, 3 weeks ago
Playbook
Activities Using This Skill 1
- Model the Data Lake as CDK Stacks Model and Deploy Infrastructure as Code