CD with AWS Elastic Beanstalk: CD pipelines

It might be a bit different from “classic” definition, but let’s call build & deploy logical steps “pipelines”.
Every logical step is put in separate function to make things simple & clear.
I’ll list and describe logical steps (functions sequence) for all actions for you:

Let’s start from the simplest example – createEbApp.sh script:
1. setVariables (we’ll use vars to store data such as file paths, emails, etc.)
2. cleanLogs (we’ll log important steps and we don’t need old logs)
3. installSoftware (we need only mail software in createEbApp stage, but we’ll install all)
4. setLogins (we’ll need permissions to create EB App)
5. createEbApp (the essence of this script; region & platform must be set correctly)
6. sendEmail (because we want to receive results to email)

 

createEbEnv:

1. clearLogs (already described above)
2. installSoftware (already described above)
3. setLogins (already described above)
4. cloneGit (we’ll clone git repo with source code)
5. setGitSchedule (we’ll schedule git pull to keep sources up to date)
6. buildApp (we’ll build app using meteor and node)
7. runLocalApp (we need run app to check it on the next step)
8. checkLocalApp (we’ll check built app and we’ll move forward only if it’s ok)
9. stopLocalApp (we don’t need running app anymore)
10. createDockerfile (we’ll create simple Dockerfile)
11. deleteDockerContainers (we’ll delete old Docker containers it they’re present)
12. deleteDockerImages (we’ll delete old Docker images it they’re present)
13. buildDockerImage (we’ll build Docker image with our app)
14. runLocalDocker (we need to run docker to check app on the next step)
15. checkLocalApp (we’ll check our app running in Docker container)
16. deleteDockerContainers (we’ll delete Docker container because we don’t need it anymore)
17. pushDockerImage (we’ll upload our Docker image to DockerHub)
18. deleteDockerImages (we’ll delete our Docker image because we don’t need it anymore)
19. createDockerrun (we’ll create Dockerrun file to use with AWS)
20. checkEbCnames (we’ll check availability of desired CNAMEs)
21. initEbEnv (we’ll create Eb initial config files)
22. createEbEnv (we’ll create and setup EbEnv using custom configuration)
23. checkEbApp (we’ll check our app running in EbEnv)
24. addGitHook (we’ll add post-merge git hook )
25. sendEmail (we’ll check our app running in Docker container)

 

deployEbEnv:

1. clearLogs (already described above)
2. installSoftware (already described above)
3. setLogins (already described above)
4. checkGitStatus (git HEAD must be attached)
5. setGitSchedule (already described above)
6. buildApp (already described above)
7. runLocalApp (already described above)
8. checkLocalApp (already described above)
9. stopLocalApp (already described above)
10. createDockerfile (already described above)
11. deleteDockerContainers (already described above)
12. deleteDockerImages (already described above)
13. buildDockerImage (already described above)
14. runLocalDocker (already described above)
15. checkLocalApp (already described above)
16. deleteDockerContainers (already described above)
17. pushDockerImage (already described above)
18. deleteDockerImages (already described above)
19. initEbEnv (already described above)
20. deployEbApp (we’ll deploy new code without environment setting change)
21. checkEbApp (already described above)
22. sendEmail (already described above)

 

restoreEbEnv:

1. clearLogs (already described above)
2. installSoftware (already described above)
3. setLogins (already described above)
4. setGitSchedule (already described above)
5. rewindGit (git HEAD must be detached)
6. buildApp (already described above)
7. runLocalApp (already described above)
8. checkLocalApp (already described above)
9. stopLocalApp (already described above)
10. createDockerfile (already described above)
11. deleteDockerContainers (already described above)
12. deleteDockerImages(already described above)
13. buildDockerImage (already described above)
14. runLocalDocker (already described above)
15. checkLocalApp (already described above)
16. deleteDockerContainers (already described above)
17. pushDockerImage (already described above)
18. deleteDockerImages (already described above)
19. initEbEnv (already described above)
20. deployEbApp(already described above)
21. checkEbApp (already described above)
22. sendEmail (already described above)

CD with  AWS Elastic Beanstalk table of contents