compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (24)

View Page History


We want to support three environments; Dev, Test and Production. Dev environment will automatically be updated with latest and greatest. Test environment will be automatically updated with the latest release. Manual deploy to production. This set up supports continuous delivery, and it is easy to enable continuous deployment when/if we want.
We support three environments; Devtest, Systest and Production. Devtest environment is automatically updated with latest and greatest version. Test environment is automatically updated with the latest release. Manual deploy to production. This set up supports continuous delivery, and it is easy to enable continuous deployment when/if we want.

Continuous deployment means that every change is automatically deployed to production. [Continuous delivery|https://en.wikipedia.org/wiki/Continuous_delivery] means that the team ensures every change can be deployed to production, but may choose not to do it.

We use maven profiles to differentiate deployment to different environments. lambda-deploy-devtest/lambda-deploy-systest profiles are using executions to hook into deploy phase and run plugin goal deploy-lambda.


TODO: use complete lambduh:deploy-lambda command lines for each environment later. Easier to read.

|| Trigger || CI server || Plugin internals || Comment ||
|1. Developer: push to Git \\ 2. mvn clean deploy |Post step: \\ lambda:deploy-lambda -Plambda-deploy-devtest ||alias LATEST and withPublish=false is set in pom.xml | |
|1. CI server: successful mvn release |Release goals and options: \\release:perform lambda:deploy-lambda -Plambda-deploy-systest |alias <version>* and withPublish=true is set in pom.xml | |
|1. CI server: manually |Job: \\mvn lambduh:deploy-lambda -Dartifact=groupId:artifactId:version\[:packaging\]\[:classifier\] -Dalias=PROD -Plambda-deploy-devtest -DremoteRepositories= |alias <version>* and withPublish=true is set automatically |If using the same AWS account for test and prod environment, this deployment can easily be done manually without a CI server job. |

* (version is same as version from jar file, but with "-" uinstead of ".")


lambda-plugin will use http://maven.apache.org/plugins/maven-dependency-plugin/get-mojo.html under the hood to download artifacts
Deploy to production is using http://maven.apache.org/plugins/maven-dependency-plugin/get-mojo.html as a pre step


# Developer: push to Git
# Jenkins: mvn clean deploy
# Jenkins: on successful build, trigger new job: lambduh-maven-plugin step: lambda-maven-plugin
## Download snapshot version from mvn repo and upload to S3
## alias: DEV (reused), LATEST (reused)
## withPublish=false
## withPublish=false, forceUpdate=true

h3. Test environment - autodeploy

# Developer (in Jenkins): trigger mvn release
# Jenkins: on successful build, trigger new job: lambduh-maven-plugin step: lambda-maven-plugin
## Download release version from mvn repo and upload to S3
## alias: TEST (reused), <version> (version is same as version from jar file, but with "-" unstead of ".")
## withPublish=true

h3. Production environment - manual

# Developer (in Jenkins): trigger new job: lambduh-maven-plugin lambda-maven-plugin
## Download release from mvn repo and upload to S3
## alias: PROD (reused), <version> (version is same as version from jar file, but with "-" unstead of ".")
## Upload file to S3 and deploy
## profile:lambda-deploy-prod (reused), <lambda.version> mvn release version
## withPublish=true

Example
{code:title=Example steps for deployment to production}
# step. Download artifact
org.apache.maven.plugins:maven-dependency-plugin:2.10:copy \
-DoutputDirectory=/tmp \
-Dmdep.stripVersion=false \
-DoverWriteReleases=true \
-DoverWriteIfNewer=true \
-Dartifact=groupId:artifactId:$MVN_RELEASE_VERSION:jar

# step. Deploy artifact
no.cantara.maven.plugins:lambda-maven-plugin:2.0-beta-1:deploy-lambda \
-Dlambda.functionCode=/tmp/$MVN_RELEASE_VERSION.jar -Dlambda.version=$MVN_RELEASE_VERSION \
-Plambda-deploy-prod
{code}

h3. Tech
** http://maven.apache.org/maven-release/maven-release-plugin/
* Maven plugin for deloy to AWS Lambda, https://github.com/Cantara/lambduh-maven-plugin
* Jenkins

Example pom.xml configuration using profiles.
{code}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<build>
<plugins>
<plugin>
<groupId>no.cantara.maven.plugins</groupId>
<artifactId>lambda-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<configuration>
<functionCode>${lambda.functionCode}</functionCode>
<version>${lambda.version}</version>
<lambdaRoleArn>arn:aws:iam::ID:role/YourRole</lambdaRoleArn>
<s3Bucket>FILE_DESTINATION_BUCKET</s3Bucket>
<lambdaFunctionsJSON>
[
{
"functionName": "function1,
"description": "Example of Function1",
"handler": "no.cantara.Function1"
},
{
"functionName": "embriq-qf-soria-to-workorder",
"description": "Example of Function1",
"handler": "no.cantara.Function2"
}
]
</lambdaFunctionsJSON>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>lambda-deploy-devtest</id>
<build>
<plugins>
<plugin>
<groupId>no.cantara.maven.plugins</groupId>
<artifactId>lambda-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-lambda</id>
<phase>deploy</phase>
<configuration>
<functionNameSuffix>devtest</functionNameSuffix>
<vpcSecurityGroupIds>
<vpcSecurityGroupId>sg-1</vpcSecurityGroupId>
</vpcSecurityGroupIds>
<vpcSubnetIds>
<vpcSubnetId>subnet-1</vpcSubnetId>
<vpcSubnetId>subnet-2</vpcSubnetId>
<vpcSubnetId>subnet-3</vpcSubnetId>
</vpcSubnetIds>
<publish>false</publish>
<forceUpdate>true</forceUpdate>
</configuration>
<goals>
<goal>deploy-lambda</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>lambda-deploy-systest</id>
<build>
<plugins>
<plugin>
<groupId>no.cantara.maven.plugins</groupId>
<artifactId>lambda-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy-lambda</id>
<phase>deploy</phase>
<configuration>
<functionNameSuffix>systest</functionNameSuffix>
<vpcSecurityGroupIds>
<vpcSecurityGroupId>sg-1</vpcSecurityGroupId>
</vpcSecurityGroupIds>
<vpcSubnetIds>
<vpcSubnetId>subnet-1</vpcSubnetId>
<vpcSubnetId>subnet-2</vpcSubnetId>
<vpcSubnetId>subnet-3</vpcSubnetId>
</vpcSubnetIds>
<publish>true</publish>
</configuration>
<goals>
<goal>deploy-lambda</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>lambda-deploy-prod</id>
<build>
<plugins>
<plugin>
<groupId>no.cantara.maven.plugins</groupId>
<artifactId>lambda-maven-plugin</artifactId>
<configuration>
<functionNameSuffix>prod</functionNameSuffix>
<vpcSecurityGroupIds>
<vpcSecurityGroupId>sg-11</vpcSecurityGroupId>
</vpcSecurityGroupIds>
<vpcSubnetIds>
<vpcSubnetId>subnet-22</vpcSubnetId>
<vpcSubnetId>subnet-33</vpcSubnetId>
<vpcSubnetId>subnet-44</vpcSubnetId>
</vpcSubnetIds>
<publish>true</publish>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
{code}

h3. Read more