· 7 years ago · Jun 21, 2018, 12:32 AM
1{
2 "variables": {
3 "windows_admin_user": "Administrator",
4 "vpc": "vpc-12345678",
5 "subnet": "subnet-2ab73a62",
6 "aws_region": "eu-west-1",
7 "aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
8 "aws_secret_key": "{{env `AWS_SECRET_KEY`}}",
9 "aws_profile": "{{env `AWS_PROFILE`}}",
10 "aws_mfa_code": "{{env `AWS_MFA_CODE`}}",
11 "ami_name": "windows-server-AMI-{{isotime \"02-Jan-06 03_04_05\"}}"
12 },
13 "builders": [{
14 "name": "AMI Windows Builder",
15 "type": "amazon-ebs",
16 "region": "{{user `aws_region`}}",
17 "access_key": "{{user `aws_access_key`}}",
18 "secret_key": "{{user `aws_secret_key`}}",
19 "mfa_code": "{{user `aws_mfa_code`}}",
20 "profile": "{{ user `aws_profile`}}",
21 "source_ami_filter": {
22 "filters": {
23 "virtualization-type": "hvm",
24 "name": "Windows_Server-2012-R2_RTM-English-64Bit-Base-*",
25 "root-device-type": "ebs"
26 },
27 "owners": ["801119661308"],
28 "most_recent": true
29 },
30 "instance_type": "t2.micro",
31 "ami_name": "{{user `ami_name` | clean_ami_name}}",
32 "tags": {
33 "Name": "{{user `ami_name`}}"
34 },
35 "run_tags": {
36 "Name": "{{user `ami_name`}}"
37 },
38 "run_volume_tags": {
39 "Name": "{{user `ami_name`}}"
40 },
41 "snapshot_tags": {
42 "Name": "{{user `ami_name`}}"
43 },
44 "ami_description": "AWS Windows Server AMIs reloaded",
45 "associate_public_ip_address": "false",
46 "vpc_id": "{{user `vpc`}}",
47 "subnet_id": "{{user `subnet`}}",
48 "user_data_file": "scripts/bootstrapping.ps1",
49 "communicator": "winrm",
50 "winrm_username": "{{user `windows_admin_user`}}",
51 "winrm_timeout": "30m",
52 "winrm_port": 5986,
53 "winrm_use_ssl": true,
54 "winrm_insecure": true,
55 "ssh_interface": "private_ip",
56 "launch_block_device_mappings": [
57 {
58 "device_name": "/dev/sda1",
59 "volume_size": 100,
60 "volume_type": "gp2",
61 "delete_on_termination": true
62 }
63 ],
64 "ami_block_device_mappings": [
65 {
66 "device_name": "/dev/sdb",
67 "virtual_name": "ephemeral0"
68 }
69 ]
70 }],
71 "provisioners": [
72 {
73 "type": "powershell",
74 "scripts": [
75 "./scripts/EC2Config.ps1",
76 "./scripts/BundleConfig.ps1",
77 "./scripts/SetUpDevTools.ps1"
78 ]
79 },
80 {
81 "type": "windows-restart"
82 }
83 ]
84}