diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..add6849 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,23 @@ +pipeline { + agent{ + node{ + label 'Built-In' + } + } + stages { + stage('Lambda Deployment') { + when { branch 'develop'} + steps { + timeout(time: 150, unit: 'SECONDS') { + input "Replace Lambda Source Code ?" + } + script { + sh "export AWS_PROFILE=cd-sandbox" + sh "aws --version" + + sh "aws lambda update-function-code --function-name lambda-automation-test --zip-file fileb://lambda-function.zip --region us-east-1" + } + } + } + } +} \ No newline at end of file diff --git a/ci/lambda-test.sh b/ci/lambda-test.sh new file mode 100644 index 0000000..02703f5 --- /dev/null +++ b/ci/lambda-test.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +ROLE_ARN=$1 +AWS_PROFILE=$2 +ROLE_SESSION_NAME=lambda-deployment + +# this assumes that the ecr_login has been done before which gives the docker container access to the production server deployment role +CREDENTIALS=`aws sts assume-role --role-arn $1 --role-session-name $ROLE_SESSION_NAME --profile $2` +export AWS_ACCESS_KEY_ID=`echo $CREDENTIALS | jq -r .Credentials.AccessKeyId` +export AWS_SECRET_ACCESS_KEY=`echo $CREDENTIALS | jq -r .Credentials.SecretAccessKey` +export AWS_SESSION_TOKEN=`echo $CREDENTIALS | jq -r .Credentials.SessionToken` +export AWS_DEFAULT_REGION='us-east-1' + +echo $AWS_ACCESS_KEY_ID +echo $AWS_SECRET_ACCESS_KEY +echo $AWS_SESSION_TOKEN + +aws lambda update-function-code --function-name lambda-automation-test --zip-file fileb://../lambda-function.zip \ No newline at end of file diff --git a/lambda-function.zip b/lambda-function.zip new file mode 100644 index 0000000..5ba0bd7 Binary files /dev/null and b/lambda-function.zip differ