-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(codedeploy) lambda application and deployment groups #1628
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f7ef936
add Lambda CodeDeploy applications and deployment groups
4424f97
Imporve tests and documentation
a55702d
Add integration test
6254b9f
Refactor traffic shifting to deployment config. Add auto rollback and…
05a486d
Replace managed policy with granular permissions
9d02184
Add Lambda details to README
b15bbbd
Add comments back in and fix deployment option and type as per comments
304c0b2
More updates
c3a7fff
Fix up some unneccessary changes and remove comments - cleanups
3798120
Fix API gateway alias test
01dbdb1
Add missing lambda handlers
f17843f
Address comments.
094cebb
Fix rename imports ...
6291fc4
Updated as per review comments
b62ec90
@param parent -> @param scope
8715f00
Merge master
d3e4790
Update as per comments - add return types, improve wiki new lines and…
50de88a
s/EC2/Lambda/
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export * from './application'; | ||
export * from './deployment-config'; | ||
export * from './deployment-group'; | ||
export * from './rollback-config'; | ||
export * from './lambda'; | ||
export * from './pipeline-action'; | ||
export * from './server'; | ||
|
||
// AWS::CodeDeploy CloudFormation Resources: | ||
export * from './codedeploy.generated'; |
101 changes: 101 additions & 0 deletions
101
packages/@aws-cdk/aws-codedeploy/lib/lambda/application.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,101 @@ | ||
import cdk = require("@aws-cdk/cdk"); | ||
import { CfnApplication } from "../codedeploy.generated"; | ||
import { applicationNameToArn } from "../utils"; | ||
|
||
/** | ||
* Represents a reference to a CodeDeploy Application deploying to AWS Lambda. | ||
* | ||
* If you're managing the Application alongside the rest of your CDK resources, | ||
* use the {@link LambdaApplication} class. | ||
* | ||
* If you want to reference an already existing Application, | ||
* or one defined in a different CDK Stack, | ||
* use the {@link LambdaApplication#import} method. | ||
*/ | ||
export interface ILambdaApplication extends cdk.IConstruct { | ||
readonly applicationArn: string; | ||
readonly applicationName: string; | ||
|
||
export(): LambdaApplicationImportProps; | ||
} | ||
|
||
/** | ||
* Construction properties for {@link LambdaApplication}. | ||
*/ | ||
export interface LambdaApplicationProps { | ||
/** | ||
* The physical, human-readable name of the CodeDeploy Application. | ||
* | ||
* @default an auto-generated name will be used | ||
*/ | ||
applicationName?: string; | ||
} | ||
|
||
/** | ||
* A CodeDeploy Application that deploys to an AWS Lambda function. | ||
*/ | ||
export class LambdaApplication extends cdk.Construct implements ILambdaApplication { | ||
/** | ||
* Import an Application defined either outside the CDK, | ||
* or in a different CDK Stack and exported using the {@link ILambdaApplication#export} method. | ||
* | ||
* @param scope the parent Construct for this new Construct | ||
* @param id the logical ID of this new Construct | ||
* @param props the properties of the referenced Application | ||
* @returns a Construct representing a reference to an existing Application | ||
*/ | ||
public static import(scope: cdk.Construct, id: string, props: LambdaApplicationImportProps): ILambdaApplication { | ||
return new ImportedLambdaApplication(scope, id, props); | ||
} | ||
sam-goodwin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public readonly applicationArn: string; | ||
public readonly applicationName: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: LambdaApplicationProps = {}) { | ||
super(scope, id); | ||
sam-goodwin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const resource = new CfnApplication(this, 'Resource', { | ||
applicationName: props.applicationName, | ||
computePlatform: 'Lambda' | ||
}); | ||
|
||
this.applicationName = resource.ref; | ||
this.applicationArn = applicationNameToArn(this.applicationName, this); | ||
} | ||
|
||
public export(): LambdaApplicationImportProps { | ||
return { | ||
applicationName: new cdk.Output(this, 'ApplicationName', { value: this.applicationName }).makeImportValue().toString() | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* Properties of a reference to a CodeDeploy Application. | ||
* | ||
* @see LambdaApplication#import | ||
* @see ILambdaApplication#export | ||
*/ | ||
export interface LambdaApplicationImportProps { | ||
/** | ||
* The physical, human-readable name of the Lambda Application we're referencing. | ||
* The Application must be in the same account and region as the root Stack. | ||
*/ | ||
applicationName: string; | ||
} | ||
|
||
class ImportedLambdaApplication extends cdk.Construct implements ILambdaApplication { | ||
public readonly applicationArn: string; | ||
public readonly applicationName: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, private readonly props: LambdaApplicationImportProps) { | ||
sam-goodwin marked this conversation as resolved.
Show resolved
Hide resolved
sam-goodwin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
super(scope, id); | ||
|
||
this.applicationName = props.applicationName; | ||
this.applicationArn = applicationNameToArn(props.applicationName, this); | ||
} | ||
|
||
public export(): LambdaApplicationImportProps { | ||
sam-goodwin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return this.props; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-config.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,95 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { arnForDeploymentConfigName } from '../utils'; | ||
|
||
/** | ||
* The Deployment Configuration of a Lambda Deployment Group. | ||
* The default, pre-defined Configurations are available as constants on the {@link LambdaDeploymentConfig} class | ||
* (`LambdaDeploymentConfig.AllAtOnce`, `LambdaDeploymentConfig.Canary10Percent30Minutes`, etc.). | ||
* | ||
* Note: CloudFormation does not currently support creating custom lambda configs outside | ||
* of using a custom resource. You can import custom deployment config created outside the | ||
* CDK or via a custom resource with {@link LambdaDeploymentConfig#import}. | ||
*/ | ||
export interface ILambdaDeploymentConfig { | ||
readonly deploymentConfigName: string; | ||
deploymentConfigArn(scope: cdk.IConstruct): string; | ||
} | ||
|
||
class DefaultLambdaDeploymentConfig implements ILambdaDeploymentConfig { | ||
public readonly deploymentConfigName: string; | ||
|
||
constructor(deploymentConfigName: string) { | ||
this.deploymentConfigName = `CodeDeployDefault.Lambda${deploymentConfigName}`; | ||
} | ||
|
||
public deploymentConfigArn(scope: cdk.IConstruct): string { | ||
return arnForDeploymentConfigName(this.deploymentConfigName, scope); | ||
} | ||
} | ||
|
||
/** | ||
* Properties of a reference to a CodeDeploy Lambda Deployment Configuration. | ||
* | ||
* @see LambdaDeploymentConfig#import | ||
* @see LambdaDeploymentConfig#export | ||
*/ | ||
export interface LambdaDeploymentConfigImportProps { | ||
/** | ||
* The physical, human-readable name of the custom CodeDeploy Lambda Deployment Configuration | ||
* that we are referencing. | ||
*/ | ||
deploymentConfigName: string; | ||
} | ||
|
||
class ImportedLambdaDeploymentConfig extends cdk.Construct implements ILambdaDeploymentConfig { | ||
public readonly deploymentConfigName: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, private readonly props: LambdaDeploymentConfigImportProps) { | ||
super(scope, id); | ||
|
||
this.deploymentConfigName = props.deploymentConfigName; | ||
} | ||
|
||
public deploymentConfigArn(scope: cdk.IConstruct): string { | ||
return arnForDeploymentConfigName(this.deploymentConfigName, scope); | ||
} | ||
|
||
public export() { | ||
return this.props; | ||
} | ||
} | ||
|
||
/** | ||
* A custom Deployment Configuration for a Lambda Deployment Group. | ||
* | ||
* Note: This class currently stands as namespaced container of the default configurations | ||
* until CloudFormation supports custom Lambda Deployment Configs. Until then it is closed | ||
* (private constructor) and does not extend {@link cdk.Construct} | ||
*/ | ||
export class LambdaDeploymentConfig { | ||
public static readonly AllAtOnce: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('AllAtOnce'); | ||
public static readonly Canary10Percent30Minutes: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Canary10Percent30Minutes'); | ||
public static readonly Canary10Percent5Minutes: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Canary10Percent5Minutes'); | ||
public static readonly Canary10Percent10Minutes: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Canary10Percent10Minutes'); | ||
public static readonly Canary10Percent15Minutes: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Canary10Percent15Minutes'); | ||
public static readonly Linear10PercentEvery10Minutes: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Linear10PercentEvery10Minutes'); | ||
public static readonly Linear10PercentEvery1Minute: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Linear10PercentEvery1Minute'); | ||
public static readonly Linear10PercentEvery2Minutes: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Linear10PercentEvery2Minutes'); | ||
public static readonly Linear10PercentEvery3Minutes: ILambdaDeploymentConfig = new DefaultLambdaDeploymentConfig('Linear10PercentEvery3Minutes'); | ||
|
||
/** | ||
* Import a custom Deployment Configuration for a Lambda Deployment Group defined outside the CDK. | ||
* | ||
* @param scope the parent Construct for this new Construct | ||
* @param id the logical ID of this new Construct | ||
* @param props the properties of the referenced custom Deployment Configuration | ||
* @returns a Construct representing a reference to an existing custom Deployment Configuration | ||
*/ | ||
public static import(scope: cdk.Construct, id: string, props: LambdaDeploymentConfigImportProps): ILambdaDeploymentConfig { | ||
return new ImportedLambdaDeploymentConfig(scope, id, props); | ||
} | ||
|
||
private constructor() { | ||
// nothing to do until CFN supports custom lambda deployment configurations | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that we're changing this worries me a bit as well... maybe consult with somebody that knows a lot about the API Gateway construct whether these changes are OK? I don't feel competent enough in that area to comment on it.