Skip to content

opensite-ai/opensite-skills / aws-cdk

aws-cdk

Unverified

Authors, deploys, and troubleshoots AWS infrastructure using CDK with TypeScript or Python. Covers best practices, stack architecture, and construct patterns. Applies when writing CDK constructs, bootstrapping environments, running cdk deploy/synth/diff, fixing CDK or CloudFormation errors, planning stack structure, importing existing resources, resolving drift, or refactoring stacks without resource replacement.

references/v1-to-v2-migration.md

View on GitHub
# CDK v1 to v2 Migration

## Table of Contents

- [Overview](#overview)
- [V1 Import Paths](#v1-import-paths)
- [Wrong Construct Import](#wrong-construct-import)
- [Duplicate aws-cdk-lib](#duplicate-aws-cdk-lib)

---

## Overview

CDK v2 consolidated all `@aws-cdk/*` packages into a single `aws-cdk-lib` package and moved `Construct` to the standalone `constructs` package. These changes cause three common error patterns when migrating from v1 or when mixing v1/v2 code.

---

## V1 Import Paths

### Symptom

```
Cannot find module '@aws-cdk/aws-ec2'
Cannot find module '@aws-cdk/aws-s3'
Cannot find module '@aws-cdk/core'
```

### Cause

CDK v2 consolidated all `@aws-cdk/*` packages into `aws-cdk-lib`. Old v1 package names no longer resolve.

### Fix

Replace v1 imports with v2 equivalents:

```typescript
// Wrong (v1)
import * as ec2 from '@aws-cdk/aws-ec2';
import * as s3 from '@aws-cdk/aws-s3';
import { Construct } from '@aws-cdk/core';

// Correct (v2)
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
```

You MUST also remove all `@aws-cdk/*` packages from `package.json` dependencies and replace with a single `aws-cdk-lib` dependency.

---

## Wrong Construct Import

### Symptom

```
Argument of type 'this' is not assignable to parameter of type 'Construct'
```

This error appears even though the code looks correct — the types have the same name but come from different packages.

### Cause

`Construct` was imported from `@aws-cdk/core` or `aws-cdk-lib` instead of the standalone `constructs` package. In CDK v2, all constructs MUST extend `Construct` from the `constructs` package.

### Fix

```typescript
// Wrong
import { Construct } from 'aws-cdk-lib';
import { Construct } from '@aws-cdk/core';

// Correct
import { Construct } from 'constructs';
```

You MUST ensure `constructs` is listed as a dependency in `package.json`.

---

## Duplicate aws-cdk-lib

### Symptom

```
Argument of type 'Function' is not assignable to parameter of type 'IFunction'
Argument of type 'Bucket' is not assignable to parameter of type 'IBucket'
```

TypeScript uses structural typing, but CDK classes contain private members, which causes TypeScript to treat them nominally. When two copies of `aws-cdk-lib` exist, the private members originate from different class declarations, making types like `Function` and `IFunction` from different copies incompatible.

### Cause

Multiple copies of `aws-cdk-lib` exist in the module graph. Common causes:

- Monorepo with improperly hoisted dependencies
- Shared construct library declares `aws-cdk-lib` as a regular dependency instead of a peer dependency
- `npm link` or `file:` protocol pulling in a second copy

### Diagnosis

```bash
npm ls aws-cdk-lib
```

If more than one version appears, you have duplicates.

### Fix

1. You MUST make `aws-cdk-lib` and `constructs` **peer dependencies** in shared construct libraries
2. Run `npm dedupe` to collapse duplicates
3. In monorepos, hoist `aws-cdk-lib` to the root workspace
4. Verify with `npm ls aws-cdk-lib` — only one copy SHOULD appear

If `npm dedupe` alone does not resolve it, reset the install:

```bash
rm -rf node_modules && npm ci && npm dedupe
```
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall