<commit_before>Packer Vagrant S3 post-processor
================================

Uploads built Vagrant boxes to S3 and manages a manifest file for versioned boxes.

Installation
------------
Install the binary (you'll need ```git``` and ```go```):

```
$ go get github.com/lmars/packer-post-processor-vagrant-s3
```
Copy the plugin into packer.d directory:

```
$ mkdir $HOME/.packer.d/plugins
$ cp $GOPATH/bin/packer-post-processor-vagrant-s3 $HOME/.packer.d/plugins

```
Usage
-----

Add the post-processor to your packer template **after** the `vagrant` post-processor:

```json
{
  "variables": {
    "version":  "0.0.1"
    "box_name": "my-cool-project"
  },
  "builders": [ ... ],
  "provisioners": [ ... ],
  "post-processors": [
    [
      {
        "type": "vagrant"
        ...
      },
      {
        "type":     "vagrant-s3",
        "region": "us-east-1",
        "bucket":   "my-s3-bucket",
        "manifest": "vagrant/json/{{ user `box_name` }}.json",
        "box_name": "{{ user `box_name` }}",
        "box_dir":  "vagrant/boxes",
        "version":  "{{ user `version` }}"
      }
    ]
  ]
}
```
**NOTE:** The post-processors must be a **nested array** (i.e.: a Packer sequence definition) so that they run in order. See the [Packer template documentation](http://www.packer.io/docs/templates/post-processors.html) for more information.

The above will result in the following object created in S3, a manifest:

```
https://s3.amazonaws.com/my-s3-bucket/vagrant/json/my-cool-project.json
```

and a box:

```
https://s3.amazonaws.com/my-s3-bucket/vagrant/boxes/0.0.1/my-cool-project.box

```

By setting `box_dir` like this in your `template.json` file:

```
        "box_dir":  "vagrant/boxes/{{ user `box_name` }}",
```

Your can have your box version directories, nested underneath another directory named after your box.

```
https://s3.amazonaws.com/my-s3-bucket/vagrant/boxes/my-cool-project/0.0.1/my-cool-project.box

```

Configuration
-------------

All configuration properties are **required**, except where noted.
### region

The S3 region of the bucket (please see next section).

Valid values:

* us-east-1
* us-gov-west-1
* us-west-1
* us-west-2
* eu-west-1
* eu-central-1
* ap-southeast-1
* ap-southeast-2
* ap-northeast-1
* sa-east-1
* cn-north-1

### bucket
<commit_msg>Use a more complete example in the README<commit_after>Packer Vagrant S3 post-processor
================================

Uploads built Vagrant boxes to S3 and manages a manifest file for versioned boxes.

Installation
------------
Install the binary (you'll need ```git``` and ```go```):

```
$ go get github.com/lmars/packer-post-processor-vagrant-s3
```
Copy the plugin into packer.d directory:

```
$ mkdir $HOME/.packer.d/plugins
$ cp $GOPATH/bin/packer-post-processor-vagrant-s3 $HOME/.packer.d/plugins

```
Usage
-----

Add the post-processor to your packer template **after** the `vagrant` post-processor:

```json
{
  "variables": {
    "version":  "0.0.1",
    "box_organization": "my-organization",
    "box_name": "my-cool-project"
  },
  "builders": [ ... ],
  "provisioners": [ ... ],
  "post-processors": [
    [
      {
        "type": "vagrant"
        ...
      },
      {
        "type":     "vagrant-s3",
        "region": "us-east-1",
        "bucket":   "my-s3-bucket",
        "manifest": "vagrant/json/{{ user `box_organization` }}/{{ user `box_name` }}.json",
        "box_dir":  "vagrant/boxes/{{ user `box_organization` }}/{{ user `box_name` }}",
        "box_name": "{{ user `box_organization` }}{{ user `box_name` }}",
        "version":  "{{ user `version` }}"
      }
    ]
  ]
}
```

**NOTE:** The post-processors must be a **nested array** (i.e.: a Packer sequence definition) so that they run in order. See the [Packer template documentation](http://www.packer.io/docs/templates/post-processors.html) for more information.

The above will result in the following objects being created in S3:

```
https://s3.amazonaws.com/my-s3-bucket/vagrant/json/my-organization/my-cool-project.json
https://s3.amazonaws.com/my-s3-bucket/vagrant/boxes/my-organization/my-cool-project/0.0.1/packer_virtualbox-iso_virtualbox.box
```

You can now use point your `Vagrantfile` to the manifest by using something like this:

```ruby
Vagrant.configure(2) do |config|
  config.vm.box = "my-organization/my-cool-project"
  config.vm.box_url = "https://s3.amazonaws.com/my-s3-bucket/vagrant/json/my-organization/my-cool-project.json"
end
```

When pointing the `Vagrantfile` at a manifest instead of directly at a box you retain traditional features such as 
versioning and multiple providers.

Configuration
-------------

All configuration properties are **required**, except where noted.
### region

The S3 region of the bucket (please see next section).

Valid values:

* us-east-1
* us-gov-west-1
* us-west-1
* us-west-2
* eu-west-1
* eu-central-1
* ap-southeast-1
* ap-southeast-2
* ap-northeast-1
* sa-east-1
* cn-north-1

### bucket

{'fraction_non_alphanumeric': 0.1861777150916784, 'fraction_numerical': 0.013701390288132179, 'mean_word_length': 3.1160862354892207, 'pattern_counts': {'":': 30, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4055629', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1728, 'n_words': 413}