@flipdish/cdk-aspects

中文文档
0.23.0发布于 2026/10/07MITTypeScriptES Module零依赖近 30 天下载 1970

CDK Aspects for Flipdish serverless applications

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Available Aspects
  4. TagsAspect
  5. TableSettingsAspect
  6. Development Workflow (serverless-app-template only)
  7. Testing
  8. License
  9. Contributing

@flipdish/cdk-aspects

CDK Aspects for Flipdish Serverless Applications that provide consistent AWS resource configuration and tagging across our infrastructure.

Installation

npm install @flipdish/cdk-aspects

Usage

The package provides CDK Aspects that can be used to enforce consistent configuration and tagging across your AWS resources. Import and use the aspects in your SST configuration:

import { TableSettingsAspect, TagsAspect, addAspects } from '@flipdish/cdk-aspects';

// In your SST config
export default {
  async stacks(app) {
    // Add standard aspects
    addAspects(app, [
      new TagsAspect(serviceName, datadogTeamName),
      new TableSettingsAspect(app.stage)
    ]);

    // ... rest of your stack configuration
  }
} as SSTConfig;

Available Aspects

TagsAspect

Applies consistent tagging across all resources in your stacks. This includes service name and team name tags that are useful for resource organization and cost allocation.

new TagsAspect(serviceName, teamName)

TableSettingsAspect

Enforces consistent DynamoDB table settings across your application. This aspect ensures:

  • PAY_PER_REQUEST billing mode
  • Point-in-time recovery enabled
  • Appropriate partition key (pk) and sort key (sk) naming
  • Proper removal policies based on stage (RETAIN for production, DELETE for development)
  • AWS Backup daily snapshots for production/integration stages with configurable plan:
    • warm (default): warm storage only, 1–30 days (default 7)
    • warm-cold: warm for N days, then cold for 90 days (total N + 90)
new TableSettingsAspect(stage) // warm, 7 days
new TableSettingsAspect(stage, { planType: 'warm', warmRetentionDays: 7 })
new TableSettingsAspect(stage, { planType: 'warm-cold', warmRetentionDays: 7 }) // 7 warm + 90 cold

Development Workflow (serverless-app-template only)

This section is only relevant if you are working within the serverless-app-template repository, where this package is maintained.

  1. Local Development:

    • During development in serverless-app-template, use @serverless-app/cdk-aspects for local testing
    • Import statements follow the pattern:
      import { TableSettingsAspect, TagsAspect, addAspects } from '@serverless-app/cdk-aspects';
      
  2. Production Usage:

    • The serverless-app-template bootstrap process will automatically:
      • Update dependencies to use @flipdish/cdk-aspects
      • Replace import statements accordingly
      • Remove the local aspects package

For all other projects, simply install and import @flipdish/cdk-aspects as shown in the Installation and Usage sections above.

Testing

You can verify the aspects are working correctly by checking your CloudFormation template. Here's an example using Jest/Vitest:

import { Template } from 'aws-cdk-lib/assertions';
import { App } from 'sst/constructs';

describe('DynamoDB checks', () => {
  it('All tables have billing mode PAY_PER_REQUEST', () => {
    template.allResourcesProperties('AWS::DynamoDB::Table', {
      BillingMode: 'PAY_PER_REQUEST',
    });
  });

  it('All tables have point in time recovery enabled', () => {
    template.allResourcesProperties('AWS::DynamoDB::Table', {
      PointInTimeRecoverySpecification: {
        PointInTimeRecoveryEnabled: true,
      },
    });
  });

  it('All tables should have RETAIN removal policy in production but DELETE in dev', () => {
    checkTableDeletionPolicy(template, 'Delete');
    checkTableDeletionPolicy(prodStageTemplate, 'Retain');
  });
});

License

MIT

Contributing

This package is maintained in the serverless-app-template repository.

版本与发布记录

@flipdish/cdk-aspects 共发布 39 个版本,首次发布于 2025/04/17;过去 12 个月发布了 17 个版本。

版本发布日期距今
0.23.0latest2026/10/071 个月前
0.22.02026/09/171 个月前
0.21.02026/08/272 个月前
0.20.02026/08/043 个月前
0.19.02026/07/213 个月前
0.18.02026/07/213 个月前

关于 @flipdish/cdk-aspects 的常见问题

@flipdish/cdk-aspects 是什么?

CDK Aspects for Flipdish serverless applications

如何安装 @flipdish/cdk-aspects?

在项目目录运行 npm install @flipdish/cdk-aspects,或使用 pnpm add / yarn add / bun add。

@flipdish/cdk-aspects 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@flipdish/cdk-aspects 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@flipdish/cdk-aspects 可以商用吗?

@flipdish/cdk-aspects 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@flipdish/cdk-aspects 的下载量有多少?

根据 npm 官方下载统计,@flipdish/cdk-aspects 在 2026/10/15 – 2026/11/13 这 30 天内被下载 1,970 次,日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flipdish/cdk-aspects 还在维护吗?

最新版本 0.23.0 发布于 2026/10/07(1 个月前);至今共发布 39 个版本,其中过去 12 个月发布了 17 个;首次发布于 2025/04/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。