# ec2 attributes

**URL:** <https://discourse.chef.io/t/ec2-attributes/6483>\
**Category:** Chef Infra (archive)\
**Created:** [April 16, 2015, 11:09am UTC](https://discourse.chef.io/t/ec2-attributes/6483 "2015-04-16T11:09:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Guilherme\_Vanz](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jose_guilherme_vanz/32/114_2.png) [@Jose\_Guilherme\_Vanz](https://discourse.chef.io/u/Jose_Guilherme_Vanz)\
**Post date:** [April 16, 2015, 11:09am UTC](https://discourse.chef.io/t/ec2-attributes/6483/1 "2015-04-16T11:09:58Z")

</div>

Hi

I’m configuring an AWS auto scaling group in my infrastructure. Now, I am  
writing a script to install and configure chef-client in the ec2 instances  
launched automatically.

When I run the chef-client first time, it find my recipes and try to run  
them. Some of the recipes uses attributes from ec2 (e.g.  
node[‘ec2’][‘instance\_id’] ). But this attribute does not exist in the  
instance. Some guy s in the irc channel told me to rerun ohai to reload the  
attributes. For this, I added the following code in the recipe:

> <https://gist.github.com/jvanz/d8b73de8a0d4457e11e7>

But the problem persists. Is This what I should do?

---

<div class="post-metadata">

**Author:** ![Peter\_Burkholder3](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@Peter\_Burkholder3](https://discourse.chef.io/u/Peter_Burkholder3)\
**Post date:** [April 16, 2015, 12:27pm UTC](https://discourse.chef.io/t/ec2-attributes/6483/2 "2015-04-16T12:27:22Z")

</div>

The node needs a 'hint' that it's in EC2. Namely this:

mkdir -p /etc/chef/ohai/hints  
touch /etc/chef/ohai/hints/ec2.json

then run chef-client and ohai will find all ec2 facts.

--Peter

On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz \<  
[guilherme.sft@gmail.com](mailto:guilherme.sft@gmail.com)\> wrote:

> Hi
> 
> I'm configuring an AWS auto scaling group in my infrastructure. Now, I am  
> writing a script to install and configure chef-client in the ec2 instances  
> launched automatically.
> 
> When I run the chef-client first time, it find my recipes and try to run  
> them. Some of the recipes uses attributes from ec2 (e.g.  
> node['ec2']['instance\_id'] ). But this attribute does not exist in the  
> instance. Some guy s in the irc channel told me to rerun ohai to reload the  
> attributes. For this, I added the following code in the recipe:
> 
> [ohai reload · GitHub](https://gist.github.com/jvanz/d8b73de8a0d4457e11e7)
> 
> But the problem persists. Is This what I should do?

--

_Peter Burkholder_ — Customer Success Engineer

Unavailability: No travel/PTO in April

301-204-5767 – [pburkholder@chef.io](mailto:pburkholder@chef.io) – \*my: \*Linkedin  
[http://www.linkedin.com/in/pburkholder](http://www.linkedin.com/in/pburkholder) Twitter  
[http://www.twitter.com/pburkholder](http://www.twitter.com/pburkholder) Cal  
[https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK](https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK)  
endar

_CHEF_

[CHEF.IO](http://CHEF.IO) [http://www.chef.io/](http://www.chef.io/)

TM

_[chef.io](http://chef.io)_ [http://www.chef.io/](http://www.chef.io/) Blog [http://www.chef.io/blog/](http://www.chef.io/blog/) Facebook  
[https://www.facebook.com/getchefdotcom](https://www.facebook.com/getchefdotcom) Twitter  
[https://twitter.com/chef](https://twitter.com/chef) Youtube [https://www.youtube.com/getchef](https://www.youtube.com/getchef)

---

<div class="post-metadata">

**Author:** ![Yoshi\_Spendiff](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/yoshi_spendiff/32/13_2.png) [@Yoshi\_Spendiff](https://discourse.chef.io/u/Yoshi_Spendiff)\
**Post date:** [April 16, 2015, 3:15pm UTC](https://discourse.chef.io/t/ec2-attributes/6483/3 "2015-04-16T15:15:41Z")

</div>

It's worth knowing that if you use knife ec2 to create instances then it  
makes the hint file for you, which is possibly why you never knew about it.

On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder [pburkholder@chef.io](mailto:pburkholder@chef.io)  
wrote:

> The node needs a 'hint' that it's in EC2. Namely this:
> 
> mkdir -p /etc/chef/ohai/hints  
> touch /etc/chef/ohai/hints/ec2.json
> 
> then run chef-client and ohai will find all ec2 facts.
> 
> --Peter
> 
> On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz \<  
> [guilherme.sft@gmail.com](mailto:guilherme.sft@gmail.com)\> wrote:
> 
> > Hi
> > 
> > I'm configuring an AWS auto scaling group in my infrastructure. Now, I am  
> > writing a script to install and configure chef-client in the ec2 instances  
> > launched automatically.
> > 
> > When I run the chef-client first time, it find my recipes and try to run  
> > them. Some of the recipes uses attributes from ec2 (e.g.  
> > node['ec2']['instance\_id'] ). But this attribute does not exist in the  
> > instance. Some guy s in the irc channel told me to rerun ohai to reload the  
> > attributes. For this, I added the following code in the recipe:
> > 
> > [ohai reload · GitHub](https://gist.github.com/jvanz/d8b73de8a0d4457e11e7)
> > 
> > But the problem persists. Is This what I should do?
> 
> --
> 
> _Peter Burkholder_ — Customer Success Engineer
> 
> Unavailability: No travel/PTO in April
> 
> 301-204-5767 – [pburkholder@chef.io](mailto:pburkholder@chef.io) – \*my: \*Linkedin  
> [http://www.linkedin.com/in/pburkholder](http://www.linkedin.com/in/pburkholder) Twitter  
> [http://www.twitter.com/pburkholder](http://www.twitter.com/pburkholder) Cal  
> [https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK](https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK)  
> endar
> 
> _CHEF_
> 
> [CHEF.IO](http://CHEF.IO) [http://www.chef.io/](http://www.chef.io/)
> 
> TM
> 
> _[chef.io](http://chef.io)_ [http://www.chef.io/](http://www.chef.io/) Blog [http://www.chef.io/blog/](http://www.chef.io/blog/)  
> Facebook [https://www.facebook.com/getchefdotcom](https://www.facebook.com/getchefdotcom) Twitter  
> [https://twitter.com/chef](https://twitter.com/chef) Youtube [https://www.youtube.com/getchef](https://www.youtube.com/getchef)

--  
Yoshi Spendiff  
Ops Engineer  
Indochino  
Mobile: +1 778 952 2025  
Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Jose\_Guilherme\_Vanz](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jose_guilherme_vanz/32/114_2.png) [@Jose\_Guilherme\_Vanz](https://discourse.chef.io/u/Jose_Guilherme_Vanz)\
**Post date:** [April 16, 2015, 7:23pm UTC](https://discourse.chef.io/t/ec2-attributes/6483/4 "2015-04-16T19:23:12Z")

</div>

I cannot use knife ec2. The instance is started by my auto scaling group.  
Anyway, the instructions sent by Peter solved my problem

Thank you

On Thu, Apr 16, 2015 at 12:16 PM Yoshi Spendiff \<  
[yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)\> wrote:

> It's worth knowing that if you use knife ec2 to create instances then it  
> makes the hint file for you, which is possibly why you never knew about it.
> 
> On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder [pburkholder@chef.io](mailto:pburkholder@chef.io)  
> wrote:
> 
> > The node needs a 'hint' that it's in EC2. Namely this:
> > 
> > mkdir -p /etc/chef/ohai/hints  
> > touch /etc/chef/ohai/hints/ec2.json
> > 
> > then run chef-client and ohai will find all ec2 facts.
> > 
> > --Peter
> > 
> > On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz \<  
> > [guilherme.sft@gmail.com](mailto:guilherme.sft@gmail.com)\> wrote:
> > 
> > > Hi
> > > 
> > > I'm configuring an AWS auto scaling group in my infrastructure. Now, I  
> > > am writing a script to install and configure chef-client in the ec2  
> > > instances launched automatically.
> > > 
> > > When I run the chef-client first time, it find my recipes and try to run  
> > > them. Some of the recipes uses attributes from ec2 (e.g.  
> > > node['ec2']['instance\_id'] ). But this attribute does not exist in the  
> > > instance. Some guy s in the irc channel told me to rerun ohai to reload the  
> > > attributes. For this, I added the following code in the recipe:
> > > 
> > > [ohai reload · GitHub](https://gist.github.com/jvanz/d8b73de8a0d4457e11e7)
> > > 
> > > But the problem persists. Is This what I should do?
> > 
> > --
> > 
> > _Peter Burkholder_ — Customer Success Engineer
> > 
> > Unavailability: No travel/PTO in April
> > 
> > 301-204-5767 – [pburkholder@chef.io](mailto:pburkholder@chef.io) – \*my: \*Linkedin  
> > [http://www.linkedin.com/in/pburkholder](http://www.linkedin.com/in/pburkholder) Twitter  
> > [http://www.twitter.com/pburkholder](http://www.twitter.com/pburkholder) Cal  
> > [https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK](https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK)  
> > endar
> > 
> > _CHEF_
> > 
> > [CHEF.IO](http://CHEF.IO) [http://www.chef.io/](http://www.chef.io/)
> > 
> > TM
> > 
> > _[chef.io](http://chef.io)_ [http://www.chef.io/](http://www.chef.io/) Blog [http://www.chef.io/blog/](http://www.chef.io/blog/)  
> > Facebook [https://www.facebook.com/getchefdotcom](https://www.facebook.com/getchefdotcom) Twitter  
> > [https://twitter.com/chef](https://twitter.com/chef) Youtube [https://www.youtube.com/getchef](https://www.youtube.com/getchef)
> 
> --  
> Yoshi Spendiff  
> Ops Engineer  
> Indochino  
> Mobile: +1 778 952 2025  
> Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Morgan\_Blackthorne](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/morgan_blackthorne/32/100_2.png) [@Morgan\_Blackthorne](https://discourse.chef.io/u/Morgan_Blackthorne)\
**Post date:** [April 16, 2015, 7:44pm UTC](https://discourse.chef.io/t/ec2-attributes/6483/5 "2015-04-16T19:44:36Z")

</div>

If you're doing it via autoscaling, you probably want to bake some  
automated registration into your AMI. At which point, I would suggest  
baking the hint file into said AMI as well.

--  
~_~ StormeRider ~_~

"Every world needs its heroes [...] They inspire us to be better than we  
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Thu, Apr 16, 2015 at 12:23 PM, José Guilherme Vanz \<  
[guilherme.sft@gmail.com](mailto:guilherme.sft@gmail.com)\> wrote:

> I cannot use knife ec2. The instance is started by my auto scaling group.  
> Anyway, the instructions sent by Peter solved my problem
> 
> Thank you
> 
> On Thu, Apr 16, 2015 at 12:16 PM Yoshi Spendiff \<  
> [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)\> wrote:
> 
> > It's worth knowing that if you use knife ec2 to create instances then it  
> > makes the hint file for you, which is possibly why you never knew about it.
> > 
> > On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder [pburkholder@chef.io](mailto:pburkholder@chef.io)  
> > wrote:
> > 
> > > The node needs a 'hint' that it's in EC2. Namely this:
> > > 
> > > mkdir -p /etc/chef/ohai/hints  
> > > touch /etc/chef/ohai/hints/ec2.json
> > > 
> > > then run chef-client and ohai will find all ec2 facts.
> > > 
> > > --Peter
> > > 
> > > On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz \<  
> > > [guilherme.sft@gmail.com](mailto:guilherme.sft@gmail.com)\> wrote:
> > > 
> > > > Hi
> > > > 
> > > > I'm configuring an AWS auto scaling group in my infrastructure. Now, I  
> > > > am writing a script to install and configure chef-client in the ec2  
> > > > instances launched automatically.
> > > > 
> > > > When I run the chef-client first time, it find my recipes and try to  
> > > > run them. Some of the recipes uses attributes from ec2 (e.g.  
> > > > node['ec2']['instance\_id'] ). But this attribute does not exist in the  
> > > > instance. Some guy s in the irc channel told me to rerun ohai to reload the  
> > > > attributes. For this, I added the following code in the recipe:
> > > > 
> > > > [ohai reload · GitHub](https://gist.github.com/jvanz/d8b73de8a0d4457e11e7)
> > > > 
> > > > But the problem persists. Is This what I should do?
> > > 
> > > --
> > > 
> > > _Peter Burkholder_ — Customer Success Engineer
> > > 
> > > Unavailability: No travel/PTO in April
> > > 
> > > 301-204-5767 – [pburkholder@chef.io](mailto:pburkholder@chef.io) – \*my: \*Linkedin  
> > > [http://www.linkedin.com/in/pburkholder](http://www.linkedin.com/in/pburkholder) Twitter  
> > > [http://www.twitter.com/pburkholder](http://www.twitter.com/pburkholder) Cal  
> > > [https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK](https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK)  
> > > endar
> > > 
> > > _CHEF_
> > > 
> > > [CHEF.IO](http://CHEF.IO) [http://www.chef.io/](http://www.chef.io/)
> > > 
> > > TM
> > > 
> > > _[chef.io](http://chef.io)_ [http://www.chef.io/](http://www.chef.io/) Blog [http://www.chef.io/blog/](http://www.chef.io/blog/)  
> > > Facebook [https://www.facebook.com/getchefdotcom](https://www.facebook.com/getchefdotcom) Twitter  
> > > [https://twitter.com/chef](https://twitter.com/chef) Youtube [https://www.youtube.com/getchef](https://www.youtube.com/getchef)
> > 
> > --  
> > Yoshi Spendiff  
> > Ops Engineer  
> > Indochino  
> > Mobile: +1 778 952 2025  
> > Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)

---

<div class="post-metadata">

**Author:** ![Jose\_Guilherme\_Vanz](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jose_guilherme_vanz/32/114_2.png) [@Jose\_Guilherme\_Vanz](https://discourse.chef.io/u/Jose_Guilherme_Vanz)\
**Post date:** [April 17, 2015, 1:05am UTC](https://discourse.chef.io/t/ec2-attributes/6483/6 "2015-04-17T01:05:37Z")

</div>

Yeah, is a good idea.

Thank you

On Thu, Apr 16, 2015 at 4:44 PM Morgan Blackthorne [stormerider@gmail.com](mailto:stormerider@gmail.com)  
wrote:

> If you're doing it via autoscaling, you probably want to bake some  
> automated registration into your AMI. At which point, I would suggest  
> baking the hint file into said AMI as well.
> 
> --  
> ~_~ StormeRider ~_~
> 
> "Every world needs its heroes [...] They inspire us to be better than we  
> are. And they protect from the darkness that's just around the corner."
> 
> (from Smallville Season 6x1: "Zod")
> 
> On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)
> 
> On Thu, Apr 16, 2015 at 12:23 PM, José Guilherme Vanz \<  
> [guilherme.sft@gmail.com](mailto:guilherme.sft@gmail.com)\> wrote:
> 
> > I cannot use knife ec2. The instance is started by my auto scaling group.  
> > Anyway, the instructions sent by Peter solved my problem
> > 
> > Thank you
> > 
> > On Thu, Apr 16, 2015 at 12:16 PM Yoshi Spendiff \<  
> > [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)\> wrote:
> > 
> > > It's worth knowing that if you use knife ec2 to create instances then it  
> > > makes the hint file for you, which is possibly why you never knew about it.
> > > 
> > > On Thu, Apr 16, 2015 at 5:27 AM, Peter Burkholder [pburkholder@chef.io](mailto:pburkholder@chef.io)  
> > > wrote:
> > > 
> > > > The node needs a 'hint' that it's in EC2. Namely this:
> > > > 
> > > > mkdir -p /etc/chef/ohai/hints  
> > > > touch /etc/chef/ohai/hints/ec2.json
> > > > 
> > > > then run chef-client and ohai will find all ec2 facts.
> > > > 
> > > > --Peter
> > > > 
> > > > On Thu, Apr 16, 2015 at 7:09 AM, José Guilherme Vanz \<  
> > > > [guilherme.sft@gmail.com](mailto:guilherme.sft@gmail.com)\> wrote:
> > > > 
> > > > > Hi
> > > > > 
> > > > > I'm configuring an AWS auto scaling group in my infrastructure. Now, I  
> > > > > am writing a script to install and configure chef-client in the ec2  
> > > > > instances launched automatically.
> > > > > 
> > > > > When I run the chef-client first time, it find my recipes and try to  
> > > > > run them. Some of the recipes uses attributes from ec2 (e.g.  
> > > > > node['ec2']['instance\_id'] ). But this attribute does not exist in the  
> > > > > instance. Some guy s in the irc channel told me to rerun ohai to reload the  
> > > > > attributes. For this, I added the following code in the recipe:
> > > > > 
> > > > > [ohai reload · GitHub](https://gist.github.com/jvanz/d8b73de8a0d4457e11e7)
> > > > > 
> > > > > But the problem persists. Is This what I should do?
> > > > 
> > > > --
> > > > 
> > > > _Peter Burkholder_ — Customer Success Engineer
> > > > 
> > > > Unavailability: No travel/PTO in April
> > > > 
> > > > 301-204-5767 – [pburkholder@chef.io](mailto:pburkholder@chef.io) – \*my: \*Linkedin  
> > > > [http://www.linkedin.com/in/pburkholder](http://www.linkedin.com/in/pburkholder) Twitter  
> > > > [http://www.twitter.com/pburkholder](http://www.twitter.com/pburkholder) Cal  
> > > > [https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK](https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK)  
> > > > endar
> > > > 
> > > > _CHEF_
> > > > 
> > > > [CHEF.IO](http://CHEF.IO) [http://www.chef.io/](http://www.chef.io/)
> > > > 
> > > > TM
> > > > 
> > > > _[chef.io](http://chef.io)_ [http://www.chef.io/](http://www.chef.io/) Blog [http://www.chef.io/blog/](http://www.chef.io/blog/)  
> > > > Facebook [https://www.facebook.com/getchefdotcom](https://www.facebook.com/getchefdotcom) Twitter  
> > > > [https://twitter.com/chef](https://twitter.com/chef) Youtube [https://www.youtube.com/getchef](https://www.youtube.com/getchef)
> > > 
> > > --  
> > > Yoshi Spendiff  
> > > Ops Engineer  
> > > Indochino  
> > > Mobile: +1 778 952 2025  
> > > Email: [yoshi.spendiff@indochino.com](mailto:yoshi.spendiff@indochino.com)
