-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BREAKING] Move the Lambda Invoke CodePipeline Action. (#401)
This commit moves the Lambda Invoke Action from the codepipeline module to its dedicated, new lambda-codepipeline module. It's not possible to move it to the lambda module itself, as that would cause a cyclic dependency between the codepipeline, sns and lambda modules. This continues the refactoring of moving out concrete Action typesfrom the codepipeline module.
- v2.179.0
- v2.178.2
- v2.178.1
- v2.178.0
- v2.177.0
- v2.176.0
- v2.175.1
- v2.175.0
- v2.174.1
- v2.174.0
- v2.173.4
- v2.173.3
- v2.173.2
- v2.173.1
- v2.173.0
- v2.172.0
- v2.171.1
- v2.171.0
- v2.170.0
- v2.169.0
- v2.168.0
- v2.167.2
- v2.167.1
- v2.167.0
- v2.166.0
- v2.165.0
- v2.164.1
- v2.164.0
- v2.163.1
- v2.163.0
- v2.162.1
- v2.162.0
- v2.161.1
- v2.161.0
- v2.160.0
- v2.159.1
- v2.159.0
- v2.158.0
- v2.157.0
- v2.156.0
- v2.155.0
- v2.154.1
- v2.154.0
- v2.153.0
- v2.152.0
- v2.151.1
- v2.151.0
- v2.150.0
- v2.149.0
- v2.148.1
- v2.148.0
- v2.147.3
- v2.147.2
- v2.147.1
- v2.147.0
- v2.146.0
- v2.145.0
- v2.144.0
- v2.143.1
- v2.143.0
- v2.142.1
- v2.142.0
- v2.141.0
- v2.140.0
- v2.139.1
- v2.139.0
- v2.138.0
- v2.137.0
- v2.136.1
- v2.136.0
- v2.135.0
- v2.134.0
- v2.133.0
- v2.132.1
- v2.132.0
- v2.131.0
- v2.130.0
- v2.129.0
- v2.128.0
- v2.127.0
- v2.126.0
- v2.125.0
- v2.124.0
- v2.123.0
- v2.122.0
- v2.121.1
- v2.121.0
- v2.120.0
- v2.119.0
- v2.118.0
- v2.117.0
- v2.116.1
- v2.116.0
- v2.115.0
- v2.114.1
- v2.114.0
- v2.113.0
- v2.112.0
- v2.111.0
- v2.110.1
- v2.110.0
- v2.109.0
- v2.108.1
- v2.108.0
- v2.107.0
- v2.106.1
- v2.106.0
- v2.105.0
- v2.104.0
- v2.103.1
- v2.103.0
- v2.102.1
- v2.102.0
- v2.101.1
- v2.101.0
- v2.100.0
- v2.99.1
- v2.99.0
- v2.98.0
- v2.97.1
- v2.97.0
- v2.96.2
- v2.96.1
- v2.96.0
- v2.95.1
- v2.95.0
- v2.94.0
- v2.93.0
- v2.92.0
- v2.91.0
- v2.90.0
- v2.89.0
- v2.88.0
- v2.87.0
- v2.86.0
- v2.85.0
- v2.84.0
- v2.83.1
- v2.83.0
- v2.82.0
- v2.81.0
- v2.80.0
- v2.79.1
- v2.79.0
- v2.78.0
- v2.77.0
- v2.76.0
- v2.75.1
- v2.75.0
- v2.74.0
- v2.73.0
- v2.72.1
- v2.72.0
- v2.71.0
- v2.70.0
- v2.69.0
- v2.68.0
- v2.67.0
- v2.66.1
- v2.66.0
- v2.65.0
- v2.64.0
- v2.63.2
- v2.63.1
- v2.63.0
- v2.62.2
- v2.62.1
- v2.62.0
- v2.61.1
- v2.61.0
- v2.60.0
- v2.59.0
- v2.58.1
- v2.58.0
- v2.57.0
- v2.56.1
- v2.56.0
- v2.55.1
- v2.55.0
- v2.54.0
- v2.53.0
- v2.52.1
- v2.52.0
- v2.51.1
- v2.51.0
- v2.50.0
- v2.49.1
- v2.49.0
- v2.48.0
- v2.47.0
- v2.46.0
- v2.45.0
- v2.44.0
- v2.43.1
- v2.43.0
- v2.42.1
- v2.42.0
- v2.41.0
- v2.40.0
- v2.39.1
- v2.39.0
- v2.38.1
- v2.38.0
- v2.37.1
- v2.37.0
- v2.36.0
- v2.35.0
- v2.34.2
- v2.34.1
- v2.34.0
- v2.33.0
- v2.32.1
- v2.32.0
- v2.31.2
- v2.31.1
- v2.31.0
- v2.30.0
- v2.29.1
- v2.29.0
- v2.28.1
- v2.28.0
- v2.27.0
- v2.26.0
- v2.25.0
- v2.24.1
- v2.24.0
- v2.23.0
- v2.22.0
- v2.21.1
- v2.21.0
- v2.20.0
- v2.19.0
- v2.18.0
- v2.17.0
- v2.16.0
- v2.15.0
- v2.14.0
- v2.13.0
- v2.12.0
- v2.11.0
- v2.10.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v2.0.0-rc.33
- v2.0.0-rc.32
- v2.0.0-rc.31
- v2.0.0-rc.30
- v2.0.0-rc.29
- v2.0.0-rc.28
- v2.0.0-rc.27
- v2.0.0-rc.26
- v2.0.0-rc.25
- v2.0.0-rc.24
- v2.0.0-rc.23
- v2.0.0-rc.22
- v2.0.0-rc.21
- v2.0.0-rc.20
- v2.0.0-rc.19
- v2.0.0-rc.18
- v2.0.0-rc.17
- v2.0.0-rc.16
- v2.0.0-rc.15
- v2.0.0-rc.14
- v2.0.0-rc.13
- v2.0.0-rc.12
- v2.0.0-rc.11
- v2.0.0-rc.10
- v2.0.0-rc.9
- v2.0.0-rc.8
- v2.0.0-rc.7
- v2.0.0-rc.6
- v2.0.0-rc.5
- v2.0.0-rc.4
- v2.0.0-rc.3
- v2.0.0-rc.1
- v2.0.0-alpha.14
- v2.0.0-alpha.13
- v2.0.0-alpha.12
- v2.0.0-alpha.11
- v2.0.0-alpha.10
- v2.0.0-alpha.6
- v2.0.0-alpha.5
- v2.0.0-alpha.4
- v2.0.0-alpha.3
- v2.0.0-alpha.2
- v2.0.0-alpha.1
- v2.0.0-alpha.0
- v1.204.0
- v1.203.0
- v1.202.0
- v1.201.0
- v1.200.0
- v1.199.0
- v1.198.1
- v1.198.0
- v1.197.0
- v1.196.0
- v1.195.0
- v1.194.0
- v1.193.0
- v1.192.0
- v1.191.0
- v1.190.0
- v1.189.0
- v1.188.0
- v1.187.0
- v1.186.1
- v1.186.0
- v1.185.0
- v1.184.1
- v1.184.0
- v1.183.0
- v1.182.0
- v1.181.1
- v1.181.0
- v1.180.0
- v1.179.0
- v1.178.0
- v1.177.0
- v1.176.0
- v1.175.0
- v1.174.0
- v1.173.0
- v1.172.0
- v1.171.0
- v1.170.1
- v1.170.0
- v1.169.0
- v1.168.0
- v1.167.0
- v1.166.1
- v1.165.0
- v1.164.0
- v1.163.2
- v1.163.1
- v1.163.0
- v1.162.0
- v1.161.0
- v1.160.0
- v1.159.0
- v1.158.0
- v1.157.0
- v1.156.1
- v1.156.0
- v1.155.0
- v1.154.0
- v1.153.1
- v1.153.0
- v1.152.0
- v1.151.0
- v1.150.0
- v1.149.0
- v1.148.0
- v1.147.0
- v1.146.0
- v1.145.0
- v1.144.0
- v1.143.0
- v1.142.0
- v1.141.0
- v1.140.0
- v1.139.0
- v1.138.2
- v1.138.1
- v1.138.0
- v1.137.0
- v1.136.0
- v1.135.0
- v1.134.0
- v1.133.0
- v1.132.0
- v1.131.0
- v1.130.0
- v1.129.0
- v1.128.0
- v1.127.0
- v1.126.0
- v1.125.0
- v1.124.0
- v1.123.0
- v1.122.0
- v1.121.0
- v1.120.0
- v1.119.0
- v1.118.0
- v1.117.0
- v1.116.0
- v1.115.0
- v1.114.0
- v1.113.0
- v1.112.0
- v1.111.0
- v1.110.1
- v1.110.0
- v1.109.0
- v1.108.1
- v1.108.0
- v1.107.0
- v1.106.1
- v1.106.0
- v1.105.0
- v1.104.0
- v1.103.0
- v1.102.0
- v1.101.0
- v1.100.0
- v1.99.0
- v1.98.0
- v1.97.0
- v1.96.0
- v1.95.2
- v1.95.1
- v1.95.0
- v1.94.1
- v1.94.0
- v1.93.0
- v1.92.0
- v1.91.0
- v1.90.1
- v1.90.0
- v1.89.0
- v1.88.0
- v1.87.1
- v1.87.0
- v1.86.0
- v1.85.0
- v1.84.0
- v1.83.0
- v1.82.0
- v1.81.0
- v1.80.0
- v1.79.0
- v1.78.0
- v1.77.0
- v1.76.0
- v1.75.0
- v1.74.0
- v1.73.0
- v1.72.0
- v1.71.0
- v1.70.0
- v1.69.0
- v1.68.0
- v1.67.0
- v1.66.0
- v1.65.0
- v1.64.1
- v1.64.0
- v1.63.0
- v1.62.0
- v1.61.1
- v1.61.0
- v1.60.0
- v1.59.0
- v1.58.0
- v1.57.0
- v1.56.0
- v1.55.0
- v1.54.0
- v1.53.0
- v1.52.0
- v1.51.0
- v1.50.0
- v1.49.1
- v1.49.0
- v1.48.0
- v1.47.1
- v1.47.0
- v1.46.0
- v1.45.0
- v1.44.0
- v1.43.0
- v1.42.1
- v1.42.0
- v1.41.0
- v1.40.0
- v1.39.0
- v1.38.0
- v1.37.0
- v1.36.1
- v1.36.0
- v1.35.0
- v1.34.1
- v1.34.0
- v1.33.1
- v1.33.0
- v1.32.2
- v1.32.1
- v1.32.0
- v1.31.0
- v1.30.0
- v1.29.0
- v1.28.0
- v1.27.0
- v1.26.0
- v1.25.0
- v1.24.0
- v1.23.0
- v1.22.0
- v1.21.1
- v1.21.0
- v1.20.0
- v1.19.0
- v1.18.0
- v1.17.1
- v1.17.0
- v1.16.3
- v1.16.2
- v1.16.1
- v1.16.0
- v1.15.0
- v1.14.0
- v1.13.1
- v1.13.0
- v1.12.0
- v1.11.0
- v1.10.1
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.1
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- v0.39.0
- v0.38.0
- v0.37.0
- v0.36.2
- v0.36.1
- v0.36.0
- v0.35.0
- v0.34.0
- v0.33.0
- v0.32.0
- v0.31.0
- v0.30.0
- v0.29.0
- v0.28.0
- v0.27.0
- v0.26.0
- v0.25.3
- v0.25.2
- v0.25.1
- v0.25.0
- v0.24.1
- v0.24.0
- v0.23.0
- v0.22.0
- v0.21.0
- v0.20.0
- v0.19.0
- v0.18.1
- v0.18.0
- v0.17.0
- v0.16.0
- v0.15.2
- v0.15.1
- v0.15.0
- v0.14.1
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.0
- v0.10.0
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.4-beta
Showing
14 changed files
with
697 additions
and
195 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
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
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
86 changes: 86 additions & 0 deletions
86
packages/@aws-cdk/aws-codepipeline/test/test.general-validation.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,86 @@ | ||
import s3 = require('@aws-cdk/aws-s3'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { Test } from 'nodeunit'; | ||
import { AmazonS3Source } from '../lib/actions'; | ||
import { Pipeline } from '../lib/pipeline'; | ||
import { Stage } from '../lib/stage'; | ||
import { validateName } from '../lib/validation'; | ||
|
||
interface NameValidationTestCase { | ||
name: string; | ||
shouldPassValidation: boolean; | ||
explanation: string; | ||
} | ||
|
||
export = { | ||
'name validation'(test: Test) { | ||
const cases: NameValidationTestCase[] = [ | ||
{ name: 'BlahBleep123.@-_', shouldPassValidation: true, explanation: 'should be valid' }, | ||
{ name: '', shouldPassValidation: false, explanation: 'the empty string should be invalid' }, | ||
{ name: ' BlahBleep', shouldPassValidation: false, explanation: 'spaces should be invalid' }, | ||
{ name: '!BlahBleep', shouldPassValidation: false, explanation: '\'!\' should be invalid' } | ||
]; | ||
|
||
cases.forEach(testCase => { | ||
const name = testCase.name; | ||
const validationBlock = () => { validateName('test thing', name); }; | ||
if (testCase.shouldPassValidation) { | ||
test.doesNotThrow(validationBlock, Error, `${name} failed validation but ${testCase.explanation}`); | ||
} else { | ||
test.throws(validationBlock, Error, `${name} passed validation but ${testCase.explanation}`); | ||
} | ||
}); | ||
|
||
test.done(); | ||
}, | ||
|
||
'Stage validation': { | ||
'should fail if Stage has no Actions'(test: Test) { | ||
const stage = stageForTesting(); | ||
|
||
test.deepEqual(stage.validate().length, 1); | ||
|
||
test.done(); | ||
} | ||
}, | ||
|
||
'Pipeline validation': { | ||
'should fail if Pipeline has no Stages'(test: Test) { | ||
const stack = new cdk.Stack(); | ||
const pipeline = new Pipeline(stack, 'Pipeline'); | ||
|
||
test.deepEqual(pipeline.validate().length, 1); | ||
|
||
test.done(); | ||
}, | ||
|
||
'should fail if Pipeline has a Source Action in a non-first Stage'(test: Test) { | ||
const stack = new cdk.Stack(); | ||
const pipeline = new Pipeline(stack, 'Pipeline'); | ||
const firstStage = new Stage(pipeline, 'FirstStage'); | ||
const secondStage = new Stage(pipeline, 'SecondStage'); | ||
|
||
const bucket = new s3.Bucket(stack, 'PipelineBucket'); | ||
new AmazonS3Source(firstStage, 'FirstAction', { | ||
artifactName: 'FirstArtifact', | ||
bucket, | ||
bucketKey: 'key', | ||
}); | ||
new AmazonS3Source(secondStage, 'SecondAction', { | ||
artifactName: 'SecondAction', | ||
bucket, | ||
bucketKey: 'key', | ||
}); | ||
|
||
test.deepEqual(pipeline.validate().length, 1); | ||
|
||
test.done(); | ||
} | ||
} | ||
}; | ||
|
||
function stageForTesting(): Stage { | ||
const stack = new cdk.Stack(); | ||
const pipeline = new Pipeline(stack, 'pipeline'); | ||
return new Stage(pipeline, 'stage'); | ||
} |
31 changes: 0 additions & 31 deletions
31
packages/@aws-cdk/aws-codepipeline/test/test.generalValidation.ts
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
*.js | ||
*.js.map | ||
*.d.ts | ||
node_modules | ||
*.generated.ts | ||
dist | ||
tsconfig.json | ||
tslint.json | ||
|
||
.jsii | ||
|
||
.LAST_BUILD | ||
.nyc_output | ||
coverage | ||
.nycrc |
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,6 @@ | ||
# Don't include original .ts files when doing `npm pack` | ||
*.ts | ||
!*.d.ts | ||
coverage | ||
.nyc_output | ||
*.tgz |
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,24 @@ | ||
## AWS CodePipline Actions for AWS Lambda | ||
|
||
This module contains an Action that allows you to invoke a Lambda function from CodePipeline. | ||
|
||
Example usage: | ||
|
||
```ts | ||
import codepipeline = require('@aws-cdk/aws-codepipeline'); | ||
import lambda = require('@aws-cdk/aws-lambda'); | ||
import lambdaCodepipeline = require('@aws-cdk/aws-lambda-codepipeline'); | ||
|
||
// see the @aws-cdk/aws-lambda module for more documentation on how to create Lamda functions | ||
const lambdaFun = new lambda.Lambda(// ... | ||
); | ||
|
||
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline'); | ||
const lambdaStage = new codepipeline.Stage(pipeline, 'Lambda'); | ||
new lambdaCodepipeline.PipelineInvokeAction(lambdaStage, 'Lambda', { | ||
lambda: lambdaFun, | ||
}); | ||
``` | ||
|
||
See [the AWS documentation](https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html) | ||
on how to write a Lambda function invoked from CodePipeline. |
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 @@ | ||
export * from './pipeline-action'; |
87 changes: 87 additions & 0 deletions
87
packages/@aws-cdk/aws-lambda-codepipeline/lib/pipeline-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,87 @@ | ||
import codepipeline = require('@aws-cdk/aws-codepipeline'); | ||
import lambda = require('@aws-cdk/aws-lambda'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
|
||
/** | ||
* Construction properties of the {@link PipelineInvokeAction Lambda invoke CodePipeline Action}. | ||
*/ | ||
export interface PipelineInvokeActionProps { | ||
/** | ||
* The lambda function to invoke. | ||
*/ | ||
lambda: lambda.LambdaRef; | ||
|
||
/** | ||
* String to be used in the event data parameter passed to the Lambda | ||
* function | ||
* | ||
* See an example JSON event in the CodePipeline documentation. | ||
* | ||
* https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-json-event-example | ||
*/ | ||
userParameters?: any; | ||
|
||
/** | ||
* Adds the "codepipeline:PutJobSuccessResult" and | ||
* "codepipeline:PutJobFailureResult" for '*' resource to the Lambda | ||
* execution role policy. | ||
* | ||
* NOTE: the reason we can't add the specific pipeline ARN as a resource is | ||
* to avoid a cyclic dependency between the pipeline and the Lambda function | ||
* (the pipeline references) the Lambda and the Lambda needs permissions on | ||
* the pipeline. | ||
* | ||
* @see | ||
* https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-create-function | ||
* | ||
* @default true | ||
*/ | ||
addPutJobResultPolicy?: boolean; | ||
} | ||
|
||
/** | ||
* CodePipeline invoke Action that is provided by an AWS Lambda function. | ||
* | ||
* @see https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html | ||
*/ | ||
export class PipelineInvokeAction extends codepipeline.Action { | ||
constructor(parent: codepipeline.Stage, name: string, props: PipelineInvokeActionProps) { | ||
super(parent, name, { | ||
category: codepipeline.ActionCategory.Invoke, | ||
provider: 'Lambda', | ||
artifactBounds: codepipeline.defaultBounds(), | ||
configuration: { | ||
FunctionName: props.lambda.functionName, | ||
UserParameters: props.userParameters | ||
} | ||
}); | ||
|
||
// allow pipeline to list functions | ||
parent.pipeline.addToRolePolicy(new cdk.PolicyStatement() | ||
.addAction('lambda:ListFunctions') | ||
.addResource('*')); | ||
|
||
// allow pipeline to invoke this lambda functionn | ||
parent.pipeline.addToRolePolicy(new cdk.PolicyStatement() | ||
.addAction('lambda:InvokeFunction') | ||
.addResource(props.lambda.functionArn)); | ||
|
||
// allow lambda to put job results for this pipeline. | ||
const addToPolicy = props.addPutJobResultPolicy !== undefined ? props.addPutJobResultPolicy : true; | ||
if (addToPolicy) { | ||
props.lambda.addToRolePolicy(new cdk.PolicyStatement() | ||
.addResource('*') // to avoid cycles (see docs) | ||
.addAction('codepipeline:PutJobSuccessResult') | ||
.addAction('codepipeline:PutJobFailureResult')); | ||
} | ||
} | ||
|
||
/** | ||
* Add an input artifact | ||
* @param artifact | ||
*/ | ||
public addInputArtifact(artifact: codepipeline.Artifact): PipelineInvokeAction { | ||
super.addInputArtifact(artifact); | ||
return this; | ||
} | ||
} |
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,62 @@ | ||
{ | ||
"name": "@aws-cdk/aws-lambda-codepipeline", | ||
"version": "0.7.3-beta", | ||
"description": "AWS CodePipline Actions for AWS Lambda", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"jsii": { | ||
"outdir": "dist", | ||
"targets": { | ||
"java": { | ||
"package": "com.amazonaws.cdk.aws.lambdacodepipeline", | ||
"maven": { | ||
"groupId": "com.amazonaws.cdk", | ||
"artifactId": "aws-lambdacodepipeline" | ||
} | ||
}, | ||
"dotnet": { | ||
"namespace": "Amazon.CDK.AWS.LambdaCodePipeline" | ||
} | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/awslabs/aws-cdk" | ||
}, | ||
"scripts": { | ||
"build": "cdk-build", | ||
"watch": "cdk-watch", | ||
"lint": "cdk-lint", | ||
"test": "cdk-test", | ||
"integ": "cdk-integ", | ||
"pkglint": "pkglint -f" | ||
}, | ||
"nyc": { | ||
"lines": 60, | ||
"branches": 30 | ||
}, | ||
"keywords": [ | ||
"aws", | ||
"cdk", | ||
"codepipeline", | ||
"constructs", | ||
"lambda" | ||
], | ||
"author": { | ||
"name": "Amazon Web Services", | ||
"url": "https://aws.amazon.com" | ||
}, | ||
"license": "LicenseRef-LICENSE", | ||
"devDependencies": { | ||
"@aws-cdk/assert": "^0.7.3-beta", | ||
"cdk-build-tools": "^0.7.3-beta", | ||
"cdk-integ-tools": "^0.7.3-beta", | ||
"pkglint": "^0.7.3-beta" | ||
}, | ||
"dependencies": { | ||
"@aws-cdk/aws-codepipeline": "^0.7.3-beta", | ||
"@aws-cdk/aws-lambda": "^0.7.3-beta", | ||
"@aws-cdk/aws-s3": "^0.7.3-beta", | ||
"@aws-cdk/cdk": "^0.7.3-beta" | ||
} | ||
} |
287 changes: 287 additions & 0 deletions
287
packages/@aws-cdk/aws-lambda-codepipeline/test/integ.pipeline.expected.json
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,287 @@ | ||
{ | ||
"Resources": { | ||
"PipelineArtifactsBucket22248F97": { | ||
"Type": "AWS::S3::Bucket", | ||
"DeletionPolicy": "Retain" | ||
}, | ||
"PipelineRoleD68726F7": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "codepipeline.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
} | ||
}, | ||
"PipelineRoleDefaultPolicyC7A05455": { | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"s3:GetObject*", | ||
"s3:GetBucket*", | ||
"s3:List*", | ||
"s3:PutObject*", | ||
"s3:DeleteObject*", | ||
"s3:Abort*" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
{ | ||
"Fn::GetAtt": [ | ||
"PipelineArtifactsBucket22248F97", | ||
"Arn" | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::GetAtt": [ | ||
"PipelineArtifactsBucket22248F97", | ||
"Arn" | ||
] | ||
}, | ||
"/", | ||
"*" | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"Action": [ | ||
"s3:GetObject*", | ||
"s3:GetBucket*", | ||
"s3:List*" | ||
], | ||
"Effect": "Allow", | ||
"Resource": [ | ||
{ | ||
"Fn::GetAtt": [ | ||
"PipelineBucketB967BD35", | ||
"Arn" | ||
] | ||
}, | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
{ | ||
"Fn::GetAtt": [ | ||
"PipelineBucketB967BD35", | ||
"Arn" | ||
] | ||
}, | ||
"/", | ||
"*" | ||
] | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"Action": "lambda:ListFunctions", | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
}, | ||
{ | ||
"Action": "lambda:InvokeFunction", | ||
"Effect": "Allow", | ||
"Resource": { | ||
"Fn::GetAtt": [ | ||
"LambdaFun98622869", | ||
"Arn" | ||
] | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"PolicyName": "PipelineRoleDefaultPolicyC7A05455", | ||
"Roles": [ | ||
{ | ||
"Ref": "PipelineRoleD68726F7" | ||
} | ||
] | ||
} | ||
}, | ||
"PipelineC660917D": { | ||
"Type": "AWS::CodePipeline::Pipeline", | ||
"Properties": { | ||
"ArtifactStore": { | ||
"Location": { | ||
"Ref": "PipelineArtifactsBucket22248F97" | ||
}, | ||
"Type": "S3" | ||
}, | ||
"RoleArn": { | ||
"Fn::GetAtt": [ | ||
"PipelineRoleD68726F7", | ||
"Arn" | ||
] | ||
}, | ||
"Stages": [ | ||
{ | ||
"Actions": [ | ||
{ | ||
"ActionTypeId": { | ||
"Category": "Source", | ||
"Owner": "AWS", | ||
"Provider": "S3", | ||
"Version": "1" | ||
}, | ||
"Configuration": { | ||
"S3Bucket": { | ||
"Ref": "PipelineBucketB967BD35" | ||
}, | ||
"S3ObjectKey": "key", | ||
"PollForSourceChanges": true | ||
}, | ||
"InputArtifacts": [], | ||
"Name": "Source", | ||
"OutputArtifacts": [ | ||
{ | ||
"Name": "SourceArtifact" | ||
} | ||
], | ||
"RunOrder": 1 | ||
} | ||
], | ||
"Name": "Source" | ||
}, | ||
{ | ||
"Actions": [ | ||
{ | ||
"ActionTypeId": { | ||
"Category": "Invoke", | ||
"Owner": "AWS", | ||
"Provider": "Lambda", | ||
"Version": "1" | ||
}, | ||
"Configuration": { | ||
"FunctionName": { | ||
"Ref": "LambdaFun98622869" | ||
} | ||
}, | ||
"InputArtifacts": [], | ||
"Name": "Lambda", | ||
"OutputArtifacts": [], | ||
"RunOrder": 1 | ||
} | ||
], | ||
"Name": "Lambda" | ||
} | ||
] | ||
}, | ||
"DependsOn": [ | ||
"PipelineRoleD68726F7", | ||
"PipelineRoleDefaultPolicyC7A05455" | ||
] | ||
}, | ||
"PipelineBucketB967BD35": { | ||
"Type": "AWS::S3::Bucket", | ||
"Properties": { | ||
"VersioningConfiguration": { | ||
"Status": "Enabled" | ||
} | ||
} | ||
}, | ||
"LambdaFunServiceRoleF0979767": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn", | ||
":", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":", | ||
"iam", | ||
":", | ||
"", | ||
":", | ||
"aws", | ||
":", | ||
"policy", | ||
"/", | ||
"service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"LambdaFunServiceRoleDefaultPolicy217FED83": { | ||
"Type": "AWS::IAM::Policy", | ||
"Properties": { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"codepipeline:PutJobSuccessResult", | ||
"codepipeline:PutJobFailureResult" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"PolicyName": "LambdaFunServiceRoleDefaultPolicy217FED83", | ||
"Roles": [ | ||
{ | ||
"Ref": "LambdaFunServiceRoleF0979767" | ||
} | ||
] | ||
} | ||
}, | ||
"LambdaFun98622869": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "\n exports.handler = function () {\n console.log(\"Hello, world!\");\n };\n " | ||
}, | ||
"Handler": "index.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LambdaFunServiceRoleF0979767", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs6.10" | ||
}, | ||
"DependsOn": [ | ||
"LambdaFunServiceRoleF0979767", | ||
"LambdaFunServiceRoleDefaultPolicy217FED83" | ||
] | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/@aws-cdk/aws-lambda-codepipeline/test/integ.pipeline.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,37 @@ | ||
import codepipeline = require('@aws-cdk/aws-codepipeline'); | ||
import lambda = require('@aws-cdk/aws-lambda'); | ||
import s3 = require('@aws-cdk/aws-s3'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import lambda_codepipeline = require('../lib'); | ||
|
||
const app = new cdk.App(process.argv); | ||
|
||
const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-lambda'); | ||
|
||
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline'); | ||
|
||
const sourceStage = new codepipeline.Stage(pipeline, 'Source'); | ||
const bucket = new s3.Bucket(stack, 'PipelineBucket', { | ||
versioned: true, | ||
}); | ||
new codepipeline.AmazonS3Source(sourceStage, 'Source', { | ||
artifactName: 'SourceArtifact', | ||
bucket, | ||
bucketKey: 'key', | ||
}); | ||
|
||
const lambdaFun = new lambda.Lambda(stack, 'LambdaFun', { | ||
code: new lambda.LambdaInlineCode(` | ||
exports.handler = function () { | ||
console.log("Hello, world!"); | ||
}; | ||
`), | ||
handler: 'index.handler', | ||
runtime: lambda.LambdaRuntime.NodeJS610, | ||
}); | ||
const lambdaStage = new codepipeline.Stage(pipeline, 'Lambda'); | ||
new lambda_codepipeline.PipelineInvokeAction(lambdaStage, 'Lambda', { | ||
lambda: lambdaFun, | ||
}); | ||
|
||
process.stdout.write(app.run()); |
91 changes: 91 additions & 0 deletions
91
packages/@aws-cdk/aws-lambda-codepipeline/test/test.pipeline-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,91 @@ | ||
import { expect, haveResource } from '@aws-cdk/assert'; | ||
import codepipeline = require('@aws-cdk/aws-codepipeline'); | ||
import lambda = require('@aws-cdk/aws-lambda'); | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { Test } from 'nodeunit'; | ||
import { PipelineInvokeAction } from '../lib/pipeline-action'; | ||
|
||
// tslint:disable:object-literal-key-quotes | ||
|
||
export = { | ||
'PipelineInvokeAction can be used to invoke lambda functions from a CodePipeline'(test: Test) { | ||
const stack = new cdk.Stack(); | ||
|
||
const lambdaFun = new lambda.Lambda(stack, 'Function', { | ||
code: new lambda.LambdaInlineCode('bla'), | ||
handler: 'index.handler', | ||
runtime: lambda.LambdaRuntime.NodeJS43, | ||
}); | ||
|
||
const pipeline = new codepipeline.Pipeline(stack, 'Pipeline'); | ||
|
||
new PipelineInvokeAction(new codepipeline.Stage(pipeline, 'Stage'), 'InvokeAction', { | ||
lambda: lambdaFun, | ||
userParameters: 'foo-bar/42' | ||
}); | ||
|
||
expect(stack).to(haveResource('AWS::CodePipeline::Pipeline', { | ||
"ArtifactStore": { | ||
"Location": { | ||
"Ref": "PipelineArtifactsBucket22248F97" | ||
}, | ||
"Type": "S3" | ||
}, | ||
"RoleArn": { | ||
"Fn::GetAtt": [ | ||
"PipelineRoleD68726F7", | ||
"Arn" | ||
] | ||
}, | ||
"Stages": [ | ||
{ | ||
"Actions": [ | ||
{ | ||
"ActionTypeId": { | ||
"Category": "Invoke", | ||
"Owner": "AWS", | ||
"Provider": "Lambda", | ||
"Version": "1" | ||
}, | ||
"Configuration": { | ||
"FunctionName": { | ||
"Ref": "Function76856677" | ||
}, | ||
"UserParameters": "foo-bar/42" | ||
}, | ||
"InputArtifacts": [], | ||
"Name": "InvokeAction", | ||
"OutputArtifacts": [], | ||
"RunOrder": 1 | ||
} | ||
], | ||
"Name": "Stage" | ||
} | ||
] | ||
})); | ||
|
||
expect(stack).to(haveResource('AWS::IAM::Policy', { | ||
"PolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"codepipeline:PutJobSuccessResult", | ||
"codepipeline:PutJobFailureResult" | ||
], | ||
"Effect": "Allow", | ||
"Resource": "*" | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"PolicyName": "FunctionServiceRoleDefaultPolicy2F49994A", | ||
"Roles": [ | ||
{ | ||
"Ref": "FunctionServiceRole675BB04A" | ||
} | ||
] | ||
})); | ||
|
||
test.done(); | ||
} | ||
}; |