Wednesday, November 2, 2016

Run Docker JBoss Wildfly image on AWS ECS

Install Docker on AWS ECS

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
[ec2-user@ip-172-31-31-199 ~]$ sudo yum update -y
Loaded plugins: priorities, update-motd, upgrade-helper
No packages marked for update
[ec2-user@ip-172-31-31-199 ~]$  sudo yum install -y docker
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 0:1.11.2-1.6.amzn1 will be installed
--> Processing Dependency: xfsprogs for package: docker-1.11.2-1.6.amzn1.x86_64
--> Running transaction check
---> Package xfsprogs.x86_64 0:3.2.2-2.20.amzn1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package         Arch          Version                   Repository        Size
 docker          x86_64        1.11.2-1.6.amzn1          amzn-main         17 M
Installing for dependencies:
 xfsprogs        x86_64        3.2.2-2.20.amzn1          amzn-main        1.7 M

Transaction Summary
Install  1 Package (+1 Dependent package)

Total download size: 18 M
Installed size: 59 M
Downloading packages:
(1/2): docker-1.11.2-1.6.amzn1.x86_64.rpm                |  17 MB     00:00     
(2/2): xfsprogs-3.2.2-2.20.amzn1.x86_64.rpm              | 1.7 MB     00:00     
Total                                               21 MB/s |  18 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : xfsprogs-3.2.2-2.20.amzn1.x86_64                             1/2 
  Installing : docker-1.11.2-1.6.amzn1.x86_64                                                        2/2 
  Verifying  : docker-1.11.2-1.6.amzn1.x86_64                                                        1/2 
  Verifying  : xfsprogs-3.2.2-2.20.amzn1.x86_64                                                      2/2 

  docker.x86_64 0:1.11.2-1.6.amzn1                                                                       

Dependency Installed:
  xfsprogs.x86_64 0:3.2.2-2.20.amzn1                                                                     

[ec2-user@ip-172-31-31-199 ~]$ sudo service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:    .                                  [  OK  ]
[ec2-user@ip-172-31-31-199 ~]$ sudo usermod -a -G docker ec2-user
[ec2-user@ip-172-31-31-199 ~]$ 

Verify Docker status

[ec2-user@ip-172-31-31-199 ~]$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.11.2
Storage Driver: devicemapper
 Pool Name: docker-202:1-394626-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 11.8 MB
 Data Space Total: 107.4 GB
 Data Space Available: 7.223 GB
 Metadata Space Used: 581.6 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.93-RHEL7 (2015-01-28)
Logging Driver: json-file
Cgroup Driver: cgroupfs
 Volume: local
 Network: null host bridge
Kernel Version: 4.4.23-31.54.amzn1.x86_64
Operating System: Amazon Linux AMI 2016.09
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.4 MiB
Name: ip-172-31-31-199
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
[ec2-user@ip-172-31-31-199 ~]$ 

Run JBoss Wildfly Docker image

[ec2-user@ip-172-31-31-199 ~]$ docker run -it -p 8080:8080 jboss/wildfly 

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true


21:14:22,924 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
21:14:23,279 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
21:14:23,368 INFO  [] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting

List Docker processes

[ec2-user@ip-172-31-31-199 ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
0a5959e5cd9e        jboss/wildfly       "/opt/jboss/wildfly/b"   9 minutes ago       Up 9 minutes>8080/tcp   adoring_allen

Connect to Wildfly with links browser from other shell

Install links and connect to http:localhost:8080

[ec2-user@ip-172-31-31-199 ~]$ yum install links

[ec2-user@ip-172-31-31-199 ~]$ links http://localhost:8080

Monday, October 31, 2016

Install Java EE7 application using JBoss Wildfly Docker image

Docker and WildFly Part 1 - Deployment via Docker volumes 

Docker and WildFly Part 2 - Deployment over management API

Download JBoss Wildfly image

[dave@localhost wildfly]$ docker run -it jboss/wildfly
Unable to find image 'jboss/wildfly:latest' locally
latest: Pulling from jboss/wildfly

8d30e94188e7: Pull complete 
183bb107e46a: Pull complete 
9ea1527ac190: Pull complete 
d632efeddd98: Pull complete 
11af01a2d795: Pull complete 
Digest: sha256:2bed1e7a68245509de5837435b6250491efe61a86533f5ce6bf94927814076fb
Status: Downloaded newer image for jboss/wildfly:latest

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true


Use port redirect to see Wildfly running in the browser

[dave@localhost wildfly]$ docker run -it -p 8080:8080 jboss/wildfly 

Wildfly home page
Add access to console using own Dockerfile

[dave@localhost wildfly]$ more Dockerfile 
FROM jboss/wildfly:latest

USER jboss
RUN /opt/jboss/wildfly/bin/ admin MY_PASSWORD_TO_ACCESS --silent
CMD ["/opt/jboss/wildfly/bin/", "-b", "", "-bmanagement", ""]

Build the Docker image

[dave@localhost wildfly]$ docker build --tag=wildfly-mgmt .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM jboss/wildfly:latest
 ---> 4c99bd2cd264
Step 2 : USER jboss
 ---> Running in de10054221e5
 ---> f3b3e54e823b
Removing intermediate container de10054221e5
Step 3 : RUN /opt/jboss/wildfly/bin/ admin MY_PASSWORD_TO_ACCESS --silent
 ---> Running in 9af7cd245555
 ---> 5a29ccf7bef0
Removing intermediate container 9af7cd245555
Step 4 : CMD /opt/jboss/wildfly/bin/ -b -bmanagement
 ---> Running in 642784343b49
 ---> 3ea63bcef45a
Removing intermediate container 642784343b49
Successfully built 3ea63bcef45a

Start with port 8080 and 9990 redirected

[dave@localhost wildfly]$ docker run -it -p 8080:8080 -p 9990:9990  wildfly-mgmt

Check the console access via browser on 9990

Deploy Java EE7 app using Maven

Source code for the application GitHub

[dave@localhost dave-java-ee7-wildfly-full]$  mvn clean package wildfly:deploy
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] dave-java-ee7-wildfly-full
[INFO] dave-java-ee7-wildfly-full: EJB Module
[INFO] dave-java-ee7-wildfly-full: WAR Module
[INFO] dave-java-ee7-wildfly-full: EAR Module
[INFO] ------------------------------------------------------------------------
[INFO] Building dave-java-ee7-wildfly-full 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ dave-java-ee7-wildfly-full ---
[INFO] >>> wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) > package @ dave-java-ee7-wildfly-full >>>
[INFO] <<< wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) < package @ dave-java-ee7-wildfly-full <<<
[INFO] --- wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) @ dave-java-ee7-wildfly-full ---

Deployment in Docker Widlfy

05:32:38,366 INFO  [] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 4639ms - Started 331 of 577 services (393 services are lazy, passive or on-demand)
05:43:49,778 INFO  [] (management-handler-thread - 1) WFLYDR0001: Content added at location /opt/jboss/wildfly/standalone/data/content/a1/58abbd7beeb79e23f10486bbefb72f55dc5368/content
05:43:49,861 INFO  [] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "dave-java-ee7-wildfly-full-ear.ear" (runtime-name: "dave-java-ee7-wildfly-full-ear.ear")
05:43:50,006 INFO  [] (MSC service thread 1-5) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-web.war")
05:43:50,006 INFO  [] (MSC service thread 1-7) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-ejb.jar")
05:43:50,168 WARN  [] (MSC service thread 1-1) WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in a future version.
05:43:50,620 INFO  [] (MSC service thread 1-5) WFLYJPA0002: Read persistence.xml for primary
05:43:50,900 INFO  [] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/dave-java-ee7-wildfly-fullDS]
05:43:50,966 INFO  [] (ServerService Thread Pool -- 69) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'dave-java-ee7-wildfly-full-ear.ear/dave-java-ee7-wildfly-full-ejb.jar#primary'
05:43:50,977 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-ear.ear
05:43:51,095 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 69) HHH000204: Processing PersistenceUnitInfo [
    name: primary
05:43:51,494 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-1) HV000001: Hibernate Validator 5.2.4.Final
05:43:51,653 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 69) HHH000412: Hibernate Core {5.0.10.Final}
05:43:51,655 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 69) HHH000206: not found
05:43:51,664 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 69) HHH000021: Bytecode provider name : javassist
05:43:51,864 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 69) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
05:43:52,082 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-ejb.jar
05:43:52,090 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-web.war
05:43:52,120 INFO  [] (MSC service thread 1-1) WFLYEJB0473: JNDI bindings for session bean named 'MemberRegistration' in deployment unit 'subdeployment "dave-java-ee7-wildfly-full-ejb.jar" of deployment "dave-java-ee7-wildfly-full-ear.ear"' are as follows:


Check the application in the browser

Tuesday, October 25, 2016

Run Arquillian test on JBoss EAP 7/ Wildfly 10 using Arquillian Chameleon Container


Arquillian Chameleon Container

 Add Maven dependency ( check for latest version )


Add container configuration into arquillian.xml file

<arquillian xmlns=""
     <container qualifier="chameleon" default="true">
            <property name="chameleonTarget">jboss eap:7.0.1:remote</property>
            <property name="managementAddress">localhost</property>
            <property name="managementPort">9990</property>
            <property name="username">${jboss.admin.user}</property>
            <property name="password">${jboss.admin.password}!</property>

Add Maven dependencies in multi-module project using shrinkwrap-resolver-impl-maven

Add Chameleon container dependency ( using runTests profile )


Run the single test using Maven command line

$ mvn clean install -PrunTests  -Dtest=ArqTestCase

Tuesday, October 11, 2016

Install Citrix receiver on Fedora

Download latest Citrix reciever from Citrix web

Install Citrix Receiver

[root@linux ~]# dnf info ICAClient
Last metadata expiration check: 1:56:02 ago on Tue Oct 11 14:24:35 2016.
Installed Packages
Name        : ICAClient
Arch        : x86_64
Epoch       : 0
Version     :
Release     : 0
Size        : 45 M
Repo        : @System
From repo   : @commandline
Summary     : Citrix Receiver for Linux
URL         :
License     : Commercial
Description : Citrix Receiver lets you access your enterprise files, applications, and
            : desktops from your favorite device wherever you are. Just ask your IT
            : department how to get started.

If you see SSL error on connection attemt

Extract  AddTrustExternalCARoot from Firefox -> Preferences -> Advanced -> Certificates -> CA certs ->
Export CA cert AddTrustExternalCARoot to disk

Or download CA certificate from Comodo

Copy CA certificate into Citrix installation

[root@linux ~]# cp AddTrustExternalCARoot.crt /opt/Citrix/ICAClient/keystore/cacerts/

Use Google Chrome to connect

Sunday, October 9, 2016

Install and configure Docker on Fedora

Installation guide for Fedora

Install Docker using DNF

Enable docker service and start it

[root@localhost ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/docker.service.

[root@localhost ~]# systemctl start docker
[root@localhost ~]# ps -aef |grep docker
root      6785     1  2 10:32 ?        00:00:00 /usr/bin/dockerd
root      6796  6785  0 10:32 ?        00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc

Run the hello world

[root@localhost ~]# docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:

For more examples and ideas, visit:

Create group docker and add own user 

[root@localhost ~]# usermod -aG docker dave

It is necessary to reboot to get rights as non-root user

[dave@localhost docker]$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:

For more examples and ideas, visit:
Paste your text here.

Run Ubuntu image

[dave@localhost docker]$ docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
cad964aed91d: Pull complete 
3a80a22fea63: Pull complete 
50de990d7957: Pull complete 
61e032b8f2cb: Pull complete 
9f03ce1741bf: Pull complete 
Digest: sha256:28d4c5234db8d5a634d5e621c363d900f8f241240ee0a6a978784c978fe9c737
Status: Downloaded newer image for ubuntu:latest
root@e0fdce56f046:/# hostname
root@e0fdce56f046:/# more /etc/issue
Ubuntu 16.04.1 LTS \n \l


Running processes in hosting Fedora system

[root@localhost ~]# ps -aef |grep docker
root      1732     1  1 13:09 ?        00:00:08 /usr/bin/dockerd
root      1901  1732  0 13:09 ?        00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc
dave      3643  3343  0 13:15 pts/0    00:00:00 docker run -it ubuntu bash
root      3855  1901  0 13:15 ?        00:00:00 docker-containerd-shim e0fdce56f046997246242db8c1ad224337dc4915f3ee497c8ae66e321c1f445f /var/run/docker/libcontainerd/e0fdce56f046997246242db8c1ad224337dc4915f3ee497c8ae66e321c1f445f docker-runc
[root@localhost ~]# 

List containers
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
e0fdce56f046        ubuntu              "bash"              5 minutes ago       Up 5 minutes                                   furious_heisenberg
04899e84663d        hello-world         "/hello"            9 minutes ago       Exited (0) 9 minutes ago                       big_newton

Create own image
 ( using tutorial )

[dave@localhost docker]$ cat Dockerfile 
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay

[dave@localhost docker]$ docker build -t docker-whale .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM docker/whalesay:latest
 ---> 6b362a9f73eb
Step 2 : RUN apt-get -y update && apt-get install -y fortunes
 ---> Running in a2501bfa86f4
Ign trusty InRelease
Get:1 trusty-updates InRelease [65.9 kB]
Get:2 trusty-security InRelease [65.9 kB]
Hit trusty Release.gpg
Hit trusty Release
Get:3 trusty-updates/main Sources [474 kB]
Get:4 trusty-updates/restricted Sources [5247 B]
Get:5 trusty-updates/universe Sources [209 kB]
Get:6 trusty-updates/main amd64 Packages [1125 kB]
Get:7 trusty-updates/restricted amd64 Packages [23.5 kB]
Get:8 trusty-updates/universe amd64 Packages [485 kB]
Get:9 trusty-security/main Sources [153 kB]
Get:10 trusty-security/restricted Sources [3944 B]
Get:11 trusty-security/universe Sources [51.3 kB]
Get:12 trusty-security/main amd64 Packages [662 kB]
Get:13 trusty-security/restricted amd64 Packages [20.2 kB]
Get:14 trusty-security/universe amd64 Packages [180 kB]
Hit trusty/main Sources
Hit trusty/restricted Sources
Hit trusty/universe Sources
Hit trusty/main amd64 Packages
Hit trusty/restricted amd64 Packages
Hit trusty/universe amd64 Packages
Fetched 3525 kB in 3s (1060 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  fortune-mod fortunes-min librecode0
Suggested packages:
  x11-utils bsdmainutils
The following NEW packages will be installed:
  fortune-mod fortunes fortunes-min librecode0
0 upgraded, 4 newly installed, 0 to remove and 87 not upgraded.
Need to get 1961 kB of archives.
After this operation, 4817 kB of additional disk space will be used.
Get:1 trusty/main librecode0 amd64 3.6-21 [771 kB]
Get:2 trusty/universe fortune-mod amd64 1:1.99.1-7 [39.5 kB]
Get:3 trusty/universe fortunes-min all 1:1.99.1-7 [61.8 kB]
Get:4 trusty/universe fortunes all 1:1.99.1-7 [1089 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 1961 kB in 0s (2729 kB/s)
Selecting previously unselected package librecode0:amd64.
(Reading database ... 13116 files and directories currently installed.)
Preparing to unpack .../librecode0_3.6-21_amd64.deb ...
Unpacking librecode0:amd64 (3.6-21) ...
Selecting previously unselected package fortune-mod.
Preparing to unpack .../fortune-mod_1%3a1.99.1-7_amd64.deb ...
Unpacking fortune-mod (1:1.99.1-7) ...
Selecting previously unselected package fortunes-min.
Preparing to unpack .../fortunes-min_1%3a1.99.1-7_all.deb ...
Unpacking fortunes-min (1:1.99.1-7) ...
Selecting previously unselected package fortunes.
Preparing to unpack .../fortunes_1%3a1.99.1-7_all.deb ...
Unpacking fortunes (1:1.99.1-7) ...
Setting up librecode0:amd64 (3.6-21) ...
Setting up fortune-mod (1:1.99.1-7) ...
Setting up fortunes-min (1:1.99.1-7) ...
Setting up fortunes (1:1.99.1-7) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
 ---> d32c0f1dd6fd
Removing intermediate container a2501bfa86f4
Step 3 : CMD /usr/games/fortune -a | cowsay
 ---> Running in 4be6a9e302e6
 ---> 04c2ee13ff82
Removing intermediate container 4be6a9e302e6
Successfully built 04c2ee13ff82

Run own image

[dave@localhost docker]$ docker run docker-whale
/ Now Denial:                          \
|                                      |
| To tell oneself that the only time   |
| worth living in is the past and that |
| the only time that may ever be       |
| interesting again is the future.     |
|                                      |
| -- Douglas Coupland, "Generation X:  |
| Tales for an Accelerated             |
|                                      |
\ Culture"                             /
                    ##        .            
              ## ## ##       ==            
           ## ## ## ##      ===            
       /""""""""""""""""___/ ===        
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~   
       \______ o          __/            
        \    \        __/             

Saturday, September 24, 2016

AWS IAM setup for CodeDeploy

Create new IAM user using AWS console

Create new user awsdave

Download user credentials into file


Create new policies using AWS console

 Create new custom policy CodeDeploy and


Create new roles using AWS console

Create roles and assign policy as described in AWS tutorial video

Create role CodeDeploy
Create role EC2CodeDeploy

Edit trust relationship for the created Role if needed

Launch EC2 instance 


Select EC2 instance IAM role EC2CodeDeploy

Policy CodeDeploy

    "Version": "2012-10-17",
    "Statement": [
            "Action": [
            "Effect": "Allow",
            "Resource": "*"

Trust Relationship

  "Version": "2012-10-17",
  "Statement": [
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": [
      "Action": "sts:AssumeRole"

Wednesday, August 3, 2016

Deploy Java application from GitHub to AWS

HOWTO from AWS tutorial

AWS tutorial video  Code Deploy Setup (IAM, EC2)

GitHub for AWS tutorial video

AWS CodeDeploy tutorial video

Steps to create running AWS EC2 instance

Create AWS free account

Getting started :

Create AWS account

Create own Linux instance

Connect to AWS Linux instance via ssh

[dave@localhost aws]$ chmod 400 dave_amazon.pem
[dave@localhost aws]$ ssh -i "dave_amazon.pem"

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
8 package(s) needed for security, out of 17 available
Run "sudo yum update" to apply all updates.

Install AWS tools on Fedora

[root@localhost ~]# dnf install  awscli
Dependencies resolved.
 Package                  Arch         Version                               Repository     Size
 awscli                   noarch       1.10.45-1.fc23                        updates       868 k
 python3-botocore         noarch       1.4.35-1.fc23                         updates       1.8 M
 python3-colorama         noarch       0.3.2-2.fc23                          fedora         29 k
 python3-docutils         noarch       0.12-0.3.20140510svn7747.fc23         fedora        1.5 M
 python3-jmespath         noarch       0.9.0-1.fc23                          updates        43 k
 python3-pyasn1           noarch       0.1.8-1.fc23                          fedora        108 k
 python3-rsa              noarch       3.4.1-1.fc23                          updates        72 k
 python3-s3transfer       noarch       0.0.1-2.fc23                          updates        29 k

Transaction Summary
Install  8 Packages

Total download size: 4.5 M
Installed size: 27 M
Is this ok [y/N]: 
Paste your text here.


[dave@localhost aws]$ aws --version
aws-cli/1.10.45 Python/3.4.3 Linux/4.5.7-200.fc23.x86_64 botocore/1.4.35

 Add AWS IAM access keys

[dave@localhost aws]$ aws configure

Check running instances 

[dave@localhost aws]$ aws ec2 describe-instances 
    "Reservations": [
            "Instances": [

Integrating AWS CodeDeploy with GitHub

Setup roles in IAM

Amazon AWS Java samples

Create GitHub repository with sample application

User guide GitHub - AWS integration 

Create application - see tutorial page
  Step 5: Deploy the Application to the Instance

Connect with GitHub

Deploy AWS sample Linux

Check AWS CodeDeploy console

Deploy fails with HEALTH_CONSTRAINTS

It is necessary to install CodeDeploy on instance
Follow this tutorial :

Install or reinstall the AWS CodeDeploy agent for Amazon Linux or RHEL

[ec2-user@ip-172-31-21-129 ~]$ wget
--2016-08-07 13:45:20--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13359 (13K) []
Saving to: ‘install’

install                    100%[======================================>]  13.05K  78.6KB/s    in 0.2s    

2016-08-07 13:45:21 (78.6 KB/s) - ‘install’ saved [13359/13359]

Check installation success
[ec2-user@ip-172-31-21-129 ~]$ sudo service codedeploy-agent status
The AWS CodeDeploy agent is running as PID 2660

Deploy application from GithHub  using CodeDeploy - Deployments

Access application using public IP address

Check log on EC2 instance

c2-user]# tail -500f /var/log/httpd/access_log - - [24/Sep/2016:18:03:53 +0000] "GET / HTTP/1.1" 200 911 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0"

Sample app Linux

Sample Tomcat application on GitHub

You can also download sample app from Amazon S3
[dave@localhost aws]$ aws s3 cp s3://aws-codedeploy-eu-central-1/samples/latest/ . --region eu-central-1
download: s3://aws-codedeploy-eu-central-1/samples/latest/ to ./

[dave@localhost aws]$ unzip -l 
  Length      Date    Time    Name
---------  ---------- -----   ----
       34  11-03-2014 22:42   scripts/install_dependencies
       33  11-03-2014 22:43   scripts/start_server
      105  11-03-2014 22:43   scripts/stop_server
      359  11-03-2014 22:42   appspec.yml
      717  11-03-2014 22:42   index.html
    10884  11-03-2014 22:42   LICENSE.txt
---------                     -------
    12132                     6 files