Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 105 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,115 @@
# Runtime data
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Runtime data
pids
*.pid
*.seed
build
dist
logs
pids
*.pid.lock

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# OS
.DS_Store
.tmp
# Yarn Integrity file
.yarn-integrity

# Dotenv files
# dotenv environment variables file
.env
admin.env
.env.test

# Dependency directory
jspm_packages
node_modules
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Serverless V1.0
.serverless
# Next.js build output
.next

# Reports
coverage
results
# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
30 changes: 29 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
# Changelog - serverless-plugin-diff
# Changelog - serverless-plugin-diff-v4

<a name="4.0.0"></a>
## 1 January 2024: v4.0.0

Forked and updated for Serverless Framework v4.x compatibility -- [@stevenblack][@stevenblack]

### Added
- Serverless Framework v4.x compatibility
- Support for nested stacks via globbing
- Variable resolution using `provider.resolveVariable`
- `json-diff` integration for CloudFormation template comparisons
- Automatic execution after packaging with `after:package:finalize` hook
- Improved error handling for missing stacks and templates

### Changed
- Updated package name to `serverless-plugin-diff-v4`
- Replaced deprecated `serverless.variables.getValueFromSource` with `provider.resolveVariable`
- Changed hook from `before:package:initialize` to `after:package:finalize`
- Updated to use `json-diff` for CloudFormation template comparison
- Updated peer dependencies to require Serverless Framework v4.x

### Fixed
- Fixed variable resolution for Serverless Framework v4
- Improved error handling for missing deployed stacks
- Better handling of nested stack templates

---

<a name="3.0.0"></a>
## 6 February 2017: v3.0.0
Expand Down Expand Up @@ -42,5 +69,6 @@ Initial release -- [@nicka][@nicka]

---

[@stevenblack]: https://github.com/sblack4
[@nicka]: https://github.com/nicka
[@dougmoscrop]: https://github.com/dougmoscrop
97 changes: 97 additions & 0 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Installation and Usage Guide

## Quick Start

### 1. Install the Plugin

```bash
npm install --save-dev serverless-plugin-diff-v4
```

### 2. Add to Your serverless.yml

```yaml
plugins:
- serverless-plugin-diff-v4
```

### 3. Use the Plugin

The plugin runs automatically after packaging, or you can run it manually:

```bash
# Package your service
sls package

# Run diff manually
sls diff

# Or with specific stage/region
sls diff --stage prod --region us-west-2
```

## Using npm link for Development

If you want to test the plugin locally before publishing:

### 1. Link the Plugin

```bash
cd /path/to/serverless-plugin-diff-v4
npm link
```

### 2. Install Dependencies

```bash
npm install
```

### 3. Link in Your Project

```bash
cd /path/to/your-serverless-project
npm link serverless-plugin-diff-v4
```

### 4. Test

```bash
sls package
sls diff
```

## Features

- ✅ Serverless Framework v4.x compatibility
- ✅ Automatic execution after packaging
- ✅ Manual execution with `sls diff` command
- ✅ Variable resolution using `provider.resolveVariable`
- ✅ Nested stack support via globbing
- ✅ Better CloudFormation diffing with `cfn-diff`
- ✅ Graceful error handling
- ✅ Clear error messages for missing stacks

## Requirements

- Serverless Framework v4.x
- AWS credentials configured
- Deployed stack to compare against

## Troubleshooting

### "No local template found"
Run `sls package` first to generate the CloudFormation template.

### "Stack does not exist"
Deploy your stack first with `sls deploy`.

### "Could not resolve variable"
The plugin will log warnings for unresolved variables and continue. Check your variable syntax.

## Migration from v3

1. Uninstall old plugin: `npm uninstall serverless-plugin-diff`
2. Install new plugin: `npm install --save-dev serverless-plugin-diff-v4`
3. Update your `serverless.yml` to use `serverless-plugin-diff-v4`
4. The plugin now runs automatically after packaging
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Steven Black

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 41 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,63 @@
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)
[![Coverage-Status](https://coveralls.io/repos/github/nicka/serverless-plugin-diff/badge.svg?branch=master)](https://coveralls.io/github/nicka/serverless-plugin-diff?branch=master)
[![Build-Status](https://travis-ci.org/nicka/serverless-plugin-diff.svg?branch=master)](https://travis-ci.org/nicka/serverless-plugin-diff)
[![serverless](http://public.serverless.com/badges/v4.svg)](http://www.serverless.com)

# Serverless CloudFormation Diff
# Serverless CloudFormation Diff v4

## Overview

Plugin for Serverless Framework v3.x which compares your local AWS CloudFormation templates against deployed ones.
Plugin for Serverless Framework v4.x which compares your local AWS CloudFormation templates against deployed ones.

# Usage
This is a fork of the original `serverless-plugin-diff` updated for Serverless Framework v4 compatibility.

## Key Changes for v4

- Updated to use `after:package:finalize` hook instead of `before:package:initialize`
- Replaced deprecated `serverless.variables.getValueFromSource` with `provider.resolveVariable`
- Added support for nested stacks via globbing
- Updated to use `json-diff` for CloudFormation template comparison
- Improved error handling and variable resolution

## Usage

```bash
serverless diff --stage REPLACEME [--region REPLACEME]
```

<img width="1255" alt="screen shot 2016-11-05 at 14 53 04" src="https://cloud.githubusercontent.com/assets/195404/20030536/9e1a552c-a367-11e6-8e6d-2043f2a5d038.png">
The plugin will automatically run after packaging, or you can run it manually with the `diff` command.

# Install
## Install

Execute npm install in your Serverless project.

```bash
npm install --save-dev serverless-plugin-diff
npm install --save-dev serverless-plugin-diff-v4
```

Add the plugin to your `serverless.yml` file

```yml
plugins:
- serverless-plugin-diff
- serverless-plugin-diff-v4
```

## Requirements

- Serverless Framework v4.x
- AWS credentials configured
- Deployed stack to compare against

## Features

- Compares local CloudFormation templates against deployed AWS stacks
- Supports nested stacks
- Resolves Serverless variables in templates
- Uses `json-diff` for CloudFormation template comparisons
- Graceful error handling for missing stacks or templates

## Migration from v3

If you're migrating from the original `serverless-plugin-diff`:

1. Uninstall the old plugin: `npm uninstall serverless-plugin-diff`
2. Install this version: `npm install --save-dev serverless-plugin-diff-v4`
3. Update your `serverless.yml` to use `serverless-plugin-diff-v4`
4. The plugin now runs automatically after packaging, or use `sls diff` command
Loading