Commit Graph

618 Commits

Author SHA1 Message Date
Rickard von Essen 96e9a8e6e9 Removed default value for ssh_username 2016-11-17 22:30:34 +01:00
Arthur Burkart 2e65867cba Closes #3908: Adds snapshot tag overrides
This commit adds the ability to configure unique tags on snapshots
that are separate from the tags defined on the AMI. Anything applied
to the AMI will also be applied to the snapshots, but `snapshot_tags`
will override and append tags to the tags already applied to the snapshots
2016-11-15 23:16:27 -05:00
Matthew Hooker 9a91ae4e8f
fix new session error when creating cred chain.
the old and deprecated method won't error and so is safe to use
even if we're not in amazon.
2016-11-14 11:39:22 -08:00
Matthew Hooker d81c06765d
fix go vet issue.
closes #4130
2016-11-07 10:17:53 -08:00
Matthew Hooker f3f5f89fe6 Merge pull request #4096 from mitchellh/filterday
builder/amazon-ebs: show ami id found from filter
2016-11-02 12:25:46 -07:00
Matthew Hooker 60c459d6c8 Merge pull request #4098 from mitchellh/newsession
aws-sdk: use session.NewSession
2016-11-02 12:25:14 -07:00
Matthew Hooker 9bc23ea512 Merge pull request #4099 from mitchellh/waitfail
Waitfail
2016-11-02 12:21:51 -07:00
James Nugent 36c09af992 builder/amazon: Add tests for the `ebs-volume` builder
These smoke tests are effectively a mirror of the EBS builder tests.
2016-11-02 12:56:39 -04:00
James Nugent b1ff8c3bfc builder/amazon: Add `ebs-volume` builder
This commit adds a builder that works like EBS builders, except does not
create an AMI, and instead is intended to create EBS volumes in an
initialized state. For example, the following template can be used to
create and export a set of 3 EBS Volumes in a ZFS zpool named `data` for
importing by instances running production systems:

```
{
	"variables": {
		"aws_access_key_id": "{{ env `AWS_ACCESS_KEY_ID` }}",
		"aws_secret_access_key": "{{ env `AWS_SECRET_ACCESS_KEY` }}",
		"region": "{{ env `AWS_REGION` }}",
		"source_ami": "{{ env `PACKER_SOURCE_AMI` }}",
		"vpc_id": "{{ env `PACKER_VPC_ID` }}",
		"subnet_id": "{{ env `PACKER_SUBNET_ID` }}"
	},
	"builders": [{
		"type": "amazon-ebs-volume",
		"access_key": "{{ user `aws_access_key_id` }}",
		"secret_key": "{{ user `aws_secret_access_key` }}",
		"region": "{{user `region`}}",
		"spot_price_auto_product": "Linux/UNIX (Amazon VPC)",

		"ssh_pty": true,
		"instance_type": "t2.medium",
		"vpc_id": "{{user `vpc_id` }}",
		"subnet_id": "{{user `subnet_id` }}",
		"associate_public_ip_address": true,
		"source_ami": "{{user `source_ami` }}",
		"ssh_username": "ubuntu",
		"ssh_timeout": "5m",

		"ebs_volumes": [
			{
				"device_name": "/dev/xvdf",
				"delete_on_termination": false,
				"volume_size": 10,
				"volume_type": "gp2",
				"tags": {
					"Name": "TeamCity-Data1",
					"zpool": "data",
					"Component": "TeamCity"
				}
			},
			{
				"device_name": "/dev/xvdg",
				"delete_on_termination": false,
				"volume_size": 10,
				"volume_type": "gp2",
				"tags": {
					"Name": "TeamCity-Data2",
					"zpool": "data",
					"Component": "TeamCity"
				}
			},
			{
				"device_name": "/dev/xvdh",
				"delete_on_termination": false,
				"volume_size": 10,
				"volume_type": "gp2",
				"tags": {
					"Name": "TeamCity-Data3",
					"zpool": "data",
					"Component": "TeamCity"
				}
			}
		]
	}],
	"provisioners": [
	{
		"type": "shell",
		"start_retry_timeout": "10m",
		"inline": [
			"DEBIAN_FRONTEND=noninteractive sudo apt-get update",
			"DEBIAN_FRONTEND=noninteractive sudo apt-get install -y zfs",
			"lsblk",
			"sudo parted /dev/xvdf --script mklabel GPT",
			"sudo parted /dev/xvdg --script mklabel GPT",
			"sudo parted /dev/xvdh --script mklabel GPT",
			"sudo zpool create -m none data raidz xvdf xvdg xvdh",
			"sudo zpool status",
			"sudo zpool export data",
			"sudo zpool status"
		]
	}
	]
}
```

StepModifyInstance and StepStopInstance are now shared between EBS and
EBS-Volume builders - move them into the AWS common directory and rename
them to indicate that they only apply to EBS-backed builders.
2016-11-02 12:56:39 -04:00
Matthew Hooker d47e47cf1f rewrite to not use private aws package 2016-11-01 18:29:18 -07:00
Matthew Hooker c4c46c349e implement security group waiter 2016-11-01 18:10:42 -07:00
Matthew Hooker 970b37077e Merge pull request #4050 from jen20/ssh-agent
builder/amazon: Allow use of local SSH Agent
2016-11-01 17:27:37 -07:00
Matthew Hooker 48bdae93d1 aws-sdk: use session.NewSession 2016-11-01 15:53:04 -07:00
Matthew Hooker 83b57b98ac show ami id found from filter 2016-11-01 15:26:43 -07:00
Matthew Hooker d920b3fbf4 run gofmt 2016-11-01 14:08:04 -07:00
Matthew Hooker 0dd7d7ff3b fix error message 2016-10-31 16:44:18 -07:00
Ganesh kumar Sankaran b9c6139d67 AWS async operations sometimes takes long times, if there are multiple parallel builds, polling at 2 second frequency will exceed the request limit. Allow 2 seconds to be overwritten with AWS_POLL_DELAY_SECONDS 2016-10-31 16:44:18 -07:00
Rickard von Essen d66490ebfd
Properly cleanup AWS temporary key pairs
Closes #4057 - Amazon key pair no longer cleaned up at end of build
2016-10-27 23:06:13 +02:00
Rickard von Essen d16d5d9686 Merge pull request #3817 from ChrisLundquist/dynamic-source-ami
Dynamic source ami
2016-10-25 21:24:41 +02:00
Richard Owen adddc60a1d Fix typo in encrypted ami step log message 2016-10-25 16:01:01 +01:00
James Nugent 395d88941c amazon: Allow SSH Agent auth for existing key pair
This commit allows SSH Agent authentication to be used with an existing
key pair defined in AWS.
2016-10-23 22:26:14 -05:00
James Nugent 7425fef2c7 builder/amazon: Allow use of local SSH Agent
This commit adds an option to use the local SSH Agent to authenticate
connections to source instances started by the the EBS and Instance
Store builders.

This is of use when the source AMI _already_ has configuration for
authorized SSH keys - for example if one uses an SSH certificate
authority.

A further extension (not implemented in this commit) is to allow SSH
agent use with a pre-defined key pair, in order to allow keys with
passphrases to be used without giving the passphrase to Packer.
2016-10-23 21:43:47 -05:00
Asif R Choudhury 48d94342ba Add us-east-2 (Ohio) AWS region 2016-10-17 21:31:41 -05:00
Rickard von Essen c273bd6beb Merge pull request #3789 from jeremy-asher/amazon-ebs-delete-volumes-on-failure
clean up EBS volumes on failure
2016-10-15 14:57:15 +02:00
Rickard von Essen 0be3034e82 Merge pull request #3953 from rickard-von-essen/amz-ssh
builder/amazon: Allow using ssh_private_key_file and ssh_password
2016-10-03 10:22:15 +02:00
Rickard von Essen acc2689b49
builder/amazon: Allow using ssh_private_key_file and ssh_password
This adds support for using amazon-ebs/amazon-instance builder without
a keypair. If a ssh_private_key_file is supplied without a
ssh_keypair_name no temporary ssh keypair is created. If ssh_password is
used no temporary ssh keypair is created and the password is used when
trying to connect.

Closes #2301
Closes #3156
2016-10-02 22:20:36 +02:00
Rickard von Essen cffc8e892c Merge pull request #3382 from ahamidi/encrypted-boot-volume
Create AMI with encrypted boot volume
2016-10-02 01:02:43 +02:00
Chris Lundquist 9379cbc5d9 [dynamic-source-ami] support instance builder too 2016-10-01 23:01:01 +00:00
Chris Lundquist ab3500b45c [dynamic-source-ami] support chroot builder 2016-10-01 22:56:09 +00:00
Chris Lundquist 1b4895c684 Merge remote-tracking branch 'origin/master' into dynamic-source-ami 2016-10-01 22:20:17 +00:00
Matthew Hooker a9abe43325 builder/amazon: add retry login when creating tags.
also move Retry from builder/googlecompute/common to common/retry
2016-09-28 18:22:31 -07:00
Rickard von Essen 13c9db5dd5 Merge pull request #3885 from orivej/on-error
Add -on-error command line argument to allow preserving artifacts on builder errors
2016-09-20 12:28:14 +02:00
Jeremy Asher aea05f6485 fix nil pointer dereference in amazon-chroot
The refactor of StepRegisterAmi to add the from_scratch parameter
incorrectly replaced iteration over image.BlockDeviceMappings with
iteration over the new mapping array when not using from_scratch.  This
fixes the regression and renames the parameters to newMappings and
mappings for better clarity.
2016-09-16 18:35:36 -07:00
Orivej Desh 6762965696 Add -on-error command line argument to allow preserving artifacts on builder errors
Resolves #409
2016-09-16 12:15:00 +00:00
Rickard von Essen 3b47893eb8
builder/amazon: reverted wrongly modified ssh_test's. 2016-09-14 20:26:09 +02:00
Rickard von Essen 067155c344
builder/amazon: guard aginst empty/nil PrivateIpAddress and updated tests. 2016-09-14 00:16:09 +02:00
Rickard von Essen 7f4bee737c Merge pull request #3752 from tarrall/issue3751-ssh-privateip-classic
builder/amazon: Honor ssh_private_ip flag in EC2-Classic, not just VPC
2016-09-13 22:54:00 +02:00
Rickard von Essen 120b60ae37 Merge pull request #3865 from dpiddy/amazon-ssh-retry-fix
amazon/common/ssh: fix saving of instance to state
2016-09-12 15:04:35 +02:00
Dan Peterson c7af9a67bc amazon/common/ssh: fix saving of instance to state
Fixes #3496
2016-09-09 10:16:53 -03:00
Jeremy Asher 1c392b23f9 generate warnings for unused options with from_scratch 2016-09-03 12:32:43 -07:00
Jeremy Asher ef0c7543e1 add amazon-chroot post mount commands
This adds an additional PostMountCommands step to the amazon-chroot
builder which executes after the volume is mounted, but before the
extra chroot mounts and copy step.
2016-09-03 12:32:41 -07:00
Jeremy Asher 5e8b697a76 add from_scratch option to amazon-chroot builder
This provides an alternate mode for the amazon-chroot builder which uses
a blank volume to build the image.  It adds StepPreMountCommands to
permit partitioning and format commands to be executed before mounting
the new volume.
2016-09-03 12:28:22 -07:00
Jeremy Asher 85ae04bb75 split up BlockDevices in amazon/common
This breaks up the two options provided by BlockDevices into separate
structs to allow only one of them to be used by the amazon-chroot
builder.
2016-09-03 09:58:45 -07:00
Chris Lundquist defdd1ecf3 Merge remote-tracking branch 'origin/master' into dynamic-source-ami 2016-09-02 01:43:03 +00:00
Rickard von Essen ba629922c6 Merge pull request #3662 from ryansb/boost-spot-bid
(AWS Spot) Add 0.5 cents to discovered spot price
2016-08-27 03:18:59 +02:00
Krzysztof Wilczynski d01fb65dcf Fix. Use temporary_key_pair_name when specified. (#3739)
Fix: Use temporary_key_pair_name when specified.

This is to fix an issue where the temporary_key_pair_name configuration option
for amazon-ebs and amazon-instance builders would be ignored and replaced with
an automatically generated value using UUID, even when the option was explicitly
specified.

Remove space from the auto-generated SSH key-pair name.

Resolves #3736
2016-08-25 09:17:57 +02:00
Chris Lundquist 3cc8d35450 [dynamic-source-ami] fix old key name in error message 2016-08-21 00:58:01 +00:00
Chris Lundquist b4d20706ce [dynamic-source-ami] add some very basic tests 2016-08-21 00:29:51 +00:00
Chris Lundquist 57e7a1a3e6 [dynamic-source-ami] fix lint error 2016-08-21 00:07:58 +00:00
Chris Lundquist 95afaa58ca [dynamic-source-ami] rename to source_ami_filter 2016-08-20 23:34:22 +00:00
Chris Lundquist 0e248f1516 [dynamic-source-ami] make most_recent work 2016-08-20 23:08:45 +00:00
Chris Lundquist ec1abb9448 [dynamic-source-ami] proof of concept 2016-08-20 18:58:36 +00:00
Jeremy Asher 6130b8588d remove check for AMIs when deleting vols
This removes the unnecessary check for AMIs before cleaning up volumes.
AMIs will exist on a successful run, but not when a build fails after
instance creation (during provisioning for example).  The following
check for instance being nil should be sufficient.
2016-08-08 14:16:43 -07:00
Ali Hamidi c6a527dc46 throw error if encrypted ami is shared 2016-07-29 15:01:24 -07:00
Ali Hamidi 1cecda639a add encrypted boot volume acceptance test 2016-07-29 15:01:24 -07:00
Ali Hamidi 902ae375b3 delete unencrypted snapshot 2016-07-29 15:01:24 -07:00
Ali Hamidi 53b3867c50 allow packer to create an encrypted copy of the AMI 2016-07-29 15:01:24 -07:00
Robert Tarrall 94bf981d3b Honor ssh_private_ip flag in EC2-Classic, not just VPC
VpcId will be nil in Classic, but we may still wish to ssh to the
instance's private IP address -- if for example we are using security
groups to block SSH access via the public IP.
2016-07-26 08:15:44 -06:00
Chris Bednarski c0b637b0c5 Merge pull request #3733 from envato/no-shutdown-behaviour-instance-backed
No shutdown behaviour instance backed
2016-07-19 01:49:05 -07:00
Ricard Clau 172a1c7a57 add source ami to output 2016-07-07 00:05:59 +01:00
Chris Bednarski ee5c5260a4 Merge pull request #3663 from liv3d/add_ap-south-1
Add support for ap-south-1 in AWS
2016-07-06 14:09:24 -07:00
Chris Bednarski 443ffd68f2 Added explicit error when SG is not working 2016-07-02 15:48:51 -07:00
Dan Offord 4428079a68 Add support for ap-south-1 in AWS
Amazon recently announced support for ap-south-1 in Mumbai, adding this
to the list of known regions to Packer
2016-06-29 15:44:02 +01:00
Ryan S. Brown c68ddef4e9 (AWS Spot) Add 0.5 cents to discovered spot price
Related to #2979 , in volatile spot markets the automatic price can
cause your instances to be evicted if the spot price rises. This change
adds one half a cent to your bid to protect against small amounts of
price volatility.
2016-06-29 07:00:21 -04:00
Mike LoSapio 080806243e Added a hook to query the security groups before launching the instance - seems to catch the AWS eventual consistency nicely 2016-06-27 16:20:53 -04:00
Patrick Robinson 40bd45764c Only set InstanceInititatedShutdownBehavior on ebs instances 2016-06-27 10:28:54 +10:00
Chris Bednarski ab9621ab7d Added aws shutdown_behavior to the changelog 2016-06-14 14:34:01 -07:00
Patrick Robinson f361e1d894 Precompile regex 2016-06-14 14:29:10 -07:00
Patrick Robinson b1d6d28a90 Add unit tests for shutdown behaviour 2016-06-14 14:29:10 -07:00
Patrick Robinson a9f914ea97 Add shutdown_behaviour option
This means an instance will terminate upon shutdown.
2016-06-14 14:29:10 -07:00
owjjh 658fadbc53 changing if conditionals to be ! instead of == false 2016-06-07 09:21:43 -04:00
owjjh d489ce9904 make fmt run 2016-06-06 14:37:09 -04:00
owjjh de5b69a8df Adding ability to skip region validation when using AWS 2016-06-06 14:17:12 -04:00
Chris Chalfant 601b833aaa style and documentation changes per PR review comments 2016-03-15 08:01:20 -04:00
Chris Chalfant 8163e16e02 gofmt code 2016-03-14 13:49:42 -04:00
Chris Chalfant 72a7123a0b Add option to tell packer not to stop the instance
It is sometimes desirable to sysprep a windows machine before creating
an EC2 image. The AWS-approved way to do this is to run
ec2configservice.exe -sysprep and let ec2configservice shut down the instance.
This change adds an option to disable the stop instance call issued by packer
so that the user can control when the machine is stopped.
2016-03-14 12:54:03 -04:00
Chris Bednarski d0ab8658bc Create a session for EC2RoleProvider; prevents crash; fixes #3123 2016-02-19 17:10:05 -08:00
Vasiliy Tolstov feee19e4ed file provisioner improvements
* allow specify source/destination as dir
* allow specify many files as source

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-02-12 11:48:28 -08:00
Chris Bednarski 4458de4ea0 Reformat 2016-02-11 23:53:40 -08:00
Chris Bednarski 765ec5cf39 Merge pull request #2962 from dave2/postprocess_amazon_ova
New post-processor: amazon-import
2016-02-11 23:38:15 -08:00
Chris Bednarski 358b5c62e2 Merge pull request #3143 from ThatGerber/iam-roles
IAM CLI Profile/Assume Role Support
2016-02-04 16:47:09 -08:00
Christopher Gerber e7711c31ea Wrong function to convert int to string. 2016-02-04 16:18:57 -06:00
Christopher Gerber b75d561c56 Fixes more windows testing errors.
"constant 9999999999 overflows int" running test on CI server. Replaced with timestamp to unixnano
2016-02-04 16:12:18 -06:00
Christopher Gerber d25ba245f4 Fixes bytes to string issues in Windows build. 2016-02-04 16:05:49 -06:00
Christopher Gerber a6aefa859f Fixes issue in build where multiple processes were trying to access the same file. 2016-02-04 15:39:54 -06:00
Christopher Gerber 6c3e0daf24 Added tests. Updated CLIConfig to pass tests. 2016-02-04 14:56:22 -06:00
Chris Bednarski e6b6f0b020 Merge pull request #2539 from fnoeding/amazon-ebs-fix-ec-user-data-encoding
amazon builder: always base64 encode ec2 user data
2016-02-03 16:47:01 -08:00
Christopher Gerber f1ae2a2b5a Moved assume credentials to CLIConfig. Added new functions and methods to CLIConfig. Ran gofmt. 2016-02-03 15:53:01 -06:00
Chris Bednarski 951a7e8ad3 Merge pull request #2596 from manicai/master
Fix for #2496 AWS credentials for instance based AMIs
2016-02-03 12:45:51 -08:00
Christopher Gerber 4cf9e36085 Changes credential/config file opener to use homedir instead of HOME environmental variable. 2016-02-03 10:43:48 -06:00
Christopher Gerber 7975c5e336 Move CLIConfig instantiation inside of ProfileName check. 2016-02-02 08:36:36 -06:00
Christopher Gerber 883acb18fa IAM Role Switching
Adds initial IAM Role Switching support and support for AWS CLI Credential and Config files.

See: https://github.com/mitchellh/packer/issues/3109
2016-02-01 18:55:59 -06:00
Chris Bednarski 4490826a17 Merge pull request #3040 from kimor79/3011
Add mount_partition option to amazon-chroot builder
2016-01-25 22:08:07 -08:00
Chris Bednarski 1a5d5acea4 Merge pull request #2737 from jen20/ebs-volume-tags
Tag EBS volumes with volume_tags in EBS builder
2016-01-21 13:29:49 -08:00
Chris Bednarski d6fad30162 Merge pull request #2955 from yayugu/feature/ami_product_codes
Add AMI Product Codes modification for amazon-ebs & amazon-chroot
2016-01-20 09:13:09 -08:00
Chris Bednarski 1ab5fc8ca5 Merge pull request #3037 from ColinHebert/subnet_az_discovery
Add auto discovery of AZ based on the subnet
2016-01-12 19:35:54 -08:00
Chris Bednarski 0cad32c696 Move region list into a function so we can re-use it in tests 2016-01-12 19:03:21 -08:00
Chulki Lee 20c0f6b02b fix doc: wrong function name 2016-01-11 13:06:34 -08:00
Chulki Lee 1aa24035fc add ap-northeast-2: Asia Pacific (Seoul) 2016-01-11 13:05:18 -08:00
Chulki Lee 7018517374 one region per line, sorted 2016-01-11 13:04:35 -08:00