forked from smart-patrol/sagemaker-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch-cicd-pipeline.sh
executable file
·60 lines (48 loc) · 1.99 KB
/
launch-cicd-pipeline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
AWS_DEFAULT_REGION="us-east-1"
Email="<Enter Your Email>"
# Parameters to Configure Specific Github Repo
GitHub_User="<Enter Github Username>"
GitHub_Repo="<Enter Github Repo Name Only>"
GitHub_Branch="<Enter Repository Branch Name>"
GitHub_Token="<Enter Github Personal Access Token>"
# CodeBuild Project Parameters
Python_Build_Version="aws/codebuild/python:3.6.5-1.3.2"
Build_Timeout_Mins=30
# SageMaker Training Job Parameters
Instance_Count=1
Instance_Type="ml.m4.xlarge"
Max_Runtime_In_Seconds=86400
Vol_In_GB=60
Template_Name="${GitHub_Repo}-cicd-pipeline"
Lambdas_Bucket="${Template_Name}-lambdas-`date '+%Y-%m-%d-%H-%M-%S'`"
Lambdas_Key="SageMakerTriggers/LambdaFunction.zip"
cd lambda
chmod -R 755 .
zip -r ../LambdaFunction.zip .
cd ..
aws s3api create-bucket --bucket ${Lambdas_Bucket} \
--region ${AWS_DEFAULT_REGION}
aws s3api put-object --bucket ${Lambdas_Bucket} \
--key ${Lambdas_Key} \
--body ./LambdaFunction.zip
aws cloudformation create-stack \
--region ${AWS_DEFAULT_REGION} \
--stack-name ${Template_Name} \
--template-body file://template/sagemaker-pipeline.yaml \
--parameters \
ParameterKey=LambdasBucket,ParameterValue=${Lambdas_Bucket} \
ParameterKey=LambdasKey,ParameterValue=${Lambdas_Key} \
ParameterKey=Email,ParameterValue=${Email} \
ParameterKey=GitHubUser,ParameterValue=${GitHub_User} \
ParameterKey=GitHubRepo,ParameterValue=${GitHub_Repo} \
ParameterKey=GitHubBranch,ParameterValue=${GitHub_Branch} \
ParameterKey=GitHubToken,ParameterValue=${GitHub_Token} \
ParameterKey=PythonBuildVersion,ParameterValue=${Python_Build_Version} \
ParameterKey=BuildTimeoutMins,ParameterValue=${Build_Timeout_Mins} \
ParameterKey=InstanceCount,ParameterValue=${Instance_Count} \
ParameterKey=InstanceType,ParameterValue=${Instance_Type} \
ParameterKey=MaxRuntimeInSeconds,ParameterValue=${Max_Runtime_In_Seconds} \
ParameterKey=VolInGB,ParameterValue=${Vol_In_GB} \
--capabilities CAPABILITY_NAMED_IAM
rm -rf ./LambdaFunction.zip