<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Omid Vahdaty on Medium]]></title>
        <description><![CDATA[Stories by Omid Vahdaty on Medium]]></description>
        <link>https://medium.com/@omidvd?source=rss-7d5da0103dfb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5H7ObNKtRlP68waU.</url>
            <title>Stories by Omid Vahdaty on Medium</title>
            <link>https://medium.com/@omidvd?source=rss-7d5da0103dfb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 01:54:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@omidvd/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Hulk Buster (LEGO) Experience — Some Insights]]></title>
            <link>https://medium.com/@omidvd/the-hulk-buster-lego-experience-some-insights-5acb9bb8e972?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/5acb9bb8e972</guid>
            <category><![CDATA[game-design]]></category>
            <category><![CDATA[lego]]></category>
            <category><![CDATA[parents-kids-time]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Sat, 01 Apr 2023 23:45:59 GMT</pubDate>
            <atom:updated>2023-04-03T01:11:25.269Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Hulk Buster (LEGO) Experience — Some Insights</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19BGVRYA-TSYklNPEq-bvA.png" /></figure><h3>Abstract</h3><p>I recently bought the <a href="https://www.lego.com/en-us/product/hulkbuster-76210">LEGO Hulk Buster,</a> for my kids to build and started building it together with them. I wanted to share with you the experience both as a father and an engineer.</p><h3>Background</h3><p>My name is Omid Vahdaty, am 43 years old highly introvert persona, married with 2 kids at the age of nine and ten. I have been working a 80 hours week job for the last 25 years. To me, family and work life balance would time was always a challenge, However the true challenge was not finding the time, whereas finding ways to connect with my kids.</p><p>Be that as it may, I never stopped looking for ways to connect with my kids so when I do spend time with them it will be will be a memory for us to hold dear and hopefully and the experience will embolden them as it did me for generations to come.</p><p>After years of searching for ideas and innovative ways to have fun and connect, the insight was simple. Simply being by their side, and finding things you all enjoy doing made the differences.</p><blockquote>For example, watching cartoons and <strong>super hero</strong> movies together via Netflix, we made into movie night with popcorn. Come hell or high water every week, we would take an hour watching shows together and talk about the scene. Even when when I was abroad on business trips, we would open a zoom session and watch together. <strong>It was our thing.</strong></blockquote><h3>So why choose LEGO to spend guilty time with todays kids where all they care about is their tablet?</h3><p>Up until today, I remember quite strongly the hours spend building LEGO products as a 6 year old child. More importantly, The time and effort my dad put to sit with me, and teach me how to work with technical lego products.</p><p>The second reason, was by darn lack. As a family we went to a toy store, and saw the LEGO tumbler 76240, and some other LEGO models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-nVHLMmIUNElhtwgh4KTKw.png" /></figure><p>What caught our attentions, was the super hero theme, and the complexity of building this products. The product mentioned it was designed for age 18+ “kids” and contains 2040 pieces. Naturally, we didn&#39;t buy it at the time, Simply because my kids were nine and ten year old. We estimated we wont be able build it as a family and it would take weeks so the kinds would lose patience, and I would end up building a very expensive LEGO toy by my self :)</p><blockquote><strong>We were quite wrong…</strong></blockquote><p>A year passed, and we kept talking(!) about that insane LEGO product and we started discussing ways to train and work our way up all on via smaller LEGO challenges (500, 1000, 2000 pieces) to get to that desired LEGO products.</p><p>By chance, my bussines trip last week was to the US, and came a cross a LEGO store. Naturally, I went in to see whats new. I came a cross the several interesting LEGO products</p><ol><li><strong>Batman Batmobile Thumler</strong> : <a href="https://www.lego.com/en-us/product/lego-dc-batman-batmobile-tumbler-76240">https://www.lego.com/en-us/product/lego-dc-batman-batmobile-tumbler-76240</a></li><li><strong>Hulk Buster</strong> : <a href="https://www.lego.com/en-us/product/hulkbuster-76210">https://www.lego.com/en-us/product/hulkbuster-76210</a></li><li><strong>Black Panther</strong>: <a href="https://www.lego.com/en-us/product/black-panther-76215">https://www.lego.com/en-us/product/black-panther-76215</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JLlYlPfVVz6GF99uFl8WTA.png" /></figure><p>The fact that the LEGO product clearly marks that it was designed for ages for 18+ concerned me so I wanted to ask around about this. Talking to this nice LEGO expert there, she explained the, few interesting facts which made the purchase quite easy:</p><ol><li>One is the obvious choking hazard. so pay attetion.</li><li>Seconds, she explained the <strong>instructions are not step by step inside the box</strong>, but rather assume some kind of experiences in understand LEGO schematics, and I could use the <a href="https://play.google.com/store/apps/details?id=com.lego.legobuildinginstructions&amp;hl=en&amp;gl=US"><strong>LEGO builder</strong></a><strong> Android App to have step by step instructions</strong>.</li><li>Thirdly, some of the parts are smaller, <strong>making it a challenge for small kids to connects, hense the adult supervision.</strong></li></ol><blockquote>The amount of parts, implies about week worth of work, However, the packaging was built in such a way, One could divide the work to about ±20 play sessions. As each play session is clearly marked by a numbered plastic bug contains only the relevant pieces for this play session. The entire complexity of building the product becomes as easy as building 20 different LEGO products of 200 pieces!</blockquote><p>From there it was simply a matter of choosing the right LEGO theme for us. Naturally I consulted with my kids, the eldest mentioned, she unlikely to build a “Boys” LEGO, and youngest, was so excited he could not think straight and he left the decision to me…</p><h3>Choosing the right LEGO Product for your kids</h3><p>Knowing I had to choose between three super hero theme lego made my life easy, simply because I compared, price, amount of pieces, complexity, colors, size of product upon completion. and here is how I finally decided:</p><ol><li><strong>Complexity of building for kids</strong>: all Family experience, one adult 2 kids, is totally adequate.</li><li>the <strong>Playability</strong> with the product AFTER it was built. as the black panther hardly has moving parts, and tumbler wheels only move back and forward like a 2 year old cars and some minor door opening. The Hulk buster has some joints the kinds, can move and shape it to any position they like.</li><li>the correct theme is <strong>EVERYTHING</strong>, in attempt to intrigue my Eldest I got her a 360 pieces LEGO product that builds into a flower and some chicken. This brought her sit with us while we build the Hulk buster. and stayed with us for the entire 20 play sessions.</li><li><strong>The amount of time I want to spend with my kids.</strong> Here is my timing formulla based on experience of building the Hulk Buster with my kids. The Packages contains 4049 pieces, divided into ±20 plastic bags, of ±200 pieces and each is clearly marked by the step number (1 to 20). each plastic bag took us about 2 hours. <strong>totalying in about 40 hours for the Hulk Buster.</strong></li></ol><h3>Some product remarks for “<strong>must know it all before</strong>” fathers like me</h3><ol><li>pay special attention to the <strong>unboxing process</strong>, keep the plastic bugs marker with the step number, in case your child gets tired mid play session, so you would be able to continue next week, while parts are safely secured and clearly marked.</li><li>Download the <strong>LEGO builder app</strong>, even though there is printed version inside, todays needs need some sort of technology reference to make the experiences more interesting, and above all, they can zoom in/out so you can show them how to validate the completion of complicated steps.</li><li>You can play in parallel with several kids, be prepared to manage the process for the them, as some play session including waiting for the previous plays session to be over so they can be connected. :)</li><li>Be prepared to loose parts, even if you don’t complete the product, focus ±40 hours quality time with your kids.</li><li>While building, Ignore the expensive pricing, focus ±40 hours quality time with your kids.</li></ol><h3>Some remarks for the LEGO designers of hulk buster</h3><ol><li>Please DO NOT have more than one plastic bug, with the same number, it was quite confusing in the unboxing process.</li><li>Please consider for such complex products, to have built in trays which are reusable, or even closed reusable box instead of plastic bags, this will double the quality time, if you consider the way back: i.e disassemble such a complex product, and putting it back to the box. and building it in another time.</li><li>Please consider more safe guards, to straighter the connection so the parts, as the product easily disconnects.</li><li>In 2023, I would expect a lot more technological features in a product that cost as much as a new Apple Iphone. For example, augmented reality app, once the product is built, the child and uses the app to “Animate” the static posture of hulk buster. Further more, and VR like experiences of of putting the bricks together or at least rotating the image in the app, instead of a borring old school static image.</li></ol><h3>Summary</h3><ol><li>I really enjoyed the quality time with my kids, it was a true pleasure. I believe the LEGO user experiences is instrumental in todays post covid-19 world, where the only common options to play for kids is a tablet / TV screen.</li><li>The LEGO price tag is a bit too much, it always has been. It is a shame because most families wont be able to afford more than one product in the 600$ price range. A decent tablet cost 600$, and last for about 3 years, with thousands of hours of endless fun and educational options. In today’s world it simply make LEGO a “rich” kids experiences. So I would expect the number three ranked brand in the world, to find ways to make the LEGO experiences more accessible to less unfortunately families for the very least reusable.</li><li>LEGO has helped shaped me to the builder/engineer I am today, and I am grateful to have been profoundly been impacted by the LEGO experience. I was thinking of disassembling the product back to its original state, and donate it back to more unfortunate families, so their families would enjoy as we did. wish me luck :)</li></ol><p>Hope this blog helped anyone,</p><p>Thanks</p><p>Omid Vahdaty</p><p>P.S feel free to add me in linked in and talk :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5acb9bb8e972" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Airflow file sensor example | Airflow Demystified]]></title>
            <link>https://medium.com/@omidvd/airflow-file-sensor-example-airflow-demystified-50584bca1628?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/50584bca1628</guid>
            <category><![CDATA[example-prayer]]></category>
            <category><![CDATA[airflow-classifier]]></category>
            <category><![CDATA[file-sensor]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 16:23:54 GMT</pubDate>
            <atom:updated>2020-04-15T16:23:54.462Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently encountered an ETL job, where the DAG worked perfectly and ended in success, however the underlying resources did not behave as I expected. i.e one of the task was expected to run and external python script. The scripted ended with success, which in turn forced Airflow DAG to report success. However, the python was suppose to create a file in GCS and it didn’t.</p><p>I Looked for a solution for this. As it turns out, Airflow Sensor are here to help. Airflow sensor, “sense” if the file exists or not. the operator has some basic configuration like path and timeout. The trick is to understand it is looking for one file and what is the correct the file is found or alternatively not found.</p><p>For the full article working <a href="https://big-data-demystified.ninja/2019/11/14/airflow-file-sensor-example-airflow-demystified/">Airflow file sensor example</a>, press on the link.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50584bca1628" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Airflow XCom examples | Airflow demystified]]></title>
            <link>https://medium.com/@omidvd/airflow-xcom-examples-airflow-demystified-1299de7f2585?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/1299de7f2585</guid>
            <category><![CDATA[xcom]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[example]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 16:19:20 GMT</pubDate>
            <atom:updated>2020-04-15T16:19:20.403Z</atom:updated>
            <content:encoded><![CDATA[<p>Getting started on Airflow Xcom | 5 Examples</p><p>Getting started on Airflow XCom is non trivial, So I put some links to post examples, and put all the use case I have personally tested here. I have published several examples here:</p><ol><li>Basic push/pull example based on official example</li><li>AirPush and pull same ID from several operator</li><li>Push and pull from other Airflow Operator than pythonOperator</li><li>Push return code from bash operator to XCom</li><li>Pull between different DAGS</li></ol><p>For the full article, and <a href="https://big-data-demystified.ninja/2020/04/15/airflow-xcoms-example-airflow-demystified/">working Airflow XCOM example</a>s, press this link.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1299de7f2585" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[80% Cost Reduction in Google Cloud BigQuery | Tips and Tricks | Big Query Demystified]]></title>
            <link>https://medium.com/@omidvd/80-cost-reduction-in-google-cloud-bigquery-tips-and-tricks-big-query-demystified-aa59c9da63f9?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa59c9da63f9</guid>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[telecom-cost-reduction]]></category>
            <category><![CDATA[bigquery]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Wed, 06 Nov 2019 15:49:38 GMT</pubDate>
            <atom:updated>2019-11-12T10:16:49.202Z</atom:updated>
            <content:encoded><![CDATA[<p>1. Install <a href="https://chrome.google.com/webstore/detail/bigquery-mate/nepgdloeceldecnoaaegljlichnfognh">BQ mate</a> — plugin for chrome in order to see cost per query in dollars <strong>before</strong> running. Key challenge in your organization team’s will be to bare cost in mine while working.</p><p>2. Log in to your <a href="https://bigquery.cloud.google.com/">BigQuery console</a> to get started. However, you might want to consider using <a href="https://web.superquery.io/">superQuery</a> IDE for more advanced features over BigQuery, Increased productivity and cost reduction. We use it in Investing.com</p><p>3. Run sample query , ALWAYS use a date in the where clause. Assuming the table is partitioned, this will save you costs by only scanning the relevant data as oppose to the entire table.</p><p>select * from</p><p>where date = &#39;2019-11-01&#39;</p><p>4.<strong> AS rule of thumb, NEVER DO</strong> the below:</p><p>select * from t</p><p>or</p><p>select * from t limit 100</p><p>as this will incur unintended full scans of table data and thus create huge billing costs. Instead, use:</p><p>Select ColName1, ColName2 from T</p><p>and <a href="https://cloud.google.com/bigquery/docs/best-practices-costs#preview-data">Preview table</a> instead of LIMIT</p><p><strong>5. As a rule of thumb , ALWAYS </strong>:</p><p>If you are running a query which costs more than 1$ — <em>you are most probably doing something wrong.</em></p><p>6. Learn Bigquery in great details. I have prepared a presentation with over 100 slides called it <a href="https://big-data-demystified.ninja/2019/07/21/google-bigquery-demystified/">BigQuery Demystified</a>. Learning BigQuery features will help optimize queries, and thus save costs. For example: did u know import/export from bigQuery is completely FREE! Another example is how to query nested data, and windows function.</p><p>7. Analize <a href="https://big-data-demystified.ninja/2019/09/19/bigquery-cost-per-query-per-user/">cost per query per user in big query</a> periodically.</p><h4><a href="https://big-data-demystified.ninja/2019/10/27/80-cost-reduction-in-google-cloud-bigquery-tips-and-tricks-big-query-demystified/"><strong>8. For the full article (slides and Video) of 80% cost reduction on GCP</strong></a></h4><p>If you like my tips, or have any opinion whatsoever, please contact me via <a href="https://www.linkedin.com/in/omid-vahdaty/">linkedin</a>.</p><p>To learn more about Superquery:</p><p><a href="https://web.superquery.io/?camp=BDD">https://web.superquery.io/?camp=BDD</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa59c9da63f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big Query Demystified |what really happens when you unnest customDimentions in ga_sessions_* (hint…]]></title>
            <link>https://medium.com/@omidvd/big-query-demystified-what-really-happens-when-you-unnest-customdimentions-in-ga-sessions-hint-b6b7d4d3d9d0?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6b7d4d3d9d0</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[ga360]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Sat, 19 Jan 2019 15:24:05 GMT</pubDate>
            <atom:updated>2019-01-19T15:25:25.793Z</atom:updated>
            <content:encoded><![CDATA[<h3>Big Query Demystified |what really happens when you unnest customDimentions in ga_sessions_* (hint data inaccuracy)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*Uv4QBqwwHO600Hza4ux58g.png" /></figure><p>I wanted to share with a problem i found while working in BigQuery and google analytics 360 data: ga_sessions_*</p><p>The following query</p><blockquote><em>select count(distinct fullvisitorid) as users,<br>count(distinct CONCAT(cast(visitid as string) ,fullVisitorID )) as number_of_sessions,<br>DATE_TRUNC(parse_DATE(‘%Y%m%d’,date),month) AS month_year<br>from `myProject.ga_sessions_*` t, t.hits h , h.customDimensions as hcd<br>where (_TABLE_SUFFIX BETWEEN ‘20181231’ and ‘20181231’)<br>and not (device.operatingSystem = ‘(not set)’<br>AND totals.screenviews = 0)<br>group by 3</em></blockquote><p>returns <strong>1724266</strong> distinct fullvisitorid rows.</p><p>when use the same query only remove the “, h.customDimensions as hcd” from the FROM section :</p><blockquote><em>select count(distinct fullvisitorid) as users,<br>count(distinct CONCAT(cast(visitid as string) ,fullVisitorID )) as number_of_sessions,<br>DATE_TRUNC(parse_DATE(‘%Y%m%d’,date),month) AS month_year<br>from `myProject.ga_sessions_*` t, t.hits h<br>where (_TABLE_SUFFIX BETWEEN ‘20181231’ and ‘20181231’)<br>and not (device.operatingSystem = ‘(not set)’<br>AND totals.screenviews = 0)<br>group by 3</em></blockquote><p>i get <strong>1754580</strong> distinct fullvisitorid rows.</p><h3>What is the reason unnset of a custom dimension causes this distinct values difference?</h3><h3>what happens when i do select * from a,b,c in bigQuery?</h3><p>As you probably know when you add “, something” to the FROM clause you are doing a <strong>CROSS JOIN</strong> between the first element and the recently added. For example:</p><blockquote><em>select * FROM table tablename as a, table tablename2 as b</em></blockquote><p>This will perform a cross join between the tables tablename and tablename2.</p><p>Then, when you do a <strong>CROSS JOIN with null value</strong>s, this rows will be <strong>suppressed</strong>.<br>Let me show you an example:</p><blockquote><em>#standardSQL<br>WITH<br>data AS (<br>(SELECT<br>“primes under 15” AS description,<br>[1, 3, 5, 7, 11, 13] AS primes_array)<br>UNION ALL<br>SELECT<br>“primes under 16” AS description,<br>[2] AS primes_array)</em></blockquote><blockquote><em>SELECT<br>description, prime<br>FROM<br>data<br>CROSS JOIN<br>UNNEST (primes_array) AS prime</em></blockquote><p>This query returns 7 rows, however the next one returns only 6:</p><blockquote><em>#standardSQL<br>WITH<br>data AS (<br>(SELECT<br>“primes under 15” AS description,<br>[1, 3, 5, 7, 11, 13] AS primes_array)<br>UNION ALL<br>SELECT<br>“primes under 16” AS description,<br>[ ] AS primes_array)</em></blockquote><blockquote><em>SELECT<br>description, prime<br>FROM<br>data<br>CROSS JOIN<br>UNNEST (primes_array) AS prime</em></blockquote><p>As you can see the only difference is in the line “[2] AS primes_array” which changes to a <strong>null</strong> value, “[ ] AS primes_array”. Then, this data is discarded with the CROSS JOIN, so when you do the query make sense that you see a difference in the results if there’s any NULL value within that “customDimensions”.</p><p>Credit for finding the problem: Evyatar Aviram</p><ul><li><a href="https://www.linkedin.com/in/omid-vahdaty?trk=nav_responsive_tab_profile">Omid Vahdaty</a></li><li>+972–54–2384178</li></ul><p>Want more big data quality content? Join our meetup, subscribe to youtube channels</p><ul><li><a href="https://www.meetup.com/AWS-Big-Data-Demystified/">https://www.meetup.com/AWS-Big-Data-Demystified/</a></li><li><a href="https://www.meetup.com/Big-Data-Demystified/">https://www.meetup.com/Big-Data-Demystified/</a></li><li><a href="https://www.youtube.com/channel/UCMSdNB0fGmX5dXI7S7Y_LFA?view_as=subscriber">Big Data Demystified YouTube</a></li><li><a href="https://www.youtube.com/channel/UCzeGqhZIWU-hIDczWa8GtgQ?view_as=subscriber">AWS Big Data Demystified YouTube</a></li><li><a href="https://big-data-demystified.ninja/">https://big-data-demystified.ninja/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6b7d4d3d9d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big Data Demystified | Using AI to optimize BigQuery]]></title>
            <link>https://medium.com/@omidvd/big-data-demystified-using-ai-to-optimize-bigquery-133b2e345df7?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/133b2e345df7</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[superquery]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 16:01:22 GMT</pubDate>
            <atom:updated>2019-01-19T15:30:53.801Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2Fo53nsxpF0DKBrH&amp;url=https%3A%2F%2Fwww.slideshare.net%2FIdoVolff%2Fmeetup-google-bigquery-powered-by-ai%3Fref%3Dhttps%3A%2F%2Famazonwebservicesbigdatademystified.wordpress.com%2F2019%2F01%2F10%2Fbig-data-demystified-using-ai-to-optimize-bigquery%2F%3Fframe-nonce%3Df0cd3147cf%26preview%3Dtrue%26iframe%3Dtrue%26revision%3D4%26calypso_token%3Ddd421eca-6c02-4b11-98e4-bcbf21e97213&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fmeetup-bigquerypoweredbyai-190114092342-thumbnail-4.jpg%3Fcb%3D1547457955&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/5415025930fd5b5b53d477959d231f8a/href">https://medium.com/media/5415025930fd5b5b53d477959d231f8a/href</a></iframe><p><a href="https://www.youtube.com/watch?time_continue=1&amp;v=cXq2tffYQ-A">https://www.youtube.com/watch?time_continue=1&amp;v=cXq2tffYQ-A</a></p><p>“Using AI to optimize BigQuery”</p><p>As we kick off 2019, one thing is certain: the “Serverless Revolution” has hit the mainstream. However, whereas a majority of serverless discussions tend to focus on its utility in software development, there is a parallel paradigm shift occurring in big data analytics.</p><p>With fully-managed data warehouses like Google BigQuery and Amazon Athena, users can start querying petabytes of data at unprecedented speed, paying only for the compute and storage used. Small startups to companies as large as Spotify and Home Depot are migrating to this new way of doing analytics every day.</p><p>However, it’s on-demand pricing can be a double-edged sword with data analysts and teams. Scan more data than is necessary, and your company will wind up with an expectedly large bill at the end of the month. Worst of all, with no real-time price transparency while querying, team’s don’t learn about this until it’s too late. As a result, companies set usage limits on their analysts.</p><p>This is not an efficient approach for data analytics services as powerful as BigQuery or Athena, as it sets a ceiling to an analyst’s potential contribution. The solution? SQL optimization.</p><p>Avi Zloof and Eben du Toit, CEO and Chief Data Scientist at superQuery, respectively, will discuss building ML models to optimize SQL queries and how that removes the need for any restrictions on data analysts.</p><p>Avi Zloof:<br>Avi has spent the past 20 years leading R&amp;D and innovation teams, managing big data and full stack development initiatives.<br>Prior to founding superQuery he worked for six years at TradAir leading cloud and big data projects. Big data tools he’s developed are being used by Tier-1 banks daily to trade and analyze billions in currencies.</p><p>Ido Vollf:</p><p>Ido is a serial entrepreneur who previously founded Sleeve (Edtech), EmbraceMe (IoT), and ChaChange (FinTech).<br>Ido worked as a Technical and Business Evangelist at Microsoft and was in charge of communicating the value of Microsoft Azure and Windows 10 to Israel’s startup ecosystem.<br>He’s an active mentor in the Israeli startup ecosystem, helping early stage startups grow fast.</p><p>Eben du Toit: Storyteller, data scientist, tech geek and computer engineer.</p><p>I’m a storyteller, data scientist, tech geek, computer engineer and control systems expert. My data skills were honed conceptualising, implementing and leading the efforts in building data science stacks. During my engineering career I’ve designed, coded, installed and tested full-stack large-scale IT engineering infrastructure projects at several power plants across South Africa and developed software for both mobile back-end platforms and power industry applications. I have over 14 years experience in engineering and grew up as a child of the internet. Currently chief data scientist at superQuery.</p><p>Want to learn more about big data ?</p><ul><li><a href="https://big-data-demystified.ninja/">https://big-data-demystified.ninja/</a></li><li>Join our meetup, subscribe to youtube channels</li><li><a href="https://www.meetup.com/AWS-Big-Data-Demystified/">https://www.meetup.com/AWS-Big-Data-Demystified/</a></li><li><a href="https://www.meetup.com/Big-Data-Demystified/">https://www.meetup.com/Big-Data-Demystified/</a></li><li><a href="https://www.youtube.com/channel/UCMSdNB0fGmX5dXI7S7Y_LFA?view_as=subscriber">Big Data Demystified YouTube</a></li><li><a href="https://www.youtube.com/channel/UCzeGqhZIWU-hIDczWa8GtgQ?view_as=subscriber">AWS Big Data Demystified YouTube</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=133b2e345df7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big Data Demystified | Data Engineering Demystified]]></title>
            <link>https://medium.com/@omidvd/big-data-demystified-data-engineering-demystified-4f000a72dfdc?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f000a72dfdc</guid>
            <category><![CDATA[demystified]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Thu, 10 Jan 2019 15:53:14 GMT</pubDate>
            <atom:updated>2019-01-10T15:55:00.826Z</atom:updated>
            <content:encoded><![CDATA[<p>Want to learn about Data Engineering? what is it? what are the challenges? Start with this teaser, and stay tuned for the next serias of lectures about Investing.com Journey to the Cloud.</p><p><a href="https://youtu.be/GD1gZURTCvo">https://youtu.be/GD1gZURTCvo</a></p><p>The Lecture slides in english:</p><p><a href="https://www.slideshare.net/OmidVahdaty/data-engineering-demystified">https://www.slideshare.net/OmidVahdaty/data-engineering-demystified</a></p><ul><li><a href="https://www.linkedin.com/in/omid-vahdaty?trk=nav_responsive_tab_profile">Omid Vahdaty</a></li><li>+972–54–2384178</li><li><a href="https://big-data-demystified.ninja/">https://big-data-demystified.ninja/</a></li><li>Join our meetup, subscribe to youtube channels</li><li><a href="https://www.meetup.com/AWS-Big-Data-Demystified/">https://www.meetup.com/AWS-Big-Data-Demystified/</a></li><li><a href="https://www.meetup.com/Big-Data-Demystified/">https://www.meetup.com/Big-Data-Demystified/</a></li><li><a href="https://www.youtube.com/channel/UCMSdNB0fGmX5dXI7S7Y_LFA?view_as=subscriber">Big Data Demystified YouTube</a></li><li><a href="https://www.youtube.com/channel/UCzeGqhZIWU-hIDczWa8GtgQ?view_as=subscriber">AWS Big Data Demystified YouTube</a></li><li><a href="https://chat.whatsapp.com/DUkbwSL27AUBr0JWbY0trm">WhatApp group</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f000a72dfdc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big Data Demystified]]></title>
            <link>https://medium.com/@omidvd/big-data-demystified-9e63bbca8c0b?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e63bbca8c0b</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[demystified]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Fri, 21 Dec 2018 12:59:34 GMT</pubDate>
            <atom:updated>2018-12-21T12:59:34.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*Uv4QBqwwHO600Hza4ux58g.png" /></figure><p>A while ago I entered the challenging world of Big Data. As an engineer, at first, I was not so impressed with this field. As time went by, I realized more and more, The technological challenges in this area are too great to master by one person. Just look at the picture in this articles, it only covers a small fraction of the technologies in the Big Data industry…</p><p>Consequently, I created a meetup detailing all the challenges of Big Data, especially in the world of cloud. I am using AWS &amp; GCP and Data Center infrastructure to answer the basic questions of anyone starting their way in the big data world.</p><p>how to transform data (TXT, CSV, TSV, JSON) into Parquet, ORC,AVRO which technology should we use to model the data ? EMR? Athena? Redshift? Spectrum? Glue? Spark? SparkSQL? GCS? Big Query? Data flow? Data Lab? tensor flow? how to handle streaming? how to manage costs? Performance tips? Security tip? Cloud best practices tips?</p><p>In this meetup we shall present lecturers working on several cloud vendors, various big data platforms such hadoop, Data warehourses , startups working on big data products. basically — if it is related to big data — this is THE meetup.</p><p>Some of our online materials (mixed content from several cloud vendor):</p><p>Website:</p><p><a href="https://big-data-demystified.ninja/">https://big-data-demystified.ninja</a> (under construction)</p><p>Meetups:</p><p><a href="https://www.meetup.com/Big-Data-Demystified">https://www.meetup.com/Big-Data-Demystified</a></p><p><a href="https://www.meetup.com/AWS-Big-Data-Demystified/">https://www.meetup.com/AWS-Big-Data-Demystified/</a></p><p>Youtube channel:</p><p><a href="https://www.youtube.com/channel/UCMSdNB0fGmX5dXI7S7Y_LFA?view_as=subscriber">https://www.youtube.com/channel/UCMSdNB0fGmX5dXI7S7Y_LFA?view_as=subscriber</a></p><p>Audience:</p><p>Data Engineers<br>Data Science<br>DevOps Engineers<br>Big Data Architects<br>Solution Architects<br>CTO<br>VP R&amp;D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e63bbca8c0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EMR and watchdog: service-nanny?]]></title>
            <link>https://medium.com/@omidvd/emr-and-watchdog-service-nanny-f73b43532f05?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f73b43532f05</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[nanny-service]]></category>
            <category><![CDATA[emr]]></category>
            <category><![CDATA[watch-dogs]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Sun, 02 Sep 2018 09:37:39 GMT</pubDate>
            <atom:updated>2018-09-02T09:37:39.322Z</atom:updated>
            <content:encoded><![CDATA[<p>Want to have a watchdog to start the service if it crashing for any reason?</p><p>There are many ways to solve this. Some of them are these. just for the record, the reason i needed it, is b/c i need to start the Spark Thrift service fore JDBC which crashes every-time there is an out of memory.</p><h2>Solution 1: Linux CRON</h2><p>Using the good old cron entry which executes a small script in every 5 min(easily customizable). This checks if this process is there. If not start this process. If you need this Thrift server to be started only in Master node then you can step to do that.You can use Script runner for running a custom script (which is stored in s3) [1]<br>Advantage of this is simple to code and maintain. Additionally is not dependent on a particular EMR version/service.</p><p>Example to create an EMR cluster with script runner step.</p><blockquote><em>aws emr create-cluster — name “Test cluster” –-release-label emr-5.16.0 — applications Name=Hive Name=Pig — use-default-roles — ec2-attributes KeyName=myKey — instance-type m4.large — instance-count 3 — steps Type=CUSTOM_JAR,Name=CustomJAR,ActionOnFailure=CONTINUE,Jar=s3://region.elasticmapreduce/libs/script-runner/script-runner.jar,Args=[“s3://mybucket/script-path/my_script.sh”]</em></blockquote><h2>Solution 2: service-nanny (Note: This is untested)</h2><p>This solution utilizes the service-nanny which is a service watchdog in all EMR cluster.<br>Create a service-nanny configuration (/etc/service-nanny/yourservice.conf) This conf file will have some basic info regarding the process. So you can create a conf file. Put this in s3. Download it via step. (If you only want to execute in Master node). Once the files are in place, then restart the service-nanny. You can start and stop service nanny using the command below :</p><blockquote><em>sudo /etc/init.d/service-nanny stop<br>sudo /etc/init.d/service-nanny start</em></blockquote><p>You can see some sample about service-nanny in this path /usr/lib/service-nanny/example. The possible disadvantage for this would be if EMR decided to remove service-nanny in some future release you may need to fall back to Solution 1.</p><p>Note: Solution 2 is untested. So please test it thoroughly before using this in production.</p><p>resources:<br>[1] <a href="https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hadoop-script.html">https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hadoop-script.html</a></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><ul><li>Contact me via linked in <a href="https://www.linkedin.com/in/omid-vahdaty?trk=nav_responsive_tab_profile">Omid Vahdaty</a></li><li>website: <a href="https://amazon-aws-big-data-demystified.ninja/">https://amazon-aws-big-data-demystified.ninja/</a></li><li>Join our meetup, FB group and youtube channel</li><li>Join our meetup : <a href="https://www.meetup.com/AWS-Big-Data-Demystified/">https://www.meetup.com/AWS-Big-Data-Demystified/</a></li><li>Join our facebook group <a href="https://www.facebook.com/groups/amazon.aws.big.data.demystified/">https://www.facebook.com/groups/amazon.aws.big.data.demystified/</a></li><li>subscribe to our youtube channel <a href="https://www.youtube.com/channel/UCzeGqhZIWU-hIDczWa8GtgQ?view_as=subscriber">https://www.youtube.com/channel/UCzeGqhZIWU-hIDczWa8GtgQ?view_as=subscriber</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f73b43532f05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bootstrapping EMR from 0900 to 1700 on each work day with AWS Cloud Formation and AWS Data…]]></title>
            <link>https://medium.com/@omidvd/bootstrapping-emr-from-0900-to-1700-on-each-work-day-with-aws-cloud-formation-and-aws-data-ed7190f1e55a?source=rss-7d5da0103dfb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed7190f1e55a</guid>
            <category><![CDATA[transient]]></category>
            <category><![CDATA[bootstrapping]]></category>
            <category><![CDATA[emr]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Omid Vahdaty]]></dc:creator>
            <pubDate>Fri, 17 Aug 2018 11:29:36 GMT</pubDate>
            <atom:updated>2018-08-17T11:29:36.510Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bootstrapping EMR from 0900 to 1700 on each work day with AWS Cloud Formation and AWS Data Pipelines</h3><p>This article covers some options to bootstrap a daily AWS EMR cluster to work continuously from 0900 in the morning to 17:00 , e.g office hours .</p><p>I will be showing two options:</p><ol><li>using data pipelines and AWS CMD</li><li>using Cloud Formation and EMR</li></ol><p>The Cluster will consist of:</p><ol><li>one master node on demand.</li><li>one data node, on demand, no autoscaling.</li><li>task group with auto scaling, using SPOT instances.</li><li>Applications: Spark, Hive, Presto, Ganglia and more.</li><li>One step action for my custom steps. this will include all my custom configurations such as glue connectors, maximise resource allocation etc.</li><li>One DNS xxx.myDomain.com that will forwarded to the masterNodePublicDNS. this is useful if you have actual employees using this cluster from 0900 to 17:00 , you want to be able to have a look and feel of “always on cluster” by letting them query xxx.myDomain.com instead of the AWS EMR masterDNS</li></ol><p><strong>important node</strong>: use use <a href="https://jsonformatter.curiousconcept.com/">https://jsonformatter.curiousconcept.com/</a> to reformat the below JSONS’s easily.</p><h2>Option 1: using AWS Data Pipelines to bootstrap AWS EMR</h2><ol><li>use data pipelines to lunch an EMR cluster, with task group, auto scaling, glue connectors, and maximize resources config for spark, you will need a cmd that would look like :</li></ol><blockquote><em>aws emr create-cluster — auto-scaling-role EMR_AutoScaling_DefaultRole — applications Name=Ganglia Name=Spark Name=Hive Name=Tez Name=Zeppelin Name=Oozie Name=Hue Name=Presto Name=Livy — ec2-attributes ‘{“KeyName”:”walla_omid”,”AdditionalSlaveSecurityGroups”:[“sg-a22c”],”InstanceProfile”:”sampleOmid53-EMRClusterinstanceProfile-U080RX3ACCZT”,”SubnetId”:”subnet-222&quot;,”EmrManagedSlaveSecurityGroup”:”sg-222&quot;,”EmrManagedMasterSecurityGroup”:”sg-22&quot;,”AdditionalMasterSecurityGroups”:[“sg-22”]}’ — service-role sampleOmid53-EMRClusterServiceRole-KWO13FMZNHF2 — release-label emr-5.13.0 — log-uri ‘s3n://aws-logs-12344-eu-west-1/elasticmapreduce/’ — steps ‘[{“Args”:[“s3://emr-bootstrap/MyBbootstrap-emr.sh”],”Type”:”CUSTOM_JAR”,”ActionOnFailure”:”CONTINUE”,”Jar”:”s3://eu-west-1.elasticmapreduce/libs/script-runner/script-runner.jar”,”Properties”:””,”Name”:”Custom JAR”}]’ — name ‘myEmrCluster’ — instance-groups ‘[{“InstanceCount”:1,”EbsConfiguration”:{“EbsBlockDeviceConfigs”:[{“VolumeSpecification”:{“SizeInGB”:32,”VolumeType”:”gp2&quot;},”VolumesPerInstance”:1}]},”InstanceGroupType”:”CORE”,”InstanceType”:”r4.xlarge”,”Name”:”Core”},{“InstanceCount”:1,”EbsConfiguration”:{“EbsBlockDeviceConfigs”:[{“VolumeSpecification”:{“SizeInGB”:32,”VolumeType”:”gp2&quot;},”VolumesPerInstance”:1}]},”InstanceGroupType”:”MASTER”,”InstanceType”:”r4.xlarge”,”Name”:”Master”},{“InstanceCount”:0,”BidPrice”:”15&quot;,”EbsConfiguration”:{“EbsBlockDeviceConfigs”:[{“VolumeSpecification”:{“SizeInGB”:50,”VolumeType”:”gp2&quot;},”VolumesPerInstance”:1}],”EbsOptimized”:true},”InstanceGroupType”:”TASK”,”InstanceType”:”r4.xlarge”,”Name”:”TaskSpotsNinja”}]’ — configurations ‘[{“Classification”:”hive-site”,”Properties”:{“hive.metastore.client.factory.class”:”com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”},”Configurations”:[]},{“Classification”:”spark”,”Properties”:{“maximizeResourceAllocation”:”true”},”Configurations”:[]},{“Classification”:”presto-connector-hive”,”Properties”:{“hive.metastore.glue.datacatalog.enabled”:”true”},”Configurations”:[]},{“Classification”:”spark-hive-site”,”Properties”:{“hive.metastore.client.factory.class”:”com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”},”Configurations”:[]}]’ — scale-down-behavior TERMINATE_AT_TASK_COMPLETION — region eu-west-1</em></blockquote><p>2.if your cluster already exists, use aws emr cli to list cluster</p><blockquote><em>aws emr list-clusters — active — output text | grep CLUSTERS</em></blockquote><p>3. given the cluster id from previous steps, use aws emr cli to describe cluster and confirm the tags are the tags of resources you need.</p><blockquote><em>aws emr describe-cluster — cluster-id j-1124HDDG47D1 — output text | grep TAGS</em></blockquote><p>4. from here, I am pretty sure, you proceed on your own and create a script, once you have all the ID’s u need.</p><h2>Option 1 Summery:</h2><ol><li>a fairly quick and simple way to manage clusters</li><li>you need to manage the ID’s and instance id’s on your on as input/ouput per each step of your workflow (create emr, task resources, assigning LB, assigning DNS etc)</li></ol><h2>Option 2: Using Cloud Formation to bootstrap EMR</h2><p>Another options would be to use cloud formation ,work hard to create the configuration JSON that tells the CF stack what to do, and the stack will take care of the stop/start of the correct resources.</p><p>once you have the JSON, you can schedule a lambda to start stack on the required time such as 0900 (cloud watch trigger). example of a lambda function to start a CF stack:</p><blockquote><em>def lambda_handler(event, context)</em></blockquote><blockquote><em># TODO implement</em></blockquote><blockquote><em>#return ‘Hello from Lambda’</em></blockquote><blockquote><em>client = boto3.client(‘cloudformation’)</em></blockquote><blockquote><em>response = client.create_stack</em></blockquote><blockquote><em>StackName=’DevEMR’</em></blockquote><blockquote><em>TemplateURL=’ </em><a href="https://path/to/s3/stack.json"><em>https://path/to/s3/stack.json&#39;</em></a><em> )</em></blockquote><blockquote><em>return(response)</em></blockquote><p>and an example of lambda terminate a stack:</p><blockquote><em>import boto</em></blockquote><blockquote><em>def lambda_handler(event, context)</em></blockquote><blockquote><em># TODO implement</em></blockquote><blockquote><em>#return ‘Hello from Lambda’</em></blockquote><blockquote><em>client = boto3.client(‘cloudformation’)</em></blockquote><blockquote><em>response = client.delete_stack(StackName=’DevEMR’)</em></blockquote><p>example of a stack temple, it give you a good sense, bit too specific, but good place to get started:</p><blockquote><a href="https://github.com/awslabs/aws-cloudformation-templates/blob/master/aws/services/EMR/EMRCLusterGangliaWithSparkOrS3backedHbase.json"><em>https://github.com/awslabs/aws-cloudformation-templates/blob/master/aws/services/EMR/EMRCLusterGangliaWithSparkOrS3backedHbase.json</em></a></blockquote><p>Since it is very easy to makes mistakes in CloudFormation, i have attache several examples of clusters, each example, adds something new to the cluster. this way , you can take the basic example below and start adding, and comparing to what i did.</p><p>another working example is for EMR cluster with many apps selected, with no instance group and auto scaling.</p><blockquote><em>{<br>“AWSTemplateFormatVersion”: “2010–09–09”,<br>“Description”: “myEmrCluster”,<br>“Parameters”: {<br>“EMRClusterName”: {<br>“Description”: “Name of the cluster”,<br>“Type”: “String”,<br>“Default”: “myEmrCluster”<br>},<br>“KeyName”: {<br>“Description”: “Must be an existing Keyname”,<br>“Type”: “String”,<br>“Default”: “walla_omid”</em></blockquote><blockquote><em>},<br>“MasterInstacneType”: {<br>“Description”: “Instance type to be used for the master instance.”,<br>“Type”: “String”,<br>“Default”: “r4.xlarge”<br>},<br>“CoreInstanceType”: {<br>“Description”: “Instance type to be used for core instances.”,<br>“Type”: “String”,<br>“Default”: “r4.xlarge”<br>},<br>“NumberOfCoreInstances”: {<br>“Description”: “Must be a valid number”,<br>“Type”: “Number”,<br>“Default”: 1<br>},<br>“SubnetID”: {<br>“Description”: “Must be Valid public subnet ID”,<br>“Default”: “subnet-012344e”,<br>“Type”: “String”<br>},<br>“LogUri”: {<br>“Description”: “Must be a valid S3 URL”,<br>“Default”: “s3://aws-logs-12313231eu-west-1/elasticmapreduce/”,<br>“Type”: “String”<br>},<br>“S3DataUri”: {<br>“Description”: “Must be a valid S3 bucket URL “,<br>“Default”: “s3://aws-logs-12131212-eu-west-1/elasticmapreduce/”,<br>“Type”: “String”<br>},<br>“ReleaseLabel”: {<br>“Description”: “Must be a valid EMR release version”,<br>“Default”: “emr-5.13.0”,<br>“Type”: “String”<br>},<br>“Applications”: {<br>“Description”: “Cluster setup:”,<br>“Type”: “String”,<br>“AllowedValues”: [<br>“Spark”,<br>“TBD”<br>]<br>}<br>},<br>“Mappings”: {},<br>“Conditions”: {<br>“Spark”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Spark”<br>]<br>},<br>“Hbase”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Hbase”<br>]<br>}<br>},<br>“Resources”: {<br>“EMRCluster”: {<br>“DependsOn”: [<br>“EMRClusterServiceRole”,<br>“EMRClusterinstanceProfileRole”,<br>“EMRClusterinstanceProfile”<br>],<br>“Type”: “AWS::EMR::Cluster”,<br>“Properties”: {<br>“Applications”: [<br>{<br>“Name”: “Ganglia”<br>},<br>{<br>“Name”: “Spark”<br>},<br>{<br>“Name”: “Hive”<br>},<br>{<br>“Name”: “Tez”<br>},<br>{<br>“Name”: “Zeppelin”<br>},<br>{<br>“Name”: “Oozie”<br>},<br>{<br>“Name”: “Hue”<br>},<br>{<br>“Name”: “Presto”<br>},<br>{<br>“Name”: “Livy”<br>}<br>],<br>“Configurations”: [<br>{“Classification”:”hive-site”, “ConfigurationProperties”:{“hive.metastore.client.factory.class”:”com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”}},<br>{“Classification”:”spark”, “ConfigurationProperties”:{“maximizeResourceAllocation”:”true”}},<br>{“Classification”:”presto-connector-hive”, “ConfigurationProperties”:{“hive.metastore.glue.datacatalog.enabled”:”true”}},<br>{“Classification”:”spark-hive-site”, “ConfigurationProperties”:{“hive.metastore.client.factory.class”:”com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”}}</em></blockquote><blockquote><em>],<br>“Instances”: {<br>“Ec2KeyName”: {<br>“Ref”: “KeyName”<br>},<br>“Ec2SubnetId”: {<br>“Ref”: “SubnetID”<br>},<br>“AdditionalMasterSecurityGroups” : [ “sg-ad1234” ],<br>“AdditionalSlaveSecurityGroups” : [ “sg-aa41234” ],<br>“MasterInstanceGroup”: {<br>“InstanceCount”: 1,<br>“InstanceType”: {<br>“Ref”: “MasterInstacneType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Master”<br>},<br>“CoreInstanceGroup”: {<br>“InstanceCount”: {<br>“Ref”: “NumberOfCoreInstances”<br>},<br>“InstanceType”: {<br>“Ref”: “CoreInstanceType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Core”<br>},<br>“TerminationProtected”: false<br>},<br>“VisibleToAllUsers”: true,<br>“JobFlowRole”: {<br>“Ref”: “EMRClusterinstanceProfile”<br>},<br>“ReleaseLabel”: {<br>“Ref”: “ReleaseLabel”<br>},<br>“LogUri”: {<br>“Ref”: “LogUri”<br>},<br>“Name”: {<br>“Ref”: “EMRClusterName”<br>},<br>“AutoScalingRole”: “EMR_AutoScaling_DefaultRole”,<br>“ServiceRole”: {<br>“Ref”: “EMRClusterServiceRole”<br>}<br>}<br>},<br>“EMRClusterServiceRole”: {<br>“Type”: “AWS::IAM::Role”,<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Version”: “2012–10–17”,<br>“Statement”: [<br>{<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“elasticmapreduce.amazonaws.com”<br>]<br>},<br>“Action”: [<br>“sts:AssumeRole”<br>]<br>}<br>]<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole”<br>],<br>“Path”: “/”<br>}<br>},<br>“EMRClusterinstanceProfileRole”: {<br>“Type”: “AWS::IAM::Role”,<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Version”: “2012–10–17”,<br>“Statement”: [<br>{<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“ec2.amazonaws.com”<br>]<br>},<br>“Action”: [<br>“sts:AssumeRole”<br>]<br>}<br>]<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role”<br>],<br>“Path”: “/”<br>}<br>},<br>“EMRClusterinstanceProfile”: {<br>“Type”: “AWS::IAM::InstanceProfile”,<br>“Properties”: {<br>“Path”: “/”,<br>“Roles”: [<br>{<br>“Ref”: “EMRClusterinstanceProfileRole”<br>}<br>]<br>}<br>}<br>},<br>“Outputs”: {}<br>}</em></blockquote><h2>Quick note: Cloud former and EMR — not recommended…</h2><p>Another way to get the JSON for cloud formation is to use cloud former, it uses existing setup and reverse engineers a json for it. below is the documentation. but before you jump right to it… EMR is now supported in cloud former :(. you can use it for</p><p>1) VPCs<br>2) VPC Network (VPC Subnets, Internet Gateways, Customer Gateways, DHCP options)<br>3) VPC Security (Network ACLs, Rote Tables)<br>4) Network (ELB, Elastic IP , Network Interfaces)<br>5) Compute (Auto Scaling Groups, EC2 Instances)<br>6) Storage (EBS Volumes, RDS Instances, DynamoDB Tables, S3 Buckets)<br>7) Services (SQS, SNS Topics, SimpleDB Domains)<br>8) Config (Auto Scaling Launch Configurations, RDS Subnet groups, RDS Parameter Groups)<br>9) Security (EC2 Security Groups, RDS Security Groups, SQS Queue Policies, SNS Tpic Policies, S3 Bucket Policies)<br>10)Optional Resources (AutoScaling Policies, CloudWatch Alarms)</p><p>However, EMR is not yet supported in cloud former. and I have created a Feature Request to the internal team to see if they can implement in. However this service has been in beta since 2015, so it might be a while before EMR support comes out.</p><p>Documentation of Cloud former:</p><p><a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-using-cloudformer.html">https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-using-cloudformer.html</a></p><p>Or using this youtube video blog :)</p><p><a href="https://www.youtube.com/watch?v=wJ1EKkJbg6M">https://www.youtube.com/watch?v=wJ1EKkJbg6M</a></p><h2>Advanced EMR cluster bootstrapping using Cloud Formation example of json</h2><p>as there is no good compressive examples for AWS EMR bootstrapping with all the different options and the fact, the it takes a lot of time do debug each time. I am contributing this JSON we are using internally to AWS Support for them to publish on their online resources:</p><h3>This AWS EMR cluster will contain:</h3><p>1 master node (on demand)</p><p>1 data node (on demand)</p><p>1 task node (spot)</p><p>Auto scaling — scale in/out</p><p>apps:spark,hive,presto and more…</p><p>config: maximizeResourceAllocation, glue for spark/hive/presto</p><p>again, use <a href="https://jsonformatter.curiousconcept.com/">https://jsonformatter.curiousconcept.com/</a> to reformat the below json easily.</p><blockquote><em>{<br>“AWSTemplateFormatVersion”: “2010–09–09”,<br>“Conditions”: {<br>“Hbase”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Hbase”<br>]<br>},<br>“Spark”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Spark”<br>]<br>}<br>},<br>“Description”: “myEmrCluster”,<br>“Mappings”: {},<br>“Outputs”: {},<br>“Parameters”: {<br>“Applications”: {<br>“AllowedValues”: [<br>“Spark”,<br>“TBD”<br>],<br>“Description”: “Cluster setup:”,<br>“Type”: “String”<br>},<br>“CoreInstanceType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for core instances.”,<br>“Type”: “String”<br>},<br>“EMRClusterName”: {<br>“Default”: “myEmrCluster”,<br>“Description”: “Name of the cluster”,<br>“Type”: “String”<br>},<br>“KeyName”: {<br>“Default”: “walla_omid”,<br>“Description”: “Must be an existing Keyname”,<br>“Type”: “String”<br>},<br>“LogUri”: {<br>“Default”: “s3://aws-logs-111111111-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 URL”,<br>“Type”: “String”<br>},<br>“MasterInstacneType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for the master instance.”,<br>“Type”: “String”<br>},<br>“NumberOfCoreInstances”: {<br>“Default”: 1,<br>“Description”: “Must be a valid number”,<br>“Type”: “Number”<br>},<br>“ReleaseLabel”: {<br>“Default”: “emr-5.13.0”,<br>“Description”: “Must be a valid EMR release version”,<br>“Type”: “String”<br>},<br>“S3DataUri”: {<br>“Default”: “s3://aws-logs-1111111-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 bucket URL “,<br>“Type”: “String”<br>},<br>“SubnetID”: {<br>“Default”: “subnet-123456e”,<br>“Description”: “Must be Valid public subnet ID”,<br>“Type”: “String”<br>}<br>},<br>“Resources”: {<br>“EMRCluster”: {<br>“</em><strong><em>DependsOn</em></strong><em>”: [<br>“EMRClusterServiceRole”,<br>“EMRClusterinstanceProfileRole”,<br>“EMRClusterinstanceProfile”<br>],<br>“Properties”: {<br>“Applications”: [<br>{<br>“Name”: “Ganglia”<br>},<br>{<br>“Name”: “Spark”<br>},<br>{<br>“Name”: “Hive”<br>},<br>{<br>“Name”: “Tez”<br>},<br>{<br>“Name”: “Zeppelin”<br>},<br>{<br>“Name”: “Oozie”<br>},<br>{<br>“Name”: “Hue”<br>},<br>{<br>“Name”: “Presto”<br>},<br>{<br>“Name”: “Livy”<br>}<br>],<br>“AutoScalingRole”: “EMR_AutoScaling_DefaultRole”,<br>“Configurations”: [<br>{<br>“Classification”: “hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>},<br>{<br>“Classification”: “spark”,<br>“ConfigurationProperties”: {<br>“maximizeResourceAllocation”: “true”<br>}<br>},<br>{<br>“Classification”: “presto-connector-hive”,<br>“ConfigurationProperties”: {<br>“hive.metastore.glue.datacatalog.enabled”: “true”<br>}<br>},<br>{<br>“Classification”: “spark-hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>}<br>],<br>“Instances”: {<br>“AdditionalMasterSecurityGroups”: [<br>“sg-1234”<br>],<br>“AdditionalSlaveSecurityGroups”: [<br>“sg-1234”<br>],<br>“CoreInstanceGroup”: {<br>“InstanceCount”: {<br>“Ref”: “NumberOfCoreInstances”<br>},<br>“InstanceType”: {<br>“Ref”: “CoreInstanceType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Core”<br>},<br>“Ec2KeyName”: {<br>“Ref”: “KeyName”<br>},<br>“Ec2SubnetId”: {<br>“Ref”: “SubnetID”<br>},<br>“MasterInstanceGroup”: {<br>“InstanceCount”: 1,<br>“InstanceType”: {<br>“Ref”: “MasterInstacneType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Master”<br>},<br>“TerminationProtected”: false<br>},<br>“JobFlowRole”: {<br>“Ref”: “EMRClusterinstanceProfile”<br>},<br>“LogUri”: {<br>“Ref”: “LogUri”<br>},<br>“Name”: {<br>“Ref”: “EMRClusterName”<br>},<br>“ReleaseLabel”: {<br>“Ref”: “ReleaseLabel”<br>},<br>“ServiceRole”: {<br>“Ref”: “EMRClusterServiceRole”<br>},<br>“VisibleToAllUsers”: true<br>},<br>“Type”: “AWS::EMR::Cluster”<br>},<br>“EMRClusterInstanceGroupConfig”: {<br>“Properties”: {<br>“Market”:”SPOT”,<br>“AutoScalingPolicy”: {<br>“Constraints”: {<br>“MaxCapacity”: 4,<br>“MinCapacity”: 0<br>},<br>“Rules”: [<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 2<br>}<br>},<br>“Description”: “yarn-scale-out2”,<br>“Name”: “yarn-scale-out2”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “LESS_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 20<br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: -1<br>}<br>},<br>“Description”: “yarn-scale-in1”,<br>“Name”: “yarn-scale-in1”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 80<br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 2<br>}<br>},<br>“Description”: “con-scale-out”,<br>“Name”: “con-scale-out”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 12,<br>“MetricName”: “ContainerPendingRatio”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 0.75<br>}<br>}<br>}<br>]<br>},<br>“BidPrice”: “15”,<br>“EbsConfiguration”: {<br>“EbsBlockDeviceConfigs”: [<br>{<br>“VolumeSpecification”: {<br>“SizeInGB”: “50”,<br>“VolumeType”: “gp2”<br>},<br>“VolumesPerInstance”: “1”<br>}<br>],<br>“EbsOptimized”: “true”<br>},<br>“InstanceCount”: 1,<br>“InstanceRole”: “TASK”,<br>“InstanceType”: “r4.xlarge”,<br>“JobFlowId”: {<br>“Ref”: “EMRCluster”<br>},<br>“Name”: “TaskSpotsNinja”<br>},<br>“Type”: “AWS::EMR::InstanceGroupConfig”<br>},<br>“EMRClusterServiceRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“elasticmapreduce.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole”<br>],<br>“Path”: “/”<br>},<br>“Type”: “AWS::IAM::Role”<br>},<br>“EMRClusterinstanceProfile”: {<br>“Properties”: {<br>“Path”: “/”,<br>“Roles”: [<br>{<br>“Ref”: “EMRClusterinstanceProfileRole”<br>}<br>]<br>},<br>“Type”: “AWS::IAM::InstanceProfile”<br>},<br>“EMRClusterinstanceProfileRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“ec2.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role”<br>],<br>“Path”: “/”<br>},<br>“Type”: “AWS::IAM::Role”<br>}<br>}<br>}</em></blockquote><p>Once the cluster is up you need to run steps to automate your cluster needs</p><p>documentation for creating a step that runs a bash script:</p><p><a href="https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hadoop-script.html">https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-hadoop-script.html</a></p><p>you can do it also via</p><ol><li>the GUI</li><li>the UI.</li><li>go to steps, add new step:</li><li>JAR location: s3://eu-west-1.elasticmapreduce/libs/script-runner/script-runner.jar</li><li>arguments: s3://emr-bootstrap/my-bootstrap-emr.sh</li><li>“Add”, and wait :)</li><li>Cloud Formation</li></ol><p>addgin the step to the same cluster from above will change the jsons as follows:</p><blockquote><em>{<br>“AWSTemplateFormatVersion”: “2010–09–09”,<br>“Conditions”: {<br>“Hbase”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Hbase”<br>]<br>},<br>“Spark”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Spark”<br>]<br>}<br>},<br>“Description”: “myEmrCluster”,<br>“Mappings”: {},<br>“Outputs”: {},<br>“Parameters”: {<br>“Applications”: {<br>“AllowedValues”: [<br>“Spark”,<br>“TBD”<br>],<br>“Description”: “Cluster setup:”,<br>“Type”: “String”<br>},<br>“CoreInstanceType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for core instances.”,<br>“Type”: “String”<br>},<br>“EMRClusterName”: {<br>“Default”: “myEmrCluster”,<br>“Description”: “Name of the cluster”,<br>“Type”: “String”<br>},<br>“KeyName”: {<br>“Default”: “walla_omid”,<br>“Description”: “Must be an existing Keyname”,<br>“Type”: “String”<br>},<br>“LogUri”: {<br>“Default”: “s3://aws-logs-1234-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 URL”,<br>“Type”: “String”<br>},<br>“MasterInstacneType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for the master instance.”,<br>“Type”: “String”<br>},<br>“NumberOfCoreInstances”: {<br>“Default”: 1,<br>“Description”: “Must be a valid number”,<br>“Type”: “Number”<br>},<br>“ReleaseLabel”: {<br>“Default”: “emr-5.13.0”,<br>“Description”: “Must be a valid EMR release version”,<br>“Type”: “String”<br>},<br>“S3DataUri”: {<br>“Default”: “s3://aws-logs-23rt-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 bucket URL “,<br>“Type”: “String”<br>},<br>“SubnetID”: {<br>“Default”: “subnet-12345”,<br>“Description”: “Must be Valid public subnet ID”,<br>“Type”: “String”<br>}<br>},<br>“Resources”: {<br>“EMRCluster”: {<br>“DependsOn”: [<br>“EMRClusterServiceRole”,<br>“EMRClusterinstanceProfileRole”,<br>“EMRClusterinstanceProfile”<br>],<br>“Properties”: {</em></blockquote><blockquote><em>“Applications”: [<br>{<br>“Name”: “Ganglia”<br>},<br>{<br>“Name”: “Spark”<br>},<br>{<br>“Name”: “Hive”<br>},<br>{<br>“Name”: “Tez”<br>},<br>{<br>“Name”: “Zeppelin”<br>},<br>{<br>“Name”: “Oozie”<br>},<br>{<br>“Name”: “Hue”<br>},<br>{<br>“Name”: “Presto”<br>},<br>{<br>“Name”: “Livy”<br>}<br>],<br>“AutoScalingRole”: “EMR_AutoScaling_DefaultRole”,<br>“Configurations”: [<br>{<br>“Classification”: “hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>},<br>{<br>“Classification”: “spark”,<br>“ConfigurationProperties”: {<br>“maximizeResourceAllocation”: “true”<br>}<br>},<br>{<br>“Classification”: “presto-connector-hive”,<br>“ConfigurationProperties”: {<br>“hive.metastore.glue.datacatalog.enabled”: “true”<br>}<br>},<br>{<br>“Classification”: “spark-hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>}<br>],<br>“Instances”: {<br>“AdditionalMasterSecurityGroups”: [<br>“sg-1234”<br>],<br>“AdditionalSlaveSecurityGroups”: [<br>“sg-12345”<br>],<br>“CoreInstanceGroup”: {<br>“InstanceCount”: {<br>“Ref”: “NumberOfCoreInstances”<br>},<br>“InstanceType”: {<br>“Ref”: “CoreInstanceType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Core”<br>},<br>“Ec2KeyName”: {<br>“Ref”: “KeyName”<br>},<br>“Ec2SubnetId”: {<br>“Ref”: “SubnetID”<br>},<br>“MasterInstanceGroup”: {<br>“InstanceCount”: 1,<br>“InstanceType”: {<br>“Ref”: “MasterInstacneType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Master”<br>},<br>“TerminationProtected”: false<br>},<br>“JobFlowRole”: {<br>“Ref”: “EMRClusterinstanceProfile”<br>},<br>“LogUri”: {<br>“Ref”: “LogUri”<br>},<br>“Name”: {<br>“Ref”: “EMRClusterName”<br>},<br>“ReleaseLabel”: {<br>“Ref”: “ReleaseLabel”<br>},<br>“ServiceRole”: {<br>“Ref”: “EMRClusterServiceRole”<br>},<br>“VisibleToAllUsers”: true<br>},<br>“Type”: “AWS::EMR::Cluster”<br>},<br>“EMRClusterInstanceGroupConfig”: {<br>“</em><strong><em>DependsOn</em></strong><em>”: “EMRCluster”,<br>“Properties”: {<br>“Market”:”SPOT”,<br>“AutoScalingPolicy”: {<br>“Constraints”: {<br>“MaxCapacity”: 4,<br>“MinCapacity”: 0<br>},<br>“Rules”: [<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 2<br>}<br>},<br>“Description”: “yarn-scale-out2”,<br>“Name”: “yarn-scale-out2”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “LESS_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 20<br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: -1<br>}<br>},<br>“Description”: “yarn-scale-in1”,<br>“Name”: “yarn-scale-in1”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 80<br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 2<br>}<br>},<br>“Description”: “con-scale-out”,<br>“Name”: “con-scale-out”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 12,<br>“MetricName”: “ContainerPendingRatio”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 0.75<br>}<br>}<br>}<br>]<br>},<br>“BidPrice”: “15”,<br>“EbsConfiguration”: {<br>“EbsBlockDeviceConfigs”: [<br>{<br>“VolumeSpecification”: {<br>“SizeInGB”: “50”,<br>“VolumeType”: “gp2”<br>},<br>“VolumesPerInstance”: “1”<br>}<br>],<br>“EbsOptimized”: “true”<br>},<br>“InstanceCount”: 1,<br>“InstanceRole”: “TASK”,<br>“InstanceType”: “r4.xlarge”,<br>“JobFlowId”: {<br>“Ref”: “EMRCluster”<br>},<br>“Name”: “TaskSpotsNinja”<br>},<br>“Type”: “AWS::EMR::InstanceGroupConfig”<br>},<br>“EMRClusterServiceRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“elasticmapreduce.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole”<br>],<br>“Path”: “/”<br>},<br>“Type”: “AWS::IAM::Role”<br>},<br>“EMRClusterinstanceProfile”: {<br>“Properties”: {<br>“Path”: “/”,<br>“Roles”: [<br>{<br>“Ref”: “EMRClusterinstanceProfileRole”<br>}<br>]<br>},<br>“Type”: “AWS::IAM::InstanceProfile”<br>},<br>“EMRClusterinstanceProfileRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“ec2.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role”<br>],<br>“Path”: “/”<br>},<br>“Type”: “AWS::IAM::Role”<br>},<br>“TestStep”: {<br>“Type”: “AWS::EMR::Step”,<br>“Properties”: {<br>“ActionOnFailure”: “CONTINUE”,<br>“HadoopJarStep”: {<br>“Args”: [<br>“s3://emr-bootstrap/Mybootstrap-emr.sh”<br>],<br>“Jar”: “s3://eu-west-1.elasticmapreduce/libs/script-runner/script-runner.jar”<br>},<br>“Name”: “CustomBootstrap”,<br>“JobFlowId”: {<br>“Ref”: “EMRCluster”<br>}<br>}<br>}<br>}<br>}</em></blockquote><p>Another upgrade to the above cluster is just adding a DNS came for the master. this is useful when you have a team of analysts, connecting to this 0900 to 1700 cluster every day, and you don’t want to really change the JDBC settings every day :) so just create a DNS CNAME for the master node of EMR.</p><blockquote><em>{<br>“AWSTemplateFormatVersion”: “2010–09–09”,<br>“Conditions”: {<br>“Hbase”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Hbase”<br>]<br>},<br>“Spark”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Spark”<br>]<br>}<br>},<br>“Description”: “myEmrCluster”,<br>“Mappings”: {},<br>“Outputs”: {},<br>“Parameters”: {<br>“Applications”: {<br>“AllowedValues”: [<br>“Spark”,<br>“TBD”<br>],<br>“Description”: “Cluster setup:”,<br>“Type”: “String”<br>},<br>“CoreInstanceType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for core instances.”,<br>“Type”: “String”<br>},<br>“EMRClusterName”: {<br>“Default”: “myEmrCluster”,<br>“Description”: “Name of the cluster”,<br>“Type”: “String”<br>},<br>“KeyName”: {<br>“Default”: “walla_omid”,<br>“Description”: “Must be an existing Keyname”,<br>“Type”: “String”<br>},<br>“LogUri”: {<br>“Default”: “s3://aws-logs-506754145427-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 URL”,<br>“Type”: “String”<br>},<br>“MasterInstacneType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for the master instance.”,<br>“Type”: “String”<br>},<br>“NumberOfCoreInstances”: {<br>“Default”: 1,<br>“Description”: “Must be a valid number”,<br>“Type”: “Number”<br>},<br>“ReleaseLabel”: {<br>“Default”: “emr-5.13.0”,<br>“Description”: “Must be a valid EMR release version”,<br>“Type”: “String”<br>},<br>“S3DataUri”: {<br>“Default”: “s3://aws-logs-506754145427-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 bucket URL “,<br>“Type”: “String”<br>},<br>“SubnetID”: {<br>“Default”: “subnet-0647325e”,<br>“Description”: “Must be Valid public subnet ID”,<br>“Type”: “String”<br>}<br>},<br>“Resources”: {<br>“EMRCluster”: {<br>“</em><strong><em>DependsOn</em></strong><em>”: [<br>“EMRClusterServiceRole”,<br>“EMRClusterinstanceProfileRole”,<br>“EMRClusterinstanceProfile”<br>],<br>“Properties”: {</em></blockquote><blockquote><em>“Applications”: [<br>{<br>“Name”: “Ganglia”<br>},<br>{<br>“Name”: “Spark”<br>},<br>{<br>“Name”: “Hive”<br>},<br>{<br>“Name”: “Tez”<br>},<br>{<br>“Name”: “Zeppelin”<br>},<br>{<br>“Name”: “Oozie”<br>},<br>{<br>“Name”: “Hue”<br>},<br>{<br>“Name”: “Presto”<br>},<br>{<br>“Name”: “Livy”<br>}<br>],<br>“AutoScalingRole”: “EMR_AutoScaling_DefaultRole”,<br>“Configurations”: [<br>{<br>“Classification”: “hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>},<br>{<br>“Classification”: “spark”,<br>“ConfigurationProperties”: {<br>“maximizeResourceAllocation”: “true”<br>}<br>},<br>{<br>“Classification”: “presto-connector-hive”,<br>“ConfigurationProperties”: {<br>“hive.metastore.glue.datacatalog.enabled”: “true”<br>}<br>},<br>{<br>“Classification”: “spark-hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>}<br>],<br>“Instances”: {<br>“AdditionalMasterSecurityGroups”: [<br>“sg-ad4e13cb”<br>],<br>“AdditionalSlaveSecurityGroups”: [<br>“sg-aa4e13cc”<br>],<br>“CoreInstanceGroup”: {<br>“InstanceCount”: {<br>“Ref”: “NumberOfCoreInstances”<br>},<br>“InstanceType”: {<br>“Ref”: “CoreInstanceType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Core”<br>},<br>“Ec2KeyName”: {<br>“Ref”: “KeyName”<br>},<br>“Ec2SubnetId”: {<br>“Ref”: “SubnetID”<br>},<br>“MasterInstanceGroup”: {<br>“InstanceCount”: 1,<br>“InstanceType”: {<br>“Ref”: “MasterInstacneType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Master”<br>},<br>“TerminationProtected”: false<br>},<br>“JobFlowRole”: {<br>“Ref”: “EMRClusterinstanceProfile”<br>},<br>“LogUri”: {<br>“Ref”: “LogUri”<br>},<br>“Name”: {<br>“Ref”: “EMRClusterName”<br>},<br>“ReleaseLabel”: {<br>“Ref”: “ReleaseLabel”<br>},<br>“ServiceRole”: {<br>“Ref”: “EMRClusterServiceRole”<br>},<br>“VisibleToAllUsers”: true<br>},<br>“Type”: “AWS::EMR::Cluster”<br>},<br>“EMRClusterInstanceGroupConfig”: {<br>“</em><strong><em>DependsOn</em></strong><em>”: “EMRCluster”,<br>“Properties”: {<br>“Market”:”SPOT”,<br>“AutoScalingPolicy”: {<br>“Constraints”: {<br>“MaxCapacity”: 4,<br>“MinCapacity”: 0<br>},<br>“Rules”: [<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 2<br>}<br>},<br>“Description”: “yarn-scale-out2”,<br>“Name”: “yarn-scale-out2”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “LESS_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 20<br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: -1<br>}<br>},<br>“Description”: “yarn-scale-in1”,<br>“Name”: “yarn-scale-in1”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 80<br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 2<br>}<br>},<br>“Description”: “con-scale-out”,<br>“Name”: “con-scale-out”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 12,<br>“MetricName”: “ContainerPendingRatio”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 0.75<br>}<br>}<br>}<br>]<br>},<br>“BidPrice”: “15”,<br>“EbsConfiguration”: {<br>“EbsBlockDeviceConfigs”: [<br>{<br>“VolumeSpecification”: {<br>“SizeInGB”: “50”,<br>“VolumeType”: “gp2”<br>},<br>“VolumesPerInstance”: “1”<br>}<br>],<br>“EbsOptimized”: “true”<br>},<br>“InstanceCount”: 1,<br>“InstanceRole”: “TASK”,<br>“InstanceType”: “r4.xlarge”,<br>“JobFlowId”: {<br>“Ref”: “EMRCluster”<br>},<br>“Name”: “TaskSpotsNinja”<br>},<br>“Type”: “AWS::EMR::InstanceGroupConfig”<br>},<br>“EMRClusterServiceRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“elasticmapreduce.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole”<br>],<br>“Path”: “/”<br>},<br>“Type”: “AWS::IAM::Role”<br>},<br>“EMRClusterinstanceProfile”: {<br>“Properties”: {<br>“Path”: “/”,<br>“Roles”: [<br>{<br>“Ref”: “EMRClusterinstanceProfileRole”<br>}<br>]<br>},<br>“Type”: “AWS::IAM::InstanceProfile”<br>},<br>“EMRClusterinstanceProfileRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“ec2.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role”<br>],<br>“Path”: “/”<br>},<br>“Type”: “AWS::IAM::Role”<br>},<br>“TestStep”: {<br>“Type”: “AWS::EMR::Step”,<br>“Properties”: {<br>“ActionOnFailure”: “CONTINUE”,<br>“HadoopJarStep”: {<br>“Args”: [<br>“s3://byoo-emr-bootstrap/bootstrap-emr.sh”<br>],<br>“Jar”: “s3://eu-west-1.elasticmapreduce/libs/script-runner/script-runner.jar”<br>},<br>“Name”: “CustomBootstrap”,<br>“JobFlowId”: {<br>“Ref”: “EMRCluster”<br>}<br>}<br>},<br></em><strong><em>“myDNSRecord” : {</em></strong><em><br></em><strong><em>“Type” : “AWS::Route53::RecordSet”,</em></strong><em><br></em><strong><em>“Properties” : {</em></strong><em><br></em><strong><em>“HostedZoneName” : “b-yoo.net.”,</em></strong><em><br></em><strong><em>“Comment” : “DNS name for my instance. for emr. cloud formation”, </em></strong><em><br></em><strong><em>“Name” : “xxx.myDomain.com”,</em></strong><em><br></em><strong><em>“Type” : “CNAME”,</em></strong><em><br></em><strong><em>“TTL” : “600”,</em></strong><em><br></em><strong><em>“ResourceRecords” : [ { “Fn::GetAtt” : [ “EMRCluster”, “MasterPublicDNS” ] } ]</em></strong><em><br></em><strong><em>}</em></strong><em><br></em><strong><em>}</em></strong><em><br>}<br>}</em></blockquote><p>You may have conceded using ALB on top of EMR, but currently CloudFormation, does not return the instance ID of the master node. you only get the Master node public dns, so u can only create CNAME for it using route 53. you can involve lambda some code to get thing moving, but there is an open feature request to resolve this issue, so you may want to hold on. :)</p><h2>quick note about deleting stack</h2><p>you may want to add dependsOn attribute to help cloud Formation properly delete the resources on rollback or delete stack. attaching the same json with depends on. this json also a small mistake we did in previous jsons in the autoscaling, i forgot to add the “UNIT” attribute to make sure the value is considered as percentage</p><blockquote><em>{<br>“AWSTemplateFormatVersion”: “2010–09–09”,<br>“Conditions”: {<br>“Hbase”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Hbase”<br>]<br>},<br>“Spark”: {<br>“Fn::Equals”: [<br>{<br>“Ref”: “Applications”<br>},<br>“Spark”<br>]<br>}<br>},<br>“Description”: “myEmrCluster”,<br>“Mappings”: {},<br>“Outputs”: {},<br>“Parameters”: {<br>“Applications”: {<br>“AllowedValues”: [<br>“Spark”,<br>“TBD”<br>],<br>“Description”: “Cluster setup:”,<br>“Type”: “String”<br>},<br>“CoreInstanceType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for core instances.”,<br>“Type”: “String”<br>},<br>“EMRClusterName”: {<br>“Default”: “myEmrCluster”,<br>“Description”: “Name of the cluster”,<br>“Type”: “String”<br>},<br>“KeyName”: {<br>“Default”: “aws_big_data_demystified”,<br>“Description”: “Must be an existing Keyname”,<br>“Type”: “String”<br>},<br>“LogUri”: {<br>“Default”: “s3://aws-logs-123-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 URL”,<br>“Type”: “String”<br>},<br>“MasterInstacneType”: {<br>“Default”: “r4.xlarge”,<br>“Description”: “Instance type to be used for the master instance.”,<br>“Type”: “String”<br>},<br>“NumberOfCoreInstances”: {<br>“Default”: 1,<br>“Description”: “Must be a valid number”,<br>“Type”: “Number”<br>},<br>“ReleaseLabel”: {<br>“Default”: “emr-5.13.0”,<br>“Description”: “Must be a valid EMR release version”,<br>“Type”: “String”<br>},<br>“S3DataUri”: {<br>“Default”: “s3://aws-logs-1234-eu-west-1/elasticmapreduce/”,<br>“Description”: “Must be a valid S3 bucket URL “,<br>“Type”: “String”<br>},<br>“SubnetID”: {<br>“Default”: “subnet-1234e”,<br>“Description”: “Must be Valid public subnet ID”,<br>“Type”: “String”<br>}<br>},<br>“Resources”: {<br>“EMRCluster”: {<br>“DependsOn”: [<br>“EMRClusterServiceRole”,<br>“EMRClusterinstanceProfileRole”,<br>“EMRClusterinstanceProfile”<br>],<br>“Properties”: {<br>“Applications”: [<br>{<br>“Name”: “Ganglia”<br>},<br>{<br>“Name”: “Spark”<br>},<br>{<br>“Name”: “Hive”<br>},<br>{<br>“Name”: “Tez”<br>},<br>{<br>“Name”: “Zeppelin”<br>},<br>{<br>“Name”: “Oozie”<br>},<br>{<br>“Name”: “Hue”<br>},<br>{<br>“Name”: “Presto”<br>},<br>{<br>“Name”: “Livy”<br>}<br>],<br>“AutoScalingRole”: “EMR_AutoScaling_DefaultRole”,<br>“Configurations”: [<br>{<br>“Classification”: “hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>},<br>{<br>“Classification”: “spark”,<br>“ConfigurationProperties”: {<br>“maximizeResourceAllocation”: “true”<br>}<br>},<br>{<br>“Classification”: “presto-connector-hive”,<br>“ConfigurationProperties”: {<br>“hive.metastore.glue.datacatalog.enabled”: “true”<br>}<br>},<br>{<br>“Classification”: “spark-hive-site”,<br>“ConfigurationProperties”: {<br>“hive.metastore.client.factory.class”: “com.amazonaws.glue.catalog.metastore.AWSGlueDataCatalogHiveClientFactory”<br>}<br>}<br>],<br>“Instances”: {<br>“AdditionalMasterSecurityGroups”: [<br>“sg-1234”<br>],<br>“AdditionalSlaveSecurityGroups”: [<br>“sg-1234”<br>],<br>“CoreInstanceGroup”: {<br>“InstanceCount”: {<br>“Ref”: “NumberOfCoreInstances”<br>},<br>“InstanceType”: {<br>“Ref”: “CoreInstanceType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Core”<br>},<br>“Ec2KeyName”: {<br>“Ref”: “KeyName”<br>},<br>“Ec2SubnetId”: {<br>“Ref”: “SubnetID”<br>},<br>“MasterInstanceGroup”: {<br>“InstanceCount”: 1,<br>“InstanceType”: {<br>“Ref”: “MasterInstacneType”<br>},<br>“Market”: “ON_DEMAND”,<br>“Name”: “Master”<br>},<br>“TerminationProtected”: false<br>},<br>“JobFlowRole”: {<br>“Ref”: “EMRClusterinstanceProfile”<br>},<br>“LogUri”: {<br>“Ref”: “LogUri”<br>},<br>“Name”: {<br>“Ref”: “EMRClusterName”<br>},<br>“ReleaseLabel”: {<br>“Ref”: “ReleaseLabel”<br>},<br>“ServiceRole”: {<br>“Ref”: “EMRClusterServiceRole”<br>},<br>“VisibleToAllUsers”: true<br>},<br>“Type”: “AWS::EMR::Cluster”<br>},<br>“EMRClusterInstanceGroupConfig”: {<br>“</em><strong><em>DependsOn</em></strong><em>”: “EMRCluster”,<br>“Properties”: {<br>“Market”: “SPOT”,<br>“AutoScalingPolicy”: {<br>“Constraints”: {<br>“MaxCapacity”: 40,<br></em><strong><em>“MinCapacity”: 0</em></strong><em><br>},<br>“Rules”: [<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 4<br>}<br>},<br>“Description”: “yarn-scale-out2”,<br>“Name”: “yarn-scale-out2”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “LESS_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 20,<br></em><strong><em>“Unit”: “PERCENT”</em></strong><em><br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: -1<br>}<br>},<br>“Description”: “yarn-scale-in1”,<br>“Name”: “yarn-scale-in1”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “YARNMemoryAvailablePercentage”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 80,<br></em><strong><em>“Unit”: “PERCENT”</em></strong><em><br>}<br>}<br>},<br>{<br>“Action”: {<br>“SimpleScalingPolicyConfiguration”: {<br>“AdjustmentType”: “CHANGE_IN_CAPACITY”,<br>“CoolDown”: 100,<br>“ScalingAdjustment”: 4<br>}<br>},<br>“Description”: “con-scale-out”,<br>“Name”: “con-scale-out”,<br>“Trigger”: {<br>“CloudWatchAlarmDefinition”: {<br>“ComparisonOperator”: “GREATER_THAN_OR_EQUAL”,<br>“EvaluationPeriods”: 1,<br>“MetricName”: “ContainerPendingRatio”,<br>“Namespace”: “AWS/ElasticMapReduce”,<br>“Period”: 300,<br>“Threshold”: 0.75,<br></em><strong><em>“Unit”: “COUNT”</em></strong><em><br>}<br>}<br>}<br>]<br>},<br>“BidPrice”: “15”,<br>“EbsConfiguration”: {<br>“EbsBlockDeviceConfigs”: [<br>{<br>“VolumeSpecification”: {<br>“SizeInGB”: “50”,<br>“VolumeType”: “gp2”<br>},<br>“VolumesPerInstance”: “1”<br>}<br>],<br>“EbsOptimized”: “true”<br>},<br>“InstanceCount”: 1,<br>“InstanceRole”: “TASK”,<br>“InstanceType”: “r4.xlarge”,<br>“JobFlowId”: {<br>“Ref”: “EMRCluster”<br>},<br>“Name”: “TaskSpotsNinja”<br>},<br>“Type”: “AWS::EMR::InstanceGroupConfig”<br>},<br>“EMRClusterServiceRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“elasticmapreduce.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole”<br>],<br>“Path”: “/”,<br>“Policies”: [<br>{<br>“PolicyName”: “s3fullaccess”,<br>“PolicyDocument”: {<br>“Version”: “2012–10–17”,<br>“Statement”: [<br>{<br>“Effect”: “Allow”,<br>“Action”: “s3:*”,<br>“Resource”: “*”<br>}<br>]<br>}<br>}<br>]<br>},<br>“Type”: “AWS::IAM::Role”<br>},<br>“EMRClusterinstanceProfile”: {<br>“Properties”: {<br>“Path”: “/”,<br>“Roles”: [<br>{<br>“Ref”: “EMRClusterinstanceProfileRole”<br>}<br>]<br>},<br>“Type”: “AWS::IAM::InstanceProfile”<br>},<br>“EMRClusterinstanceProfileRole”: {<br>“Properties”: {<br>“AssumeRolePolicyDocument”: {<br>“Statement”: [<br>{<br>“Action”: [<br>“sts:AssumeRole”<br>],<br>“Effect”: “Allow”,<br>“Principal”: {<br>“Service”: [<br>“ec2.amazonaws.com”<br>]<br>}<br>}<br>],<br>“Version”: “2012–10–17”<br>},<br>“ManagedPolicyArns”: [<br>“arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role”<br>],<br>“Path”: “/”<br>},<br>“Type”: “AWS::IAM::Role”<br>},<br>“TestStep”: {<br>“Type”: “AWS::EMR::Step”,<br></em><strong><em>“DependsOn”: “EMRClusterInstanceGroupConfig”,</em></strong><em><br>“Properties”: {<br>“ActionOnFailure”: “CONTINUE”,<br>“HadoopJarStep”: {<br>“Args”: [<br>“s3://byoo-emr-bootstrap/bootstrap-emr.sh”<br>],<br>“Jar”: “s3://eu-west-1.elasticmapreduce/libs/script-runner/script-runner.jar”<br>},<br>“Name”: “CustomBootstrap”,<br>“JobFlowId”: {<br>“Ref”: “EMRCluster”<br>}<br>}<br>},<br>“myDNSRecord”: {<br>“Type”: “AWS::Route53::RecordSet”,<br></em><strong><em>“DependsOn”: [“EMRCluster”],</em></strong><em><br>“Properties”: {<br>“HostedZoneName”: “b-yoo.net.”,<br>“Comment”: “DNS name for my instance. for emr. cloud formation”,<br>“Name”: “xxx.b-yoo.net”,<br>“Type”: “CNAME”,<br>“TTL”: “600”,<br>“ResourceRecords”: [<br>{<br>“Fn::GetAtt”: [<br>“EMRCluster”,<br>“MasterPublicDNS”<br>]<br>}<br>]<br>}<br>}<br>}<br>}</em></blockquote><h2>Back to the scheduling… via Lambda</h2><p>Once you settled on your cloud formation stack, you may want to trigger it at 0900 and kill it at 17:00</p><p>here is a lambda boto3 code snippet for the lunch. notice this is a more advanced example the example in the beginning of the blog, as I added the options to select an application in the JSON. and I added the “CAPABILITY_IAM” explicit acknowledgement required by CF:</p><blockquote><em>import boto3</em></blockquote><blockquote><em>def lambda_handler(event, context):<br>client = boto3.client(‘cloudformation’)<br>response = client.create_stack(<br>StackName=’StgEMR’,<br>Parameters=[<br>{<br>‘ParameterKey’: ‘Applications’,<br>‘ParameterValue’: ‘Spark’,<br>‘UsePreviousValue’: True,<br>‘ResolvedValue’: ‘string’<br>},<br>],<br>Capabilities=[<br>‘CAPABILITY_IAM’,<br>],<br>TemplateURL=’https://myBucket/emrClusterCloudFormation.json&#39;)<br>return(response)</em></blockquote><p>with a cloud formation trigger with a schedule expression:</p><blockquote><em>Schedule expression: </em><strong><em>cron(0 9 ? * SUN-THU *)</em></strong></blockquote><p>and another lambda code snippet would be for the destroy</p><blockquote><em>import boto3</em></blockquote><blockquote><em>def lambda_handler(event, context):<br>client = boto3.client(‘cloudformation’)<br>response = client.delete_stack(StackName=’StgEMR’)</em></blockquote><p>with a cloud formation trigger with a schedule expression:</p><blockquote><em>Schedule expression: </em><strong><em>cron(0 17 ? * SUN-THU *)</em></strong></blockquote><h2>Important note about this lambda:</h2><p>you will need to create a role for lambda that include permissions for:</p><ol><li>CloudFormation policy that creates and delete stack</li><li>Route53 for managing the DNS</li><li>IAM policies to add those EMR roles</li><li>EMR polices to lunch clusters</li><li>s3 read only to read the JSON file :)</li></ol><p>I highly recommend to use least privilege practice to minimise the permissions given to the lambdas and using VPC to run the Lambda.</p><h2>Option 2 Summery</h2><ul><li>we learned several ways to lunch an EMR cluster from 0900 to 1700</li><li>Just for perspective, it took my 5 full working days to create the EMR json, and and 1 hour to work with lambda. :)</li><li>CloudFormation can you achiever many things with EMR, though the JSON creation process was not trivial, and the documentation was a bit lacking in terms of EMR and cloud formation, i was able to provide a comprehensive working cloud formation example for your to play with and customize to your needs</li><li>Once the JSON of CF is ready, triggering within lambda will take you about an hour including the learning curve.</li><li>The beauty of using CF, is that stack takes care of the resources, you do not need to handle instance id, or public dns, you simple working with dynamic parameters.</li><li>The downside of working with EMR and CF, that as of today, there is no easy and trivial way to add load balancers to the json, as the EMR wont return the instance ID of the master node, only its public DNS.</li></ul><p>Thanks, and have fun!</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -</p><ul><li>Contact me via linked in <a href="https://www.linkedin.com/in/omid-vahdaty?trk=nav_responsive_tab_profile">Omid Vahdaty</a></li><li>website: <a href="https://amazon-aws-big-data-demystified.ninja/">https://amazon-aws-big-data-demystified.ninja/</a></li><li>Join our meetup, FB group and youtube channel</li><li>Join our meetup : <a href="https://www.meetup.com/AWS-Big-Data-Demystified/">https://www.meetup.com/AWS-Big-Data-Demystified/</a></li><li>Join our facebook group <a href="https://www.facebook.com/groups/amazon.aws.big.data.demystified/">https://www.facebook.com/groups/amazon.aws.big.data.demystified/</a></li><li>subscribe to our youtube channel <a href="https://www.youtube.com/channel/UCzeGqhZIWU-hIDczWa8GtgQ?view_as=subscriber">https://www.youtube.com/channel/UCzeGqhZIWU-hIDczWa8GtgQ?view_as=subscriber</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed7190f1e55a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>