{"id":14565,"date":"2014-07-03T11:50:41","date_gmt":"2014-07-03T06:20:41","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=14565"},"modified":"2015-09-17T16:47:59","modified_gmt":"2015-09-17T11:17:59","slug":"using-custom-chef-recipes-in-aws-opsworks","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/using-custom-chef-recipes-in-aws-opsworks\/","title":{"rendered":"Using Custom Chef Recipes in AWS OpsWorks"},"content":{"rendered":"<p style=\"text-align: justify;\">AWS OpsWorks is an application management service that makes it easy to deploy and operate applications of all shapes and sizes. You can define the application\u2019s architecture and the specification of each component including package installation, software configuration and resources such as storage. Start from templates for common technologies like application servers and databases or build your own to perform any task that can be scripted. <a title=\"AWS DevOps\" href=\"http:\/\/www.tothenew.com\/devops-aws\">AWS OpsWorks<\/a> includes automation to scale your application based on time or load and dynamic configuration to orchestrate changes as your environment scales.<\/p>\n<p>In this article We are going to install a web server (httpd) and deploying a simple static website having index.html page using <a title=\"Chef DevOps on AWS\" href=\"http:\/\/www.tothenew.com\/devops-chef-puppet-docker\">chef recipes in AWS OpsWorks<\/a>.<\/p>\n<p><strong>Go to AWS Services console and click on Opsworks.<\/strong><\/p>\n<p>Click on \u201cAdd Your First Stack\u201d<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14566\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/1.png\" alt=\"1\" width=\"943\" height=\"603\" \/><\/a><\/p>\n<p>2. Name your Stack say \u201cTest Stack\u201d<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14567\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/2.png\" alt=\"2\" width=\"1248\" height=\"610\" \/><\/a><\/p>\n<p>3. In the Configuration Management Section make \u201cUse custom Chef cookbooks\u201d to \u201cYes\u201d<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/31.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14586\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/31.png\" alt=\"3\" width=\"1036\" height=\"599\" \/><\/a><\/p>\n<p>In this scenario we have uploaded our cookbooks to S3, Hence Select Repository type to S3 Archive.<\/p>\n<p>Paste the S3 Repository URL.<\/p>\n<p>Enter your Access Key ID and Secret Access Key.<\/p>\n<p>Note : Before uploading to S3 make sure your cookbooks should be in <strong>mycookbooks<\/strong> directory even if it is a single cookbook.<\/p>\n<p>To know how chef works and how we can write chef cookbook&#8217;s recipes , you can read this article \u201c<a href=\"http:\/\/www.tothenew.com\/blog\/understanding-chef-and-writing-cookbooks\/\" target=\"_blank\">Understanding Chef and Writing Cookbooks<\/a>\u201d<\/p>\n<p>4. Now Add a Layer<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/4.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14569\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/4.png\" alt=\"4\" width=\"1060\" height=\"369\" \/><\/a><\/p>\n<p>5. Named it e.g mycustomLayer and short name &#8211; clayer<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/5.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14570\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/5.png\" alt=\"5\" width=\"1039\" height=\"437\" \/><\/a><\/p>\n<p>6. As we have specified cookbook repository in Stack creation , In the Layer we will specify the custom Chef Recipe to be executed . So in the Layers Section click on Recipes and specify Recipes as below .<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/6.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14571\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/6.png\" alt=\"6\" width=\"993\" height=\"329\" \/><\/a><\/p>\n<p>7. We can see the S3 Repository URL . So in this scenario our Chef Recipe will do installation of Web<\/p>\n<p>Server(httpd) and will copy some file(s) to \/var\/www\/html\/ (say index.html ). My Cookbook name is test_plat_indep and recipe is default. Hence I&#8217;ll follow the format specified and will write as test_plat_indep::default, test_plat_indep<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/7.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14572\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/7.png\" alt=\"7\" width=\"1092\" height=\"511\" \/><\/a><\/p>\n<p>8. Now whatever instance we launch in this Layer will acquire the Layer Properties. e.g. if we launch t1.micro instance in this Layer (myCustomLayer) , httpd server will be installed on this instance and files will be copied to \/var\/www\/html\/ directory .<\/p>\n<p>Now Click on Add an instance :<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/8.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14573\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/8.png\" alt=\"8\" width=\"1042\" height=\"353\" \/><\/a><\/p>\n<p>9. Named it as clayer1 (You can give name as per your ease.)<\/p>\n<p>Give size , subnet , scaling, ssh_key, etc.. and add it to Layer .<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/9.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14574\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/9.png\" alt=\"9\" width=\"964\" height=\"562\" \/><\/a><\/p>\n<p>10. After adding it , start it by clicking on start option.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/10.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14575\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/10.png\" alt=\"10\" width=\"966\" height=\"443\" \/><\/a><\/p>\n<p>11. It will take time as first it will be requested, then it will boot, running setup and finally it will become Online.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/11.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14576\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/11.png\" alt=\"11\" width=\"1023\" height=\"370\" \/><\/a><\/p>\n<p>Note : if any of operation fails , it will give Error. You can check Logs for error details.<\/p>\n<p>12. Below you can see that it has become Online.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/12.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14577\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/12.png\" alt=\"12\" width=\"1026\" height=\"508\" \/><\/a><\/p>\n<p>13. Just take the Public Ip address its showing, copy it and paste it to Browser &#8216;s Address Bar like below.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/131.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-14578\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/07\/131.png\" alt=\"13\" width=\"950\" height=\"392\" \/><\/a><\/p>\n<p>Yes ! Web Server (httpd) has been installed and index.html has been copied to \/var\/www\/html\/<\/p>\n<p>You can see the Website.<\/p>\n<hr \/>\n<p>Ishant Kumar<br \/>\n<a href=\"http:\/\/aws.amazon.com\/certification\/certification-levels\/certified-solutions-architect-associate\/\" target=\"_blank\" rel=\"nofollow\">AWS Certified Solution Architect \u2013 Associate<\/a><br \/>\nAWS Administrator @ Intelligrape<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AWS OpsWorks is an application management service that makes it easy to deploy and operate applications of all shapes and sizes. You can define the application\u2019s architecture and the specification of each component including package installation, software configuration and resources such as storage. Start from templates for common technologies like application servers and databases or [&hellip;]<\/p>\n","protected":false},"author":125,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":3},"categories":[1174,2348],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/14565"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/125"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=14565"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/14565\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=14565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=14565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=14565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}