@adaptiveworx/iac-aws

中文文档
0.6.1发布于 2026/10/30Apache-2.0TypeScriptES Module零依赖构建来源已验证近 30 天下载 5848

Reusable Pulumi infrastructure components for AWS — VPC, IAM cross-account roles, GitHub Actions OIDC, and IAM policy helpers.

原始使用文档
文档目录10 节
  1. Install
  2. Components
  3. Usage
  4. SharedVpc and IPv6
  5. Tier roles, sharing and renames
  6. Upgrading to 0.6.0
  7. Upgrading to 0.5.0
  8. Upgrading to 0.4.0
  9. Versioning & releases
  10. License

@adaptiveworx/iac-aws

Reusable Pulumi infrastructure components for AWS, written in TypeScript.

Part of AdaptiveWorX iac-core — a suite of open-source IaC libraries for multi-cloud Pulumi deployments.

Install

pnpm add @adaptiveworx/iac-aws @pulumi/aws @pulumi/pulumi

@pulumi/aws and @pulumi/pulumi are peer dependencies — bring your own versions.

Components

ComponentPurpose
SharedVpcMulti-tier VPC with NAT, flow logs, RAM sharing, configurable per-tier CIDR, optional IPv6 dual-stack on every subnet
CrossAccountIAMRolesCross-account Pulumi role + foundation access role for product-line architectures
GitHubActionsOIDCOIDC provider + deploy role for GitHub Actions CI/CD
IAM policy helpersComposable policy document builders

Usage

import { SharedVpc, CrossAccountIAMRoles, GitHubActionsOIDC } from "@adaptiveworx/iac-aws";

const vpc = new SharedVpc("dev-use1", {
  environment: "dev",
  region: "us-east-1",
  accountId: "123456789012",
  orgPrefix: "worx",
  vpcCidr: "10.10.0.0/16",
  availabilityZones: ["us-east-1a", "us-east-1b", "us-east-1c"],
  natGatewayCount: 3,
  enableIpv6: true, // dual-stack: a /64 on every subnet
  subnetTiers: [
    // With enableIpv6 every tier declares a unique, permanent ipv6Slot (0–15). role names the
    // workloads a tier holds; shareWith names the accounts it is shared with.
    { name: "public", role: "load-balancers", routeToInternet: true, shareWith: [], ipv6Slot: 0 },
    { name: "private", role: "apps", routeToInternet: false, shareWith: ["worx-app-dev"], ipv6Slot: 1 },
    { name: "data", role: "databases", routeToInternet: false, shareWith: ["worx-app-dev"], ipv6Slot: 2 },
  ],
  flowLogs: { enabled: true, trafficType: "ALL", retentionDays: 90 },
  sharedAccounts: { "210987654321": "worx-app-dev" },
  tags: {},
});

SharedVpc and IPv6

enableIpv6: true makes the VPC dual-stack throughout: an Amazon-provided /56 on the VPC; on every subnet a /64 (netnum = ipv6Slot * 16 + AZ-letter index, so adding an AZ or a tier never renumbers an existing subnet) with IPv6 assigned to new network interfaces; IPv6 rules on every tier NACL (numbered IPv4 counterpart + 1000, plus UDP return and ICMPv6 Packet Too Big); ::/0 to the internet gateway on public tiers and to an egress-only gateway on private tiers, with or without NAT; dual-stack VPC endpoints where the service supports IPv6.

  • allowIpv4PublicIngress (default false, since 0.5.0): no internet-initiated IPv4 inbound on the public tier. Set it to true only for a production-facing edge; it adds IPv4 443/80 inbound (rules 100/110) to the public NACL.
  • allowIpv6PublicIngress (default false): no internet-initiated IPv6 inbound; the tiers keep their required egress and its return traffic. Set it to true only for a production-facing edge that must accept internet-initiated IPv6; it adds IPv6 443/80 inbound to the public NACL. The public ::/0 route is always present (it is IPv6 egress), so security groups remain the control on inbound IPv6.
  • IPv6 egress cannot reach IPv4-only destinations (e.g. github.com, ghcr.io), and there is no DNS64/NAT64. natGatewayCount: 0 with private tiers is valid only when their workloads use VPC endpoints or IPv6-capable destinations exclusively.

Details: docs/security-implementation.md.

Tier roles, sharing and renames

  • role names the workloads a tier holds. It is tagged Role on the tier's subnets and NACL. Required (0.6.0).
  • shareWith lists the accounts (by their names in sharedAccounts) a tier's subnets are shared with through RAM. A tier sharing with every account goes in the main share; a narrower set gets a share of its own; [] shares with no account. Required (0.6.0); every name must be in sharedAccounts (fail closed). shareViaRam was removed in 0.6.0 and is refused: replace shareViaRam: true with every account in sharedAccounts, false with []. The default tiers (defaultSubnetTiers(sharedAccounts)) share private and data with every account.
  • formerNames renames a tier without replacing anything: every resource named after the tier carries its old logical name as a Pulumi alias, so the preview shows tag updates only. The standard outputs (publicSubnetIds, privateSubnetIds, dataSubnetIds) and NAT placement follow a renamed tier through its former name. tierSubnetIds lists every tier by its current name.
  • Each subnet is tagged AzId with its zone ID (zone names map to physical zones per account). Pass availabilityZoneIds or let the component look them up (aws.getAvailabilityZones); under Pulumi mocks, return names and zoneIds for that call.
  • Exported helpers: tierAliases, tierNamed, validateTierSharing, tierShareTargets, legacyRamAssociationNames.

See each component's source for its full options interface.

Upgrading to 0.6.0

Every consumer: the next preview renames each subnet's RAM association from a running index (<env>-ram-<tier>-<n>) to tier and AZ letter (<env>-ram-<tier>-<a…p>) through an alias, and adds the AzId tag (plus Role where declared) to subnets. Nothing is replaced. Test suites under mocks must answer aws:index/getAvailabilityZones:getAvailabilityZones with names and zoneIds, or pass availabilityZoneIds.

A stack that renames tiers, moves to shareWith or stops sharing a tier in the same apply: pass legacyRamSharedTiers with the tiers that were in the main share before, by the names then applied (e.g. ["public", "private", "data"]). Without it the associations it keeps are deleted and recreated, which briefly unshares their subnets. Check the preview: a kept tier's associations must show as renames, never as create plus delete.

Upgrading to 0.5.0

Who must act: consumers with a public tier whose public subnets take internet-initiated HTTPS/HTTP over IPv4 (e.g. a public load balancer). Set allowIpv4PublicIngress: true for them.

The public tier NACL's TCP 443 and 80 rules from 0.0.0.0/0 (rules 100 and 110) are now opt-in, symmetric with allowIpv6PublicIngress. Without the flag the next preview deletes those two rule entries per public tier and changes nothing else. The VPC CIDR rule (95) and the return-traffic rule (120) stay, so public-tier targets remain reachable from inside the VPC and keep their egress.

Upgrading to 0.4.0

0.4.0 is the release that marks the SharedVpc IPv6 change as breaking. The change itself first shipped in 0.3.4, which is deprecated: it was released as a patch although it breaks some consumers. Pin to 0.3.3 or move to 0.4.0; don't use 0.3.4.

Who must act: consumers that set enableIpv6: true.

  • Custom subnetTiers: every tier must declare ipv6Slot (an integer 0–15, unique across tiers). Without it the component throws at construction, so nothing is deployed. Choose the slots once and never change them: a tier's slot fixes its subnets' /64s.
  • Default tiers: they carry slots 0/1/2, so construction succeeds, but the next preview turns on IPv6 everywhere. Every subnet gains a /64 and assign-on-create (in-place updates, never replacements), every tier NACL gains IPv6 rules, private tiers gain an egress-only gateway route, and endpoints become dual-stack. Review it as a deliberate network change, per environment.
  • allowIpv6PublicIngress now defaults to false, and the public ::/0 route is always present with IPv6 (see SharedVpc and IPv6).

Consumers without enableIpv6 see no change.

Versioning & releases

This package ships independent semver. Below 1.0, a breaking change bumps the minor version (0.3.x → 0.4.0) and features and fixes bump the patch. Breaking changes are marked (!), so a ^0.y.z range never admits one. See the root CHANGELOG conventions and this package's CHANGELOG.md.

License

Apache-2.0 — see LICENSE and NOTICE.

版本与发布记录

@adaptiveworx/iac-aws 共发布 16 个版本,首次发布于 2026/04/29;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.6.1latest2026/10/309 天前
0.6.02026/10/2612 天前
0.5.12026/10/2613 天前
0.5.02026/10/1127 天前
0.4.02026/10/1028 天前
0.3.42026/10/1028 天前

关于 @adaptiveworx/iac-aws 的常见问题

@adaptiveworx/iac-aws 是什么?

Reusable Pulumi infrastructure components for AWS — VPC, IAM cross-account roles, GitHub Actions OIDC, and IAM policy helpers.

如何安装 @adaptiveworx/iac-aws?

在项目目录运行 npm install @adaptiveworx/iac-aws,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@pulumi/aws(^7.0.0)、@pulumi/pulumi(^3.0.0)、@adaptiveworx/iac-core(^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.6.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adaptiveworx/iac-aws 支持 TypeScript 吗?

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

@adaptiveworx/iac-aws 支持 ESM 还是 CommonJS?

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

@adaptiveworx/iac-aws 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@adaptiveworx/iac-aws 可以商用吗?

@adaptiveworx/iac-aws 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@adaptiveworx/iac-aws 的下载量有多少?

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

@adaptiveworx/iac-aws 还在维护吗?

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