CD with AWS Elastic Beanstalk: Code principles and tips

There’re some general ideas in all scripts, so let’s overview ’em:

1. Add comments to every important action:

Screenshot at Mar 04 12-52-16

 

2. Use variables instead of hardcoding:

Screenshot at Mar 04 12-54-25

 

3. If you need small files with variables from main script, create ’em from the main script:

Screenshot at Mar 04 12-56-19

 

4. Use functions to make the script structured:

Screenshot at Mar 04 12-57-47

 

5. Use the same structure for simple and complex functions:

Screenshot at Mar 04 12-59-39

 

6. Measure functions execution time:

Screenshot at Mar 04 13-00-47

Screenshot at Mar 04 13-02-25

 

7. If function fails, stop errors spread:

Screenshot at Mar 04 13-04-09

 

8. Use main log to store important results:

Screenshot at Mar 04 13-05-57

 

… and use temporary log for small checks:

Screenshot at Mar 04 13-08-41

 

9. Send important logs to email:

Screenshot at Mar 04 13-10-53

 

10. Delete old stuff instead of replacement:

Screenshot at Mar 04 13-13-43

 

11. Test every important step:

Screenshot at Mar 04 13-14-42

 

12. Give it some time to start before checking:

Screenshot at Mar 04 13-15-56

 

13. Don’t forget to check twice:

Screenshot at Mar 04 13-17-13

 

14. Don’t give up – force it:

Screenshot at Mar 04 13-18-42

 

15. Cleanup after yourself:

Screenshot at Mar 04 13-20-19

 

CD with  AWS Elastic Beanstalk table of contents