# @anttiviljami/serverless-stack-output 中文文档

规范地址：https://npmcn.com/package/%40anttiviljami/serverless-stack-output/

版本：0\.3\.1
npm 元数据更新时间：2022-04-04T14:24:09.106Z
中文译文更新时间：2026-11-06T15:55:33.188Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40anttiviljami/serverless-stack-output
原文对照：https://npmcn.com/package/%40anttiviljami/serverless-stack-output/?lang=original
项目主页：https://github.com/anttiviljami/serverless-stack-output#readme
源码仓库：https://github.com/anttiviljami/serverless-stack-output

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：116 kB，18 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：2 个
- 首次发布：2018-12-11T13:59:13.431Z
- 最新版本发布：2018-12-16T12:06:45.355Z
- 近 30 天下载量：2822（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

处理 AWS 云格式堆栈输出的无服务器插件

## 安装

```sh
npm install @anttiviljami/serverless-stack-output
```

也可以使用：`pnpm add @anttiviljami/serverless-stack-output`、`yarn add @anttiviljami/serverless-stack-output`、`bun add @anttiviljami/serverless-stack-output`

## README

# 无服务器堆栈输出插件

[![npm](https://img.shields.io/npm/v/serverless-stack-output.svg)](https://www.npmjs.com/package/serverless-stack-output) [![license](https://img.shields.io/github/license/sbstjn/serverless-stack-output.svg)](https://github.com/sbstjn/serverless-stack-output/blob/master/LICENSE.md) [![CircleCI](https://img.shields.io/circleci/project/github/sbstjn/serverless-stack-output.svg)](https://circleci.com/gh/sbstjn/serverless-stack-output) [![Coveralls](https://img.shields.io/coveralls/sbstjn/serverless-stack-output.svg)](https://coveralls.io/github/sbstjn/serverless-stack-output)

A 类 [无服务器](https://serverless.com/) 插件将您的 AWS CloudFormation Stack 输出存储于 JSON/YAML/TOML 文件, 或将输出传递给 JavaScript 函数进行进一步处理 .

## 使用量

### 安装

```bash
$ > yarn add serverless-stack-output
```

```bash
$ > npm install serverless-stack-output
```

### 配置

```yaml
plugins:
  - serverless-stack-output

custom:
  output:
    handler: scripts/output.handler # Same syntax as you already know
    file: .build/stack.toml # toml, yaml, yml, and json format is available
```

### 处理器

根据上面的配置, 插件将搜索一个文件 `scripts/output.js` 内容如下:

```js
function handler (data, serverless, options) {
  console.log('Received Stack Output', data)
}

module.exports = { handler }
```

### 文件格式

用一个名字命名你的档案 `.json`, (中文(简体) ), `.toml`, (中文(简体) ), `.yaml`,或 `.yml` 扩展名,插件将注意格式化您的输出。 请确定要保存文件的位置是否存在 !

## 许可证

可以随意使用代码,它使用 [麻省理工学院许可证](https://npmcn.com/package/%40anttiviljami/serverless-stack-output/LICENSE.md)。 。 。 .

## 捐款

欢迎你们为这个项目出力

为了保证你有一个愉快的经验, 请阅读 [行为守则](https://npmcn.com/package/%40anttiviljami/serverless-stack-output/CODE_OF_CONDUCT.md)它概述了核心价值观,相信并将使共同工作成为更幸福的经历.

## 示例

插件在无服务器功能的情况下,以及在使用自定义 CloudFormation 资源时,效果很好. 以下示例配置将部署 AWS Lambda 函数, API Gateway, SQS Quue, 有 AccessKey 和 SecretKey 的 IAM 用户, 以及一个静态值 :

### 无服务器. yml

```yaml
service: sls-stack-output-example

plugins:
  - serverless-stack-output

package:
  exclude:
    - node_modules/**

custom:
  output:
    handler: scripts/output.handler
    file: .build/stack.toml

provider:
  name: aws
  runtime: nodejs6.10

functions:
  example:
    handler: functions/example.handle
    events:
      - http:
          path: example
          method: get
          cors: true

resources:
  Resources:
    ExampleQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: example-queue
    ExampleUser:
      Type: "AWS::IAM::User"
      Properties:
        UserName: example-user
        Policies:
          - PolicyName: ExampleUserSQSPolicy
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: "Allow"
                  Action:
                    - sqs:SendMessage
                  Resource:
                    - {"Fn::Join": [":", ["arn:aws:sqs:*", {"Ref": "AWS::AccountId"}, "example-queue"]]}
    ExampleUserKey:
      Type: AWS::IAM::AccessKey
      Properties:
        UserName:
          Ref: ExampleUser
  Outputs:
    ExampleUserKey:
      Value:
        Ref: ExampleUserKey
    ExampleUserSecret:
      Value: {"Fn::GetAtt": ["ExampleUserKey", "SecretAccessKey"]}
    ExampleStaticValue:
      Value: example-static-value
```

### 堆栈输出

#### 移动

```toml
ExampleUserSecret = "YourUserSecretKey"
ExampleUserKey = "YourUserAccessKey"
ExampleLambdaFunctionQualifiedArn = "arn:aws:lambda:us-east-1:AccountID:function:sls-stack-output-example-dev-example:9"
ExampleStaticValue = "example-static-value"
ServiceEndpoint = "https://APIGatewayID.execute-api.us-east-1.amazonaws.com/dev"
ServerlessDeploymentBucketName = "sls-stack-output-example-serverlessdeploymentbuck-BucketID"
```

#### 也门

```yaml
ExampleUserSecret: YourUserSecretKey
ExampleUserKey: YourUserAccessKey
ExampleLambdaFunctionQualifiedArn: 'arn:aws:lambda:us-east-1:AccountID:function:sls-stack-output-example-dev-example:9'
ExampleStaticValue: example-static-value
ServiceEndpoint: 'https://APIGatewayID.execute-api.us-east-1.amazonaws.com/dev'
ServerlessDeploymentBucketName: sls-stack-output-example-serverlessdeploymentbuck-BucketID
```

#### 贾森

```json
{
  "ExampleUserSecret": "YourUserSecretKey",
  "ExampleUserKey": "YourUserAccessKey",
  "ExampleLambdaFunctionQualifiedArn": "arn:aws:lambda:us-east-1:AccountID:function:sls-stack-output-example-dev-example:9",
  "ExampleStaticValue": "example-static-value",
  "ServiceEndpoint": "https://APIGatewayID.execute-api.us-east-1.amazonaws.com/dev",
  "ServerlessDeploymentBucketName": "sls-stack-output-example-serverlessdeploymentbuck-BucketID"
}
```

## 常见问题

### @anttiviljami/serverless-stack-output 是什么？

处理 AWS 云格式堆栈输出的无服务器插件

### 如何安装 @anttiviljami/serverless-stack-output？

在项目目录运行 npm install @anttiviljami/serverless-stack-output，或使用 pnpm add / yarn add / bun add。

### @anttiviljami/serverless-stack-output 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/anttiviljami\_\_serverless-stack-output 是否存在。

### @anttiviljami/serverless-stack-output 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @anttiviljami/serverless-stack-output 可以商用吗？

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

### @anttiviljami/serverless-stack-output 的下载量有多少？

根据 npm 官方下载统计，@anttiviljami/serverless-stack-output 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,822 次，日均约 94 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @anttiviljami/serverless-stack-output 还在维护吗？

最新版本 0\.3\.1 发布于 2018/12/16（7 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2018/12/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

