{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": "",
    "source_ami": "",
    "ami_tag": "",
    "cookbook_name": ""
  },

  "builders": [
    {
      "type": "amazon-ebs",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "region": "us-east-1",
      "source_ami": "{{user `source_ami`}}",
      "instance_type": "t2.micro",
      "ssh_username": "ubuntu",
      "ami_name": "{{user `ami_tag`}} {{timestamp}}",
      "tags": {
        "{{user `ami_tag`}}": "{{timestamp}}",
        "created_at": "{{isotime}}"
      }
    }
  ],
  "provisioners": [
    {
      "type": "chef-solo",
      "cookbook_paths": ["cookbooks", "site-cookbooks"],
      "run_list": ["{{user `cookbook_name`}}"],
      "skip_install": true,
      "data_bags_path": "data_bags",
      "encrypted_data_bag_secret_path": "/etc/chef/encrypted_data_bag_secret"
    }
  ]
}

{
  "variables": {
    "aws_access_key": "",
    "aws_secret_key": "",
    "source_ami": "",
    "ami_tag": "",
    "cookbook_name": ""
  },

  "builders": [
    {
      "type": "amazon-ebs",
      "access_key": "{{user `aws_access_key`}}",
      "secret_key": "{{user `aws_secret_key`}}",
      "region": "us-east-1",
      "source_ami": "{{user `source_ami`}}",
      "instance_type": "t2.micro",
      "ssh_username": "ubuntu",
      "ami_name": "{{user `ami_tag`}} {{timestamp}}",
      "tags": {
        "{{user `ami_tag`}}": "{{timestamp}}",
        "created_at": "{{isotime}}",
        "parent_ami": "{{user `source_ami`}}"
      }
    }
  ],
  "provisioners": [
    {
      "type": "chef-solo",
      "cookbook_paths": ["cookbooks", "site-cookbooks"],
      "run_list": ["{{user `cookbook_name`}}"],
      "skip_install": true,
      "data_bags_path": "data_bags",
      "encrypted_data_bag_secret_path": "/etc/chef/encrypted_data_bag_secret"
    }
  ]
}

Tag AMIs with their parent ami
Tag AMIs with their parent ami
