- This is complete example how to setup java ee ready for micro service AWS Cloud deployment with AWS elastic beanstalk and AWS Code pipeline via AWS Code Build
Before changing properties you need to setup:
- AWS IAM user account with Elastic Beanstalk / EC2 Container read write permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
"s3:GetObjectVersion"
],
"Resource": "arn:aws:s3:::elasticbeanstalk-*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:GetAuthorizationToken",
"ecr:UploadLayerPart",
"elasticbeanstalk:CreateApplicationVersion",
"ecr:ListImages",
"ecr:PutImage",
"ecr:BatchGetImage",
"ecr:CompleteLayerUpload",
"ecr:DescribeImages",
"elasticbeanstalk:DescribeApplicationVersions",
"ecr:DescribeRepositories",
"ecr:InitiateLayerUpload",
"ecr:BatchCheckLayerAvailability",
"ecr:GetRepositoryPolicy"
],
"Resource": "*"
}
]
}- EC2 Container Registry and Elastic Beanstalk Single environment application with docker engine
Change aws config in gradle.properties:
groupName=icoder
awsECRName=YOUR_EC_REPOSITORY_NAME
awsId=YOUR_AWS_ID
awsEBSApp=YOUR_ELASTIC_BEANSTALK_APPLICATION_NAME
awsRegion=eu-central-1gradle clean build -Penv=localServer will be running on default port 8080
gradle startServergradle testBefore tests docker compose hast to be started because you may need an local data store which you can run in docker.
Run compose once:
gradle dockerComposeThen start tests:
gradle itestgradle startDocker
gradle stopDokerThis command creates elastic beanstalk application deployment version and publish baked container to EC2 Container Repository:
gradle clean publishToECR -Penv=prod You can simply run them as jar applications or you can configure your ide to run jar application so you can debug it.
gradle build -Penv=local
java -jar ./pajara-micro.jar --deploy ./build/libs/starter-1.0.0.warnote if you did not download payara micro run
gradle downloadPayaraMicro