{"id":15860,"date":"2014-10-27T15:23:40","date_gmt":"2014-10-27T09:53:40","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=15860"},"modified":"2014-10-27T15:57:57","modified_gmt":"2014-10-27T10:27:57","slug":"elb-logs-on-s3-bucket","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/elb-logs-on-s3-bucket\/","title":{"rendered":"ELB Logs on S3 Bucket"},"content":{"rendered":"<p>Today we&#8217;ll be implementing an S3 bucket policy for storing multiple Elastic Load Balancer access logs on a single S3 bucket.<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb3.png\"><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb3-300x279.png\" alt=\"elb3\" width=\"300\" height=\"279\" class=\"alignnone size-medium wp-image-15865\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb3-300x279.png 300w, \/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb3.png 459w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Instead of having multiple S3 bucket for each ELB access logs, we&#8217;ll create only one S3 bucket for storing all ELB&#8217;s access logs.<\/p>\n<p>This section walks you through the step by step guide for configuring S3 bucket for storing ELB logs.<\/p>\n<p><strong>Step1: Create S3 bucket<br \/>\nStep2: Attach a bucket policy to the S3 Bucket<br \/>\nStep3: Enable Access logs at the ELB<br \/>\n<\/strong><\/p>\n<h3 style=\"text-align: justify;color: #ff9900\">Step1: Create S3 bucket: <\/h3>\n<p><\/p>\n<p>Let&#8217;s create an S3 bucket for storing our ELB logs.<br \/>\n<strong>S3 bucket:<\/strong> com.domainame.com.elb.logs<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb1.png\"><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb1-300x93.png\" alt=\"elb1\" width=\"400\" height=\"93\" class=\"alignnone size-medium\" \/><\/p>\n<p>Let&#8217;s create few folder inside our S3 bucket. e.g. myapp1, myapp2, myapp3 for storing respective elb access logs.<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\"> Step2: Attach a bucket policy to the S3 bucket.<\/h3>\n<p><\/p>\n<p>You can use below bucket policy for this purpose. You have to change certain parameters on this policy like &#8220;account number, bucket name , folder name&#8221; as per your setup.<\/p>\n<p>[js]<br \/>\n{<br \/>\n&quot;Version&quot;: &quot;2008-10-17&quot;,<br \/>\n&quot;Id&quot;: &quot;Policy1413182823222&quot;,<br \/>\n&quot;Statement&quot;: [<br \/>\n     {<br \/>\n      &quot;Sid&quot;: &quot;Stmt1413182819426&quot;,<br \/>\n      &quot;Effect&quot;: &quot;Allow&quot;,<br \/>\n      &quot;Principal&quot;: {<br \/>\n      &quot;AWS&quot;: &quot;arn:aws:iam::ELB-REGION-ID:root&quot;<br \/>\n    },<br \/>\n &quot;Action&quot;: &quot;s3:PutObject&quot;,<br \/>\n &quot;Resource&quot;: [<br \/>\n     &quot;arn:aws:s3:::com.domainname.com.elb.logs\/myapp1\/AWSLogs\/XXXXXXXXXXXX\/*&quot;,<br \/>\n     &quot;arn:aws:s3:::com.domainname.com.elb.logs\/myapp2\/AWSLogs\/XXXXXXXXXXXX\/*&quot;,<br \/>\n     &quot;arn:aws:s3:::com.domainname.com.elb.logs\/myapp3\/AWSLogs\/XXXXXXXXXXXX\/*&quot;,<br \/>\n    ]<br \/>\n   }<br \/>\n ]<br \/>\n}<br \/>\n[\/js]<br \/>\n&#8211;&gt; In place of ELB-REGION-ID, you have to use  &#8216;127311923021&#8217; if your ELB is in North Virginia and &#8216;156460612806&#8217; if your ELB is in EU (Ireland). For a complete list of ELB REGION ID you can follow this link &#8220;<a href=\"http:\/\/docs.aws.amazon.com\/ElasticLoadBalancing\/latest\/DeveloperGuide\/configure-s3-bucket.html\">http:\/\/docs.aws.amazon.com\/ElasticLoadBalancing\/latest\/DeveloperGuide\/configure-s3-bucket.html<\/a>&#8221;<\/p>\n<p>&#8211;&gt; In Resource section above , You have to use below format <\/p>\n<p>   [js] arn:aws:s3:::yourS3bucketname\/prefix\/AWSLogs\/yourAWSAccountID\/* [\/js]<\/p>\n<p>like we did<br \/>\n<strong>yourS3bucketname:<\/strong> &#8220;com.domainname.com.elb.logs&#8221;<br \/>\n<strong>prefix:<\/strong> &#8220;myapp1&#8221;<br \/>\n<strong>AWSlogs:<\/strong> &#8220;leave it as it is&#8221;<br \/>\n<strong>yourAWSAccountID:<\/strong> &#8220;your 12 digit AWS Account Number&#8221;<\/p>\n<p>Similarly you can define multiple prefix for multiple application.<\/p>\n<h3 style=\"text-align: justify;color: #ff9900\">Step3: Enable Access logs at the ELB <\/h3>\n<p><\/p>\n<p>Log In to EC2 Section -&gt; Browse to Load Balancers -&gt; Click on any load Balancer -&gt; Enable Access log [Edit],<br \/>\nThis will ask you for your S3 Bucket location with prefix. <\/p>\n<p>Give the path of S3 bucket. &#8220;com.domainname.com.elb.logs\/myapp1&#8221;<\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb5.png\"><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb5-300x27.png\" alt=\"elb5\" width=\"500\" height=\"27\" class=\"alignnone size-medium\" \/><\/p>\n<p><a href=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb6.png\"><img decoding=\"async\" loading=\"lazy\" src=\"\/blog\/wp-ttn-blog\/uploads\/2014\/10\/elb6-300x163.png\" alt=\"elb6\" width=\"500\" height=\"163\" class=\"alignnone size-medium\" \/><\/p>\n<p>Similarly for another ELB you can enable access log and use myapp2 folder.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we&#8217;ll be implementing an S3 bucket policy for storing multiple Elastic Load Balancer access logs on a single S3 bucket. Instead of having multiple S3 bucket for each ELB access logs, we&#8217;ll create only one S3 bucket for storing all ELB&#8217;s access logs. This section walks you through the step by step guide for [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":30},"categories":[1174],"tags":[1462,528,670],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15860"}],"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\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=15860"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15860\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=15860"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=15860"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=15860"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}