Tuesday, May 13, 2025

Jenkins part2

Jenkins part2
Class 22nd Jenkins May 13th
Alternative Jenkins 
 1.Github Actions
2.Git Lab CI/CD
3. AWS Pipeline 
4.Azure Devops(pipelines)
5.CicleCI
6.Travis CI
7.ArgoCD (for Kubernetes -based CI/CD)

Jenkins Triggers 
->Jenkins triggers define how and when a Jenkins job or pipeline should start
->You can configure different types of triggers to automate the execution of builds based on events such as code commits,scheduled times,or external API calls 

1.Trigger builds remotely Allows external scripts or applications to trigger Jenkins builds.

For Control and security purpose 

Step1: Security token generation
In Jenkins, a Security Token (often called an API token or Crumb token) is used to authenticate and authorize automated requests to Jenkins.
A Security Token in Jenkins is like a password :
Scripts, tools, or external services (like GitHub, curl, Postman) access Jenkins
Do this without exposing your actual password
See here token generated : copy and save that token it will come again


117e71fe284ff0777e2b9c5a8345c9cd09

Step2: which i have created job  configuration,given the name Security key name for authorization click save 

Step3:just create one file in workspace our job folder save and click build
Step4:Bulid Success 

Step6: file created successfully

[root@ip-10-0-1-168 ccit-job]# pwd
/var/lib/jenkins/workspace/ccit-job
[root@ip-10-0-1-168 ccit-job]# ls -lrt
total 4
drwxr-xr-x 3 jenkins jenkins   18 May 14 03:58 src
-rw-r--r-- 1 jenkins jenkins 1541 May 14 03:58 pom.xml
drwxr-xr-x 6 jenkins jenkins  141 May 14 03:58 target
-rw-r--r-- 1 jenkins jenkins    0 May 14 06:17 ccit.txt

Step7:
Trigger builds remotely, as you here comment specified build using url also with token name 

JENKINS_URL/job/ccit-job/build?token=TOKEN_NAME

http://3.252.96.43:8080/job/ccit-job/build?token=ccittoken

using command line enter this command build the application 

 This is one way to Build 
C:\Users\Administrator>curl -u admin:117e71fe284ff0777e2b9c5a8345c9cd09 "http://3.252.96.43:8080/job/ccit-job/build?token=ccittoken"

See here automatically build started using authentication code CLI prompt
 This is other way to Build 
  

 see Build success



2.Build after other projects are built: ( it is dependency for other project,after the project compile, start build the current project)  -Not covered 
Configures a job to run after one   or more other jobs are completed   
Ensure that dependent builds are executed only when their prerequisites are succesfull.
3.Build periodically? :   (Cron expression run schedule base) When to perform the build period
(*)    (*)      (*)     (*)    (*)
Min  Hour  DOM  MOY (DOW)
Triggers a job at a scheduled time using CRON syntax 
Useful for routine tasks like nightly build or scheduled maintenance jobs 
MINUTEMinutes within the hour (0–59)
HOURThe hour of the day (0–23)
DOMThe day of the month (1–31)
MONTHThe month (1–12)
DOWThe day of the week (0–7) where 0 and 7 are Sunday.

You see here given all 5 start it will run every minute all days

See here Build running every 1 mint

See here i just changed to 53 8 AM Scheduled 


See here it run specific file 8:53 AM it is running


53 8 15(it will run 15th date) 8 (it will August month) , 3(day of the week) 
may be conflict 15 day is may be  or may not be wed day )
0 is sun , 1 is mon,2 is tue ,3 is wed , 4 thu , 5 fir, 6 sat , 7 is again sun unix 7 is not there 

4.GitHub hook trigger for GITScm polling? This is a build trigger option in Jenkins that lets GitHub notify Jenkins when new code is pushed to a repository. It’s faster and more efficient than Jenkins polling GitHub repeatedly.



Git Webbook set, whenever git commit Build done automatically ,Below Webhook give Jenkin url 
and click webhook

  
 Give below details Click save 




 Click Build manually See build 49 12.467 it is execute .jar file also create target server side 

Jar file created 

[ec2-user@ip-10-0-1-168 ccit-job]$ java -jar target/ccit-0.0.1.jar --server.address=0.0.0.0 --server.port=8081

Page opened 

 You see here java runtime alway be run if you stop webpage not work

So it is difficult always run manually instead of that we need create service that service always run background 

For that Git Index page added some text commit changes



see automatically build 



[ec2-user@ip-10-0-1-168 ccit-job]java -jar target/ccit-0.0.1.jar --server.address=0.0.0.0 --server.port=8081

See change once git commit automatically build done ,but above java jar need cancel and rerun effect the changes in webpage




Jar File run automictically need to configure service 

5.Poll SCM?: (it is also Same to Build periodically the difference is ,whenever Git commit Changes done then only it will trigger) SCM (source code management)
 
If you commit any change Git hub one id will create , The Jenkins monitor ID previous commit Id ,if any commit id changes then only build will run 
 
If you are Build period * * * * * , date and time will capture any 1 minute

Shell script for any other example for reference 
#!/bin/bash 
echo "Current date and time :" $(date) >> ccit.txt
[ec2-user@ip-10-0-1-168 ccit-job]$ cat ccit.txt
Current date and time : Wed May 14 12:19:30 UTC 2025
Current date and time : Wed May 14 12:20:00 UTC 2025
Current date and time : Wed May 14 12:21:00 UTC 2025


                                Build after other projects are built
This decencies one trigger to another Tigger, i have created  4 job all shell touch ccit1...4 txt files

step1:


Step2: ccotjob2 put dependencies ccitjob1 click save 
click one ccitjob1 manually ,automatically run remaining all

All dependencies job success one after another based on dependencies


All File created Successfully in the workspace directory

[ec2-user@ip-10-0-1-168 workspace]$ pwd
/var/lib/jenkins/workspace
[ec2-user@ip-10-0-1-168 workspace]$ ls
ccit-job  ccitjob1  ccitjob2  ccitjob3  ccitjob4
├── ccitjob1
│   └── ccit1.txt
├── ccitjob2
│   └── ccit2.txt
├── ccitjob3
│   └── ccitjob3.txt
└── ccitjob4
    └── ccitjob4.txt

                      Job Icon Legends

                                  --Thanks 







Monday, May 12, 2025

Jenkins

Jenkins
 Class 21st Jenkins May 12th
Jenkins is an open-source automation server that helps developers build,test, and deploy software efficiently.
it enables continuous integration (CI) and continuous development(CD)by automating tasks like pulling code from a repositry building application,running tests, and deploying software to production

Key Features of Jenkins 
1.Automated Build & Deployment :Jenkins automates the process of compiling.testing and deploying the application
2.Plugin support - Jenkins has a vast eco system of plugins to integrate with tools like git,docker ,kubernetes ,Aws ,and more 

How Jenkins works?
1. Developers push code to a repository (e.g Gut hub ,Git lab or Bitbucket)
2.Jenkins detects the change and triggers a job to fetch the latest code 
3.Jenkins builds the application using tools like maven,Gradle,or npm
4.Jenkins run automated test to check code quality
5.Jenkin notification:

Default path  /var/lib/jenkins

https://www.jenkins.io/

https://www.jenkins.io/doc/book/installing/linux/

Step1: Long term support 

sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
# Add required dependencies for the jenkins package
sudo yum install fontconfig java-21-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload

default path for Jjenkins /var/lib/Jenkins

Step2: Maven though some application building and  developing the artifacts 

get the pom.xml from git repo

[root@ip-10-0-1-168 ~]# sudo wget -O /etc/yum.repos.d/jenkins.repo \
>     https://pkg.jenkins.io/redhat-stable/jenkins.repo

[root@ip-10-0-1-168 ~]# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

[root@ip-10-0-3-152 ec2-user]# yum install -y java-17-amazon-corretto-devel

[root@ip-10-0-3-152 ec2-user]# yum install -y git

[root@ip-10-0-1-168 ~]# sudo yum install jenkins

--click y 

Status for Jenkins 

[root@ip-10-0-1-168 ~]# systemctl status jenkins

● jenkins.service - Jenkins Continuous Integration Server

   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)

   Active: inactive (dead)

May 14 01:59:03 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:16] Unknown lval...nit'

May 14 01:59:03 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:17] Unknown lval...nit'
May 14 01:59:55 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:16] Unknown lval...nit'
May 14 01:59:55 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:17] Unknown lval...nit'
Hint: Some lines were ellipsized, use -l to show in full.

Showing inactive make active 

[root@ip-10-0-1-168 ~]# systemctl start jenkins

[root@ip-10-0-1-168 ~]# systemctl status jenkins

Step3: Jenkins default port is 8080 

here telling Jenkins unlock and get password given below path, get the key ,give the key password
click continue

Step4: 
[root@ip-10-0-1-168 ~]# cd /var/lib/jenkins/secrets/
[root@ip-10-0-1-168 secrets]# ls
initialAdminPassword  jenkins.model.Jenkins.crumbSalt  master.key
[root@ip-10-0-1-168 secrets]# cat initialAdminPassword
ec84ee9900ef4cdbb741172024bb0405
Click install suggested plugins ,it Getting started installations


Step5: 
It is just like AWS im user's here iam creating amin user and some email-id save and continue


 this your Jenkins url http://3.252.96.43:8080/ click save and Finish  and start using jenkins 


Jenkins dashboard we creating jobs ,we have git repo need to build deploy it 


Manage Jenkins , we have some warning java 17 not support like information just ignore,
System configuration ,
node multiple server build purpose using
plugins special software msbuild like we get from here 
Tools >we have inbuilt software available maven/Ant /Gradle/Git 

Give name any and save just configured 

 Step6: Create job 
here different configuration ,Triggers 


Triggers 

Trigger builds remotely (e.g., from scripts) ?  For you job running give one url for secure give Authentication Token, based on token it will run 

Build after other projects are built? for multiple project ,we can give one by one 

Build periodically? ,We give time period just like crontab 

GitHub hook trigger for GITScm polling?( Our Git repos webhook we have to configure, so that whenevery you give commit , our build will run we just give jenkins url in the git) like this way we will do practical later 


Poll SCM?  it is also Cron periodically ,the difference build periodically it schedule every time 
if change doesnot matter it will run ,poll scm  only whenevery git commit change happen only triggered and build

Build Steps (Shell scripting , we can able given manually maven installation if you not added maven plugins..etc)

Step7: 
I did not any change click save and build went success 

Step8: Created job give below confirguration and save buid

Step9:Build success 

Step10:See here maven target folder created 
[root@ip-10-0-1-168 target]# pwd
/var/lib/jenkins/workspace/ccit-job/target
[root@ip-10-0-1-168 target]# ls -lrt
total 19660
drwxr-xr-x 3 jenkins jenkins       25 May 14 03:58 generated-sources
drwxr-xr-x 3 jenkins jenkins       35 May 14 03:58 maven-status
drwxr-xr-x 4 jenkins jenkins       34 May 14 03:58 classes
drwxr-xr-x 2 jenkins jenkins       28 May 14 03:58 maven-archiver
-rw-r--r-- 1 jenkins jenkins     3700 May 14 03:58 ccit-0.0.1.jar.original
-rw-r--r-- 1 jenkins jenkins 20125836 May 14 03:58 ccit-0.0.1.jar

Step11: execute jar file 8080 already jenkins running given different port 8081
java -jar target/ccit-0.0.1.jar  --server.address=0.0.0.0 --server.port=8081

[root@ip-10-0-1-168 target]# ls
ccit-0.0.1.jar  ccit-0.0.1.jar.original  classes  generated-sources  maven-archiver  maven-status
[root@ip-10-0-1-168 target]# cd ..
[root@ip-10-0-1-168 ccit-job]# java -jar target/ccit-0.0.1.jar --server.address=0.0.0.0 --server.port=8081
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.5)

Step12: See here below our website hosted 


 This Simple Java Webpage successfully Build 

   --Thanks 




Saturday, May 10, 2025

Terraform and Maven

 Terraform and Maven

Class 20th Terraform and Maven May 10 th(Devops)

Last class ,We have done git changes committed, after committed change will move  automatically 

HCP terraform plan will executed and after confirm and apply AWS resources are creating  succefully

HCP we have some policies also

We have Cost estimation also in HCP while you creating AWS resource it will communicate to the AWS cost portal,took the detail and publish in HCP 

             Cost Estimation Process 

Step1: Settings> Go Organization >click top most left hand side Hashcorp Icon/logo

Enable the Cost estimation click update settings 


Whatevery your trying create resource it will give you rough estimation 

Step2: Create Ec2 server, modify in git .tf file ,Click commit changes

Step3: Plan completed Cost estimated 

Step4: I have added 2 count of instance ,it was below cost estimation Monthly  $17.26 Dollar 2 instance
,as of now we are in free , after 12 months it will charge 

                                                                     Policies
HCP >Settings >Click logo > Policies >Create new policy 

 We need give instruction to HCP before creating instance resource, instance type,configuration(VPC)  cdr block limitation ..etc, those purpose we use policies 

Policy (If you create the policy it will applicable to complete project level)
Sentinel (it is complete HCP related,it will support terraform )
Open Policy Agent (it is related generic )
Just reference 
https://github.com/hashicorp/terraform-sentinel-policies

here Advisory ( it give advice which is you not follow the policy)
       Soft mandatory(even not follow ,it will apply your process will not stop)
       Hard mandatory(restrict must follow the policy,if not process will fail)

Step1:


Below for S3 bucket policy give tags name,project mandatory, select hard mandatory

import "tfplan"

# Warning, this is case sensitive.  
# This is on purpose especially for organizations that do cost analysis on tag names.
# where case sensitivity will cause grouping issues

mandatory_tags = [
  "Name", 
  "Project",
]

# Get all AWS S3 buckets contained in all modules being used
get_aws_s3_buckets = func() {
    buckets = []
    for tfplan.module_paths as path {
        buckets += values(tfplan.module(path).resources.aws_s3_bucket) else []
    }
    return buckets
}
    
aws_s3_buckets = get_aws_s3_buckets()

# S3 bucket tag rule
s3_bucket_tags = rule {
    all aws_s3_buckets as _, buckets {
        all buckets as index, r {
            all mandatory_tags as t {
                r.applied.tags contains t
            }
        }
    }
}

main = rule {
    (s3_bucket_tags) else true
}
Past the code in policy code then click> create policy

Step2: After create policy, Need to create policy sets >Select Individually managed policies 
if give particular workspace , we can choose else complete globally for all workspaces, select globally 
click next 


 Choose your policy ,connect policy set 

 Sentinel Policy set done, Pratical

Step3: S3 bucket tags are mandatory, As above policy two tags are mandatory ,we can try give only one tag, see hard monitory, failed or not ,below git code committed

provider "aws" {
  region = "eu-west-1"
}
resource "aws_s3_bucket" "ccitbucket" {
  bucket = "ccitaprilmay11"
 tags = {
   Name = "cpbucket"
       }
}

You see below plan executed success but Sentinel policy failed
Step4: After added second tag porject and git commit,HCP Sentinel policy passed ,Confirmation to apply
provider "aws" {
  region = "eu-west-1"
}
resource "aws_s3_bucket" "ccitbucket" {
  bucket = "ccitaprilmay11"
 tags = {
   Name = "cpbucket"
   Project ="ccitproject"
       }
}
AWS console s3 bucket created
            
Ec2 Sentinel policy 

import "tfplan"

# Warning, this is case sensitive.  
# This is on purpose especially for organizations that do cost analysis on tag names.
# where case sensitivity will cause grouping issues

mandatory_tags = [
  "Name", 
  "Project",
]

# Get all AWS instances contained in all modules being used
get_aws_instances = func() {
    instances = []
    for tfplan.module_paths as path {
        instances += values(tfplan.module(path).resources.aws_instance) else []
    }
    return instances
}
    
aws_instances = get_aws_instances()

# Instance tag rule
instance_tags = rule {
    all aws_instances as _, instances {
    all instances as index, r {
            all mandatory_tags as t {
                r.applied.tags contains t
            }
        }
    }
}

main = rule {
    (instance_tags) else true
}

Step1: Create new policy and policy set in Workspace  
Created Instance-sentinel-policy 

Set the existing policy sets 
Step2: Git code modified and do commit, if any previous runs pending discard and continue

provider "aws" {
  region = "eu-west-1"
}
resource "aws_instance" "aws_instanceind" {
ami = "ami-04e7764922e1e3a57"
instance_type= "t2.micro"
subnet_id     = "subnet-0477e85088645156b"
}


Step3:
provider "aws" {
  region = "eu-west-1"
}
resource "aws_instance" "aws_instanceind" {
ami = "ami-04e7764922e1e3a57"
instance_type= "t2.micro"
subnet_id     = "subnet-0477e85088645156b"
tags = {
   Name = "cpbucket"
   Project ="ccitproject"
       }
}
Sentinel Passed  after added tags in git commited and confirm apply


See new instance create successfully


For Destroy ,Same process after plan completed ,confirm apply

 AWS console and destroy in workspace applied instance terminated successfully.


Terraform  many limitation on based on usages


                                                             -- Terraform completed 

                                                                 Maven
Maven is Build tools for the java, whatevery you source code once you build run files are create,
those run file ,we can use and host the application( only run time file only)
microsoft msbuild the use
encrypted file 
java - .jar /.war/ .ear build files 
.net  .dll 

Maven:

Maven Installation

https://downloads.apache.org/maven/maven-3/3.9.9/binaries/ 

Copy link adddress 

wget https://downloads.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz

[root@ip-10-0-1-168 ~]# mkdir mywebapp

[root@ip-10-0-1-168 mywebapp]# wget https://downloads.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz

apache-maven-3.9.9-bin.tar.gz

[root@ip-10-0-1-168 ~]# tar -xvzf apache-maven-3.9.9-bin.tar.gz

[root@ip-10-0-1-168 ~]# sudo mv apache-maven-3.9.9  /opt/maven

[root@ip-10-0-1-168 mywebapp]# export M2_HOME=/opt/maven

[root@ip-10-0-1-168 mywebapp]# export PATH=$M2_HOME/bin:$PATH

[root@ip-10-0-1-168 mywebapp]# source ~/.bashrc

[root@ip-10-0-3-152 ec2-user]# yum install -y java-17-amazon-corretto-devel
[root@ip-10-0-1-168 mywebapp]# mvn --version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/maven
Java version: 17.0.15, vendor: Amazon.com Inc., runtime: /usr/lib/jvm/java-17-amazon-corretto.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.10.236-227.928.amzn2.x86_64", arch: "amd64", family: "unix"
[root@ip-10-0-1-168 mywebapp]# cat  vim pom.xml
cat: vim: No such file or directory
<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">

  <modelVersion>4.0.0</modelVersion>

  <!-- Inherit from Spring Boot Parent -->
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.5</version>
    <relativePath/>
  </parent>

  <groupId>com.example</groupId>
  <artifactId>mywebapp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>My Spring Boot Web App</name>
  <description>Cloud Computing in Telugu Web Application</description>

  <properties>
    <java.version>17</java.version>
  </properties>

  <dependencies>
    <!-- Spring Boot Web Starter (includes embedded Tomcat) -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- Thymeleaf Starter for HTML templating -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- Spring Boot Maven Plugin to build an executable jar -->
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

</project>

[root@ip-10-0-1-168 mywebapp]# mkdir -p src/main/java/com/example
[root@ip-10-0-1-168 mywebapp]# vim src/main/java/com/example/App.java
[root@ip-10-0-1-168 mywebapp]# cat src/main/java/com/example/App.java
package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@SpringBootApplication
@Controller
public class App {

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }

    @GetMapping("/")
    public String home(Model model) {
        // Pass the header text to the view
        model.addAttribute("header", "Cloud Computing in Telugu");
        return "index"; // Return the index.html template
    }
}
[root@ip-10-0-1-168 mywebapp]# mvn clean package

[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  11.507 s
[INFO] Finished at: 2025-05-13T19:57:59Z
[INFO] ------------------------------------------------------------------------
[root@ip-10-0-1-168 mywebapp]# yum install tree -y
[root@ip-10-0-1-168 mywebapp]# tree
.
├── apache-maven-3.9.9-bin.tar.gz
├── pom.xml
├── src
│   └── main
│       └── java
│           └── com
│               └── example
│                   └── App.java
└── target
    ├── classes
    │   └── com
    │       └── example
    │           └── App.class
    ├── generated-sources
    │   └── annotations
    ├── maven-archiver
    │   └── pom.properties
    ├── maven-status
    │   └── maven-compiler-plugin
    │       └── compile
    │           └── default-compile
    │               ├── createdFiles.lst
    │               └── inputFiles.lst
    ├── mywebapp-0.0.1-SNAPSHOT.jar
    └── mywebapp-0.0.1-SNAPSHOT.jar.original

[root@ip-10-0-1-168 mywebapp]# mvn spring-boot:run
[root@ip-10-0-1-168 mywebapp]#mkdir -p src/main/resources/templates/
[root@ip-10-0-1-168 mywebapp]# cd src/main/resources/templates/
[root@ip-10-0-1-168 mywebapp]#vi index.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Home</title>
</head>
<body>
    <h1 th:text="${header}">Fallback Header</h1>
</body>
</html>
[root@ip-10-0-1-168 mywebapp]# java -jar target/mywebapp-0.0.1-SNAPSHOT.jar --server.address=0.0.0.0 --server.port=8080

Take Public IP:



[root@ip-10-0-1-168 target]# aws s3 cp "./mywebapp-0.0.1-SNAPSHOT.jar" "s3://ccitsamplebucket123" --region "eu-west-1"
upload: ./mywebapp-0.0.1-SNAPSHOT.jar to s3://ccitsamplebucket123/mywebapp-0.0.1-SNAPSHOT.jar

Move the .jar file  s3 bucket prior you need admin role attached to Ec2 instance 
using this .jar with maven  build ,just execute the java file launch the website.

[root@ip-10-0-1-168 target]# aws s3 cp "./mywebapp-0.0.1-SNAPSHOT.jar" "s3://ccitsamplebucket123" --region "eu-west-1"
upload: ./mywebapp-0.0.1-SNAPSHOT.jar to s3://ccitsamplebucket123/mywebapp-0.0.1-SNAPSHOT.jar
aws S3 bucker console 


Build file using that launch the website

For Java build file .jar 

Dotnet .ddl 

Alternatives for maven (Gradle,Apache Ant,Bazel,Buildr)

 --Thanks