Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update peer dependency to aws-sdk v3 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog


## 3.0.0

- Updated peer dependency to aws-sdk version 3.

## 2.2.0

- Added `taskOptions` as 4th parameter. Allowing setting of `logPrefix` to differentiate
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ you secret and access keys separately from other resource information (such as `
You can handle this as follows:

```js
import AWS from 'aws-sdk/global'
import gulp from 'gulp'
import clone from 'gulp-clone'
import filter from 'gulp-filter'
Expand All @@ -132,7 +131,6 @@ gulp.task('deploy:aws', () => {
const cfOutput = gulp.src('deploy/resources.yaml').pipe(
cfDeploy(
{
credentials: new AWS.Config().credentials,
region,
},
{
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gulp-cf-deploy",
"version": "2.2.1",
"version": "3.0.0",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated major version due to breaking peerDependency change

"description": "Gulp plugin for deploying AWS CloudFormation stacks",
"main": "dist/deploy.js",
"typings": "dist/deploy.d.ts",
Expand All @@ -15,17 +15,17 @@
"through2": "^3.0.1"
},
"devDependencies": {
"@aws-sdk/client-cloudformation": "^3.78.0",
"@mindhive/tsconfig": "^1.2.0",
"@types/fancy-log": "^1.3.1",
"@types/gulp": "^4.0.5",
"@types/lodash": "^4.14.123",
"@types/node": "^8.0.0",
"@types/through2": "^2.0.34",
"aws-sdk": "^2.41.0",
"typescript": "^3.4.0"
},
"peerDependencies": {
"aws-sdk": "^2.41.0",
"@aws-sdk/client-cloudformation": "^3.78.0",
"gulp": "^4.0.0"
},
"author": "Damon Maria <[email protected]>",
Expand Down
39 changes: 21 additions & 18 deletions src/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import CloudFormation, {
import {
CloudFormationClient,
CloudFormationClientConfig,
CreateStackCommand,
CreateStackInput,
Parameters,
DescribeStackEventsCommand,
DescribeStacksCommand,
Parameter,
Stack,
StackEvent,
Types,
UpdateStackCommand,
UpdateStackInput,
} from 'aws-sdk/clients/cloudformation'
} from '@aws-sdk/client-cloudformation';
import through2 from 'through2'
import PluginError from 'plugin-error'
import log from 'fancy-log'
Expand Down Expand Up @@ -52,7 +57,7 @@ const simplifiedOutput = (state: Stack) =>
]),
)

interface IServiceOptions extends Types.ClientConfiguration {
interface IServiceOptions extends CloudFormationClientConfig {
region: string // We require region
}

Expand Down Expand Up @@ -94,15 +99,15 @@ export default (
}
const stackName = stackOptions.StackName
const logPrefix = options.logPrefix || stackName
const cfn = new CloudFormation({
const cfn = new CloudFormationClient({
apiVersion: '2010-05-15',
...serviceOptions,
})

const retrieveStackEvents = async (stackId: string) => {
const command = new DescribeStackEventsCommand({ StackName: stackId });
const eventsResult = await cfn
.describeStackEvents({ StackName: stackId })
.promise()
.send(command)
return takeWhile(
eventsResult.StackEvents,
e => !isInitialStackEvent(e, stackId),
Expand All @@ -123,7 +128,7 @@ export default (
)
}

const buildParameters = (): Parameters => [
const buildParameters = (): Parameter [] => [
...(stackOptions.Parameters || []),
...Object.entries(parameters).map(([k, v]) => ({
ParameterKey: k,
Expand All @@ -144,10 +149,10 @@ export default (
const reportedLogicalIds: string[] = []
let state
let delaySeconds = 2
const command = new DescribeStacksCommand({ StackName: StackId });
for (;;) {
const describeResult = await cfn
.describeStacks({ StackName: StackId })
.promise()
.send(command)
state = describeResult.Stacks![0]
const completed =
!isInProgress(state) ||
Expand Down Expand Up @@ -200,11 +205,11 @@ export default (
}
}

let initialState: CloudFormation.Stack | undefined
let initialState: Stack | undefined
try {
const command = new DescribeStacksCommand({ StackName: stackName });
const describeResult = await cfn
.describeStacks({ StackName: stackName })
.promise()
.send(command)
initialState = describeResult.Stacks![0]
} catch (e) {
if (e.code !== 'ValidationError') {
Expand Down Expand Up @@ -234,10 +239,8 @@ export default (
let resultState
let skipped = false
try {
const request = updating
? cfn.updateStack(deployParams)
: cfn.createStack(deployParams)
const deployResult = await request.promise()
const command = updating ? new UpdateStackCommand(deployParams) : new CreateStackCommand(deployParams)
const deployResult = await cfn.send(command)
resultState = await completedState({
StackId: deployResult.StackId!,
reportEvents: true,
Expand Down
Loading