-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functions, modified Jenkinsfile (copy code to s3 bucket)
- Loading branch information
Showing
4 changed files
with
96 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,8 @@ | ||
# package directories | ||
node_modules | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Swagger code gen ### | ||
.swagger-codegen | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# nyc test coverage | ||
coverage | ||
.nyc_output | ||
|
||
# JetBrains IDEs | ||
.idea | ||
|
||
# Git merge tool | ||
*.orig | ||
|
||
# Build dir | ||
dist |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Environment name will be taken from the ROOT folder | ||
def env(){ | ||
return env.JOB_NAME.replace("/${env.JOB_BASE_NAME}", '') | ||
} | ||
|
||
def validateTemplate() { | ||
def templates = findFiles(glob: 'cfn/**') | ||
for (template in templates) { | ||
cfnValidate(file: template.getPath()) | ||
} | ||
} | ||
|
||
def updateDeploymentBucket() { | ||
def envName = env() | ||
cfnUpdate(stack: envName+'-deployment-bucket', file: 'cfn/deployment/s3bucket.cfn.yaml', params: ['BucketName': envName], timeoutInMinutes: 10, tags: ['Environment='+envName], pollInterval: 10000) | ||
} | ||
|
||
def getDeploymentBucketName() { | ||
def envName = env() | ||
return cfnDescribe(stack: envName+'-deployment-bucket').BucketName | ||
} | ||
|
||
def getDeploymentPath() { | ||
return "artifacts/${env()}/${env.JOB_BASE_NAME}/${env.BUILD_NUMBER}/cfn" | ||
} | ||
|
||
def uploadTemplates() { | ||
s3Upload(file: 'cfn', bucket: getDeploymentBucketName(), path: getDeploymentPath()) | ||
} | ||
|
||
def uploadLambdaCode() { | ||
s3Upload(file: 'dist/lambda.zip', bucket: getDeploymentBucketName(), path: getDeploymentPath()) | ||
} | ||
|
||
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,53 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: Template for typescript lambda | ||
Parameters: | ||
Environment: | ||
Type: String | ||
Description: Environment name | ||
DeploymentBucket: | ||
Type: String | ||
Description: Deployment bucket name | ||
LambdaZipPath: | ||
Type: String | ||
Description: Path to zip file with lambda code (including build number etc) | ||
|
||
Resources: | ||
TypescriptLambda: | ||
Type: AWS::Lambda::Function | ||
DependsOn: | ||
- LambdaLogGroup | ||
Properties: | ||
FunctionName: !Sub '${Environment}-${AWS::Region}-typescript-lambda' | ||
Description: Sample lambda written in typescript | ||
Runtime: nodejs8.10 | ||
Code: | ||
S3Bucket: !Ref DeploymentBucket | ||
S3Key: !Ref LambdaZipPath | ||
Handler: dist/handler.handler | ||
MemorySize: 128 | ||
Role: !Ref LambdaExecutionRole | ||
Timeout: 10 | ||
|
||
LambdaLogGroup: | ||
Type: AWS::Logs::LogGroup | ||
Properties: | ||
LogGroupName: !Sub '/aws/lambda/${TypescriptLambda}' | ||
RetentionInDays: 3 | ||
|
||
LambdaExecutionRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: lambda.amazonaws.com | ||
Action: | ||
- sts:AssumeRole | ||
ManagedPolicyArns: | ||
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole | ||
|
||
Outputs: | ||
TypescriptLambda: | ||
Value: !Ref TypescriptLambda |