# Continuous Windows AMI Builds

**URL:** <https://awshq.com/t/continuous-windows-ami-builds/433>\
**Category:** AWS Compute Discussion\
**Created:** [April 29, 2014, 10:12pm UTC](https://awshq.com/t/continuous-windows-ami-builds/433 "2014-04-29T22:12:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![myoung34](https://awshq.com/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@myoung34](https://awshq.com/u/myoung34)\
**Post date:** [April 29, 2014, 10:12pm UTC](https://awshq.com/t/continuous-windows-ami-builds/433/1 "2014-04-29T22:12:06Z")

</div>

Has anyone had any luck building out AMIs for .NET platforms at AWS?

Let’s simplify my question:

1. We have a linux platform. Jenkins sees a change to the code, runs tests, builds an RPM, uploads it to Pulp. That package is managed by Puppet+Foreman. AWS Instances look for a change to that Pulp repo. New package seen, installed, good to go.
2. We have a .NET platform. Teamcity sees changes, runs tests, etc and builds nuget packages. When we want to release, we create an Windows AWS instance, install octopus deploy tentacle on it, then create a release and deploy it out, then create an AMI from that as version x.y.z.

So now, we want to deploy an ‘environment’ of these 2 nodes. I use cloudformation. Spins up a Linux AMI with some pre-requisites, installs Puppet, gets Foreman/the master to sign it and applies it, good to go. Completely automated.

I’m looking for something as good as that for Windows that requires no intervention. My Idea would be to create a ‘release’ in Teamcity that loads up a Windows AMI, does the octopus thing, then builds the AMI without me having to.

Anyone done anything similar? Anyone done anything not similar that might be useful?

* * *

**Related discussions:**

- [How does ‘no capacity block’ work when launching an ec2 instance? (p5en.48xlarge)](https://awshq.com/t/how-does-no-capacity-block-work-when-launching-an-ec2-instance-p5en-48xlarge/21290)
- [Amazon EC2 introduces application status checks](https://awshq.com/t/amazon-ec2-introduces-application-status-checks/21607)
- [AWS finally updates T4g: new T9g instances powered by Graviton5](https://awshq.com/t/aws-finally-updates-t4g-new-t9g-instances-powered-by-graviton5/21776)
- [I’m an AWS newbie. If I totally hose an EC2 instance, can I just restore a snapshot and be like nothing happened?](https://awshq.com/t/im-an-aws-newbie-if-i-totally-hose-an-ec2-instance-can-i-just-restore-a-snapshot-and-be-like-nothing-happened/12245)
- [Need an optimized sandbox setup for coding agents](https://awshq.com/t/need-an-optimized-sandbox-setup-for-coding-agents/21770)

---

<div class="post-metadata">

**Author:** ![nofuckingwaydude](https://awshq.com/letter_avatar_proxy/v4/letter/n/71e660/32.png) [@nofuckingwaydude](https://awshq.com/u/nofuckingwaydude)\
**Post date:** [April 29, 2014, 10:44pm UTC](https://awshq.com/t/continuous-windows-ami-builds/433/2 "2014-04-29T22:44:17Z")

</div>

Interesting, I’d like to know about this too.

---

<div class="post-metadata">

**Author:** ![stikko](https://awshq.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@stikko](https://awshq.com/u/stikko)\
**Post date:** [April 30, 2014, 12:40am UTC](https://awshq.com/t/continuous-windows-ami-builds/433/3 "2014-04-30T00:40:35Z")

</div>

[ec2Config](http://aws.amazon.com/developertools/5562082477397515) will execute PowerShell scripts if you put them in UserData surrounded by . You can use that to get things installed/updated, but then it could be a matter of timing to figure out when the instance is ready.

---

<div class="post-metadata">

**Author:** ![myoung34](https://awshq.com/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@myoung34](https://awshq.com/u/myoung34)\
**Post date:** [April 30, 2014, 12:45am UTC](https://awshq.com/t/continuous-windows-ami-builds/433/4 "2014-04-30T00:45:51Z")

</div>

> [@stikko](#):
>
> [ec2Config](http://aws.amazon.com/developertools/5562082477397515) will execute PowerShell scripts if you put them in UserData surrounded by . You can use that to get things installed/updated, …

I have UserData set up right now, I was just hoping to do it with as little intervention as possible (was hoping there was a windows container such as Docker).

My thoughts on how to do it when I approach it:

1. Hit the ‘release’ button on teamcity
2. Teamcity uses its EC2 setup to launch a windows instance with a known elastic IP.
3. The tricky part I’m hoping to get some thoughts on: How can Teamcity at this point, get into the AMI instance that was spun up in 2. Possibly something that launches a cloudformation template with parameters.
4. The Cloudformation template from 3 + UserData would install the tentacle and:
5. Also unsure about this step: the tentacle needs to be auto-accepted from the Octopus master.
6. TeamCity/Octopus pushes the NuGet packages into the master
7. The remaining Powershell is run to do final configurations
8. Teamcity sees a success, possibly runs some smoke tests
9. Teamcity builds and AMI (no clue on how to do this with current software)

---

<div class="post-metadata">

**Author:** ![scmccart](https://awshq.com/letter_avatar_proxy/v4/letter/s/5f8ce5/32.png) [@scmccart](https://awshq.com/u/scmccart)\
**Post date:** [April 30, 2014, 2:57am UTC](https://awshq.com/t/continuous-windows-ami-builds/433/5 "2014-04-30T02:57:33Z")

</div>

> [@myoung34](#):
>
> I have UserData set up right now, I was just hoping to do it with as little intervention as possible (was hoping there was a windows container such as Docker). My thoughts on how to do it when I approach it: 1. Hit the …

For 3, I use WinRM - it takes a bit of configuration but once working you can simply use powershell’s Invoke-Command (or any other WinRM client) to have the instance execute any script you would like.

The AWS cmdlets make it easy to spin an instance up, get its address and password, run a script via WinRM (using Invoke-Command + address + password), then stop the instance and take an image.

---

<div class="post-metadata">

**Author:** ![burning1rr](https://awshq.com/letter_avatar_proxy/v4/letter/b/58f4c7/32.png) [@burning1rr](https://awshq.com/u/burning1rr)\
**Post date:** [April 30, 2014, 3:08am UTC](https://awshq.com/t/continuous-windows-ami-builds/433/6 "2014-04-30T03:08:44Z")

</div>

For automated AMI creation, Packer is your best bet. Creation of Linux AMIs is a snap, though I haven’t done it with windows, I have no reason to expect it would be any more difficult.

Packer supports a number of CFM systems; you can use Puppet Powershell, ETC to build your configs.

---

<div class="post-metadata">

**Author:** ![myoung34](https://awshq.com/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@myoung34](https://awshq.com/u/myoung34)\
**Post date:** [April 30, 2014, 3:16am UTC](https://awshq.com/t/continuous-windows-ami-builds/433/7 "2014-04-30T03:16:31Z")

</div>

> [@burning1rr](#):
>
> For automated AMI creation, Packer is your best bet. Creation of Linux AMIs is a snap, though I haven’t done it with windows, I have no reason to expect it would be any more difficult. Packer supports a number of CFM …

I’ll look into this next I think

---

<div class="post-metadata">

**Author:** ![CpuID](https://awshq.com/letter_avatar_proxy/v4/letter/c/8baadc/32.png) [@CpuID](https://awshq.com/u/CpuID)\
**Post date:** [April 30, 2014, 10:20am UTC](https://awshq.com/t/continuous-windows-ami-builds/433/8 "2014-04-30T10:20:53Z")

</div>

> [@burning1rr](#):
>
> For automated AMI creation, Packer is your best bet. Creation of Linux AMIs is a snap, though I haven’t done it with windows, I have no reason to expect it would be any more difficult. Packer supports a number of CFM …

Definitely, packer ftw

---

<div class="post-metadata">

**Author:** ![Cloudnexa-on-AWS](https://awshq.com/letter_avatar_proxy/v4/letter/c/df788c/32.png) [@Cloudnexa-on-AWS](https://awshq.com/u/Cloudnexa-on-AWS)\
**Post date:** [June 10, 2014, 2:13pm UTC](https://awshq.com/t/continuous-windows-ami-builds/433/9 "2014-06-10T14:13:06Z")

</div>

Packer is the best I’ve come up with as well. Here’ a link.  
[http://www.packer.io/docs/builders/amazon.html](http://www.packer.io/docs/builders/amazon.html)

---

<div class="post-metadata">

**Author:** ![myoung34](https://awshq.com/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@myoung34](https://awshq.com/u/myoung34)\
**Post date:** [June 10, 2014, 8:52pm UTC](https://awshq.com/t/continuous-windows-ami-builds/433/10 "2014-06-10T20:52:13Z")

</div>

> [@Cloudnexa-on-AWS](#):
>
> Packer is the best I’ve come up with as well. Here’ a link. [http://www.packer.io/docs/builders/amazon.html](http://www.packer.io/docs/builders/amazon.html)

What I’ve got right now:

- Teamcity runs a Rakefile, which uses the aws-sdk to spin up a windows AMI
  - The windows AMI has a userdata section that gets octopus to accept it with some roles, etc
  - Teamcity then runs an “Octopus Release” step which deploys a version to the windows AMI

What I’m working on for the next few days is the next few steps:

- Either packer or my own thing will use EC2Config.exe and create an AMI of the box that was bootstrapped via octopus.
  - ???
  - Profit.

---

<div class="post-metadata">

**Author:** ![myoung34](https://awshq.com/letter_avatar_proxy/v4/letter/m/dc4da7/32.png) [@myoung34](https://awshq.com/u/myoung34)\
**Post date:** [June 12, 2014, 1:16pm UTC](https://awshq.com/t/continuous-windows-ami-builds/433/11 "2014-06-12T13:16:54Z")

</div>

> [@Cloudnexa-on-AWS](#):
>
> Packer is the best I’ve come up with as well. Here’ a link. [http://www.packer.io/docs/builders/amazon.html](http://www.packer.io/docs/builders/amazon.html)

After some discovery, turns out Packer won’t work quite yet for me. I’d like to avoid SSH to windows hosts, which is the only way in the latest stable. There’s a PR right now to add WinRM support, but it currently only supports certain builders. Once it’s approved I might look at mimicking the work for the Amazon builder, but until then Packer isn’t quite what I’ll be able to use.

PR: [https://github.com/mitchellh/packer/pull/1175](https://github.com/mitchellh/packer/pull/1175)
