-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codepipeline-actions): correctly serialize the userParameters pas…
…sed to the Lambda invoke Action. (#2537) BREAKING CHANGE: removed the `addPutJobResultPolicy` property when creating LambdaInvokeAction.
- Loading branch information
Showing
3 changed files
with
143 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
packages/@aws-cdk/aws-codepipeline-actions/test/lambda/test.lambda-invoke-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { expect, haveResourceLike } from "@aws-cdk/assert"; | ||
import codepipeline = require('@aws-cdk/aws-codepipeline'); | ||
import lambda = require('@aws-cdk/aws-lambda'); | ||
import { Aws, SecretValue, Stack, Token } from "@aws-cdk/cdk"; | ||
import { Test } from 'nodeunit'; | ||
import cpactions = require('../../lib'); | ||
|
||
// tslint:disable:object-literal-key-quotes | ||
|
||
export = { | ||
'Lambda invoke Action': { | ||
'properly serializes the object passed in userParameters'(test: Test) { | ||
const stack = stackIncludingLambdaInvokeCodePipeline({ | ||
key: 1234, | ||
}); | ||
|
||
expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { | ||
'Stages': [ | ||
{}, | ||
{ | ||
'Actions': [ | ||
{ | ||
'Configuration': { | ||
'UserParameters': '{"key":1234}', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
})); | ||
|
||
test.done(); | ||
}, | ||
|
||
'properly resolves any Tokens passed in userParameters'(test: Test) { | ||
const stack = stackIncludingLambdaInvokeCodePipeline({ | ||
key: new Token(() => Aws.region), | ||
}); | ||
|
||
expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { | ||
'Stages': [ | ||
{}, | ||
{ | ||
'Actions': [ | ||
{ | ||
'Configuration': { | ||
'UserParameters': { | ||
'Fn::Join': [ | ||
'', | ||
[ | ||
'{"key":"', | ||
{ | ||
'Ref': 'AWS::Region', | ||
}, | ||
'"}', | ||
], | ||
], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
})); | ||
|
||
test.done(); | ||
}, | ||
|
||
'properly resolves any stringified Tokens passed in userParameters'(test: Test) { | ||
const stack = stackIncludingLambdaInvokeCodePipeline({ | ||
key: new Token(() => null).toString(), | ||
}); | ||
|
||
expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', { | ||
'Stages': [ | ||
{}, | ||
{ | ||
'Actions': [ | ||
{ | ||
'Configuration': { | ||
'UserParameters': '{"key":null}', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
})); | ||
|
||
test.done(); | ||
}, | ||
}, | ||
}; | ||
|
||
function stackIncludingLambdaInvokeCodePipeline(userParams: { [key: string]: any }) { | ||
const stack = new Stack(); | ||
|
||
new codepipeline.Pipeline(stack, 'Pipeline', { | ||
stages: [ | ||
{ | ||
name: 'Source', | ||
actions: [ | ||
new cpactions.GitHubSourceAction({ | ||
actionName: 'GitHub', | ||
output: new codepipeline.Artifact(), | ||
oauthToken: SecretValue.plainText('secret'), | ||
owner: 'awslabs', | ||
repo: 'aws-cdk', | ||
}), | ||
], | ||
}, | ||
{ | ||
name: 'Invoke', | ||
actions: [ | ||
new cpactions.LambdaInvokeAction({ | ||
actionName: 'Lambda', | ||
lambda: new lambda.Function(stack, 'Lambda', { | ||
code: lambda.Code.cfnParameters(), | ||
handler: 'index.handler', | ||
runtime: lambda.Runtime.NodeJS810, | ||
}), | ||
userParameters: userParams, | ||
}), | ||
], | ||
}, | ||
], | ||
}); | ||
|
||
return stack; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters