Commit Graph

1231 Commits

Author SHA1 Message Date
Adrien Delorme 40947c2bf6
HCL2: generate hcl tags with go-cty tags too (#9306)
This will allow to generate the config files:

```go
package main

import (
	"fmt"

	"github.com/hashicorp/hcl/v2/gohcl"
	"github.com/hashicorp/hcl/v2/hclwrite"
	"github.com/hashicorp/packer/builder/alicloud/ecs"
)

func main() {
	name := "name"
	app := ecs.FlatConfig{
		AlicloudImageName: &name,
		ECSSystemDiskMapping: &ecs.FlatAlicloudDiskDevice{
			DiskName: &name,
		},
	}

	f := hclwrite.NewEmptyFile()
	block := gohcl.EncodeAsBlock(&app, `source "something" "something"`)
	f.Body().AppendBlock(block)
	fmt.Printf("%s", f.Bytes())
}

```

Will output:

```
source "something" "something" {
  packer_user_variables      = null
  packer_sensitive_variables = null
  image_name                 = "name"
  image_share_account        = null
  image_unshare_account      = null
  image_copy_regions         = null
  image_copy_names           = null
  tags                       = null
  tag                        = null
  system_disk_mapping        = { disk_category = null, disk_delete_with_instance = null, disk_descri
ption = null, disk_device = null, disk_encrypted = null, disk_name = "name", disk_size = null, disk_
snapshot_id = null }
  image_disk_mappings        = null
  ssh_remote_tunnels         = null
  ssh_local_tunnels          = null
  ssh_public_key             = null
  ssh_private_key            = null
}
```

This is a good first step for #9015 and #9282 

fix #9304
2020-05-28 11:19:00 +02:00
nitrocode 6d29ec956b Added SourceAMICreationDate 2020-05-26 15:04:03 -04:00
Wilken Rivera b5639d4697
tests/builder/amazon: Enhance the test coverage for SSM Tunnel related steps (#9213)
* test/builder/amazon: Update mocks to properly test SSM tunnel and driver code base

* Update mod files
2020-05-13 10:10:55 -04:00
Wilken Rivera 6f5f6bf999 builder/amazon Fix invalid pointer issue for non SSMAgengtEnabled builds
Tests before change
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1392ca2]

goroutine 299 [running]:
github.com/hashicorp/packer/builder/amazon/common.(*StepCreateSSMTunnel).Cleanup(0xc0003dc460, 0x4d1a4c0, 0xc0006e9800)
        /home/wilken/Development/packer/builder/amazon/common/step_create_ssm_tunnel.go:95 +0xf2
github.com/hashicorp/packer/helper/multistep.(*BasicRunner).Run(0xc0006e98f0, 0x4d408c0, 0xc00065fcc0, 0x4d1a4c0, 0xc0006e9800)
        /home/wilken/Development/packer/helper/multistep/basic_runner.go:79 +0x2c6
github.com/hashicorp/packer/builder/amazon/ebs.(*Builder).Run(0xc000726800, 0x4d408c0, 0xc00065fcc0, 0x4d5e300, 0xc0006e8d80, 0x4cc7220, 0xc000434120, 0x0, 0x0, 0x0, ...)
        /home/wilken/Development/packer/builder/amazon/ebs/builder.go:330 +0x17e2
github.com/hashicorp/packer/packer.(*CoreBuild).Run(0xc000720500, 0x4d408c0, 0xc00065fcc0, 0x4d5e180, 0xc0006fe510, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/wilken/Development/packer/packer/build.go:287 +0x7ef
github.com/hashicorp/packer/command.(*BuildCommand).RunContext.func1(0xc0004d14d0, 0xc0003dc3c0, 0xc000441500, 0xa, 0x4d5e1e0, 0xc000720500, 0x4d408c0, 0xc00065fcc0, 0x4d5e180, 0xc0006fe510, ...)
        /home/wilken/Development/packer/command/build.go:290 +0x189
created by github.com/hashicorp/packer/command.(*BuildCommand).RunContext
        /home/wilken/Development/packer/command/build.go:284 +0xd5a
FAIL    github.com/hashicorp/packer/provisioner/shell   188.335s
FAIL
```

Test After change
```
--- PASS: TestShellProvisioner (212.39s)
    --- PASS: TestShellProvisioner/testing_amazon-ebs_builder_against_shell_provisioner (212.39s)
PASS

```
2020-05-12 14:49:57 -04:00
Wilken Rivera 89fb7bb080 Apply suggestions from code review
Co-authored-by: Megan Marsh <megan@hashicorp.com>
2020-05-08 09:36:43 -04:00
Wilken Rivera 056f1f6e76 docs/amazon/builder: Add not about using a temporary_iam_instance_profile_policy_document 2020-05-08 09:32:54 -04:00
Wilken Rivera bf1da57a05 Update address to localhost to be consistent with other proxies 2020-05-08 09:32:54 -04:00
Wilken Rivera 7cea7466ba buider/amazon: Add `session_manager_port` option for setting a custom local port 2020-05-08 09:32:54 -04:00
Wilken Rivera 0d13c634b7 Update logging constructs for Session Manger driver 2020-05-08 09:32:49 -04:00
Wilken Rivera 81c40b8d08 Add section to docs about the session-manager-plugin tunnel 2020-05-08 09:32:49 -04:00
Wilken Rivera 5f68303504 Remove no longer needed port check
The communicator code base will default to the correct port settings for
valid communicators and fail the build for non valid communicators.
2020-05-08 09:32:49 -04:00
Wilken Rivera 3ae7ab994b step_create_ssm_tunnel: Add port availability check for LocalPortNumber 2020-05-08 09:32:49 -04:00
Wilken Rivera 08dc2cb847 Remove call to unstubbed session start 2020-05-08 09:32:49 -04:00
Wilken Rivera f498866c3a Update validation for session_manager connectivity
Validation will now check that either a IamInstanceProfile or a TemporaryIamInstanceProfilePolicyDocument is set
2020-05-08 09:32:49 -04:00
Wilken Rivera 2f09b74587 amazon/builder: Move port validation for security group into RunConfig.Prepare 2020-05-08 09:32:48 -04:00
Wilken Rivera 3f6b28b70c Add SSMTunnel step to other amazon builders, minus chroot 2020-05-08 09:32:48 -04:00
Wilken Rivera 743df19af2 Add tests for driver and ssm tunnel step 2020-05-08 09:32:48 -04:00
Wilken Rivera e53d6aea66 amazon/ssm_driver: Update to support command context
* Defer the release of the found port to prevent possible Packer build collisions.
2020-05-08 09:32:48 -04:00
Wilken Rivera 5e14089851 tests/builder/amazon: Add basic testing for session_manager
* Add a test to ensure the proper host is returned when using session_manager
* Add a basic driver test for the validating that the SSMDriver will fail if the plugin is not in the path.
2020-05-08 09:32:48 -04:00
Wilken Rivera 60e0ba7e68 Update iam instance profile name 2020-05-08 09:32:48 -04:00
Wilken Rivera d5a0262d6c builder/amazon/instance: Add session manager support 2020-05-08 09:32:48 -04:00
Wilken Rivera e515aefee3 Add validation checks for session_manager
* Session manager connectivity only supported via SSH
* Session manager requires the use of an iam instance profile with system manager permissions
2020-05-08 09:32:48 -04:00
Wilken Rivera c1d2477d18 builder/amzon: Update port configuration for WinRM
Connectivity for WinRM works for the initial connection, but fails to upload any provisioning scripts - need to dive in deeper.
For now connectivity over SSH works as expected.
2020-05-08 09:32:48 -04:00
Wilken Rivera fbffbd1899 docs/builder/amazon: Add short blurb for connecting via the AWS session_manager interface 2020-05-08 09:32:48 -04:00
Wilken Rivera 520061dee6 builder/amazon: Update Session Manger connectivity
* Update security group creation step skip ingress rules if using session manager
* Update create ssm tunnel step to dynamically set a session port
* Add SSHPort function to common to return session-manager tunnel port
* Update SSHHost to return proper host for session-manager
2020-05-08 09:32:48 -04:00
Wilken Rivera 3dd46eb5f4 Add PoC of connectivity using session-manager-plugin
* Add a bunch of hard coded values for testing on port 8081; ssh configs
are set to localhost and 8081
* Add a base drive for communicating with the session manager plugin
* Update step for creating tunnel to actually create SSM session tunnel via driver
2020-05-08 09:32:48 -04:00
Wilken Rivera 16604373ac initial ssm tunnel changes - not working 2020-05-08 09:32:48 -04:00
Megan Marsh f0d2680426
remove spot_price_auto_product from docs (#9173) 2020-05-05 20:48:27 -04:00
Megan Marsh 7e0cfd8b77 add undocumented tag to struct-markdown generator so that we can leave internal-use-only fields out of docs 2020-05-01 10:31:38 -07:00
Adrien Delorme 73242e8de4 make sure keyvalue and namevalue filters are using the same naming as the service being used 2020-04-16 17:22:13 +02:00
Adrien Delorme 840e67f775
HCL2: when we see a map generate an attribute spec instead of a block spec (#9035)
* mapstructure-to-hcl2: when we see a map generate an attribute spec and not a block spec

this will alow to do

tags = {
 key = "value"
}

instead of

tags {
  key = "value"
}

This will also enable using variables directly for those tags

* generate code

* update tests
2020-04-14 16:05:13 +02:00
Jeff Escalante 2999934326
fix generation script, bugfixes in source comments, update website paths in primary codebase 2020-04-07 17:53:22 -04:00
Jeff Escalante 9165be87da
packer.io prefix removal, html extension remove for in-code errors 2020-04-07 17:53:22 -04:00
Jeff Escalante 4afd107eeb
patch source files for extensions changes 2020-04-07 17:50:51 -04:00
Jeff Escalante 37300c7203
fix backtick errors 2020-04-07 17:50:47 -04:00
Jeff Escalante bcc848a83d
were rendering yay 2020-04-07 17:50:47 -04:00
Moss 185deeeb38 Fix provisioner acc-test builder and provisioner store 2020-04-06 16:52:24 -04:00
Wilken Rivera b183c5498f provisioner/powershell: Add basic Powershell provisioner acceptance tests
* Modifies the amazon-ebs builder with a windows build configuration

```
⇶  ACC_TEST_BUILDERS=amazon-ebs ACC_TEST_PROVISIONERS=powershell go test -v ./provisioner/powershell/... -run=TestPowershellProvisioner_Inline
--- PASS: TestPowershellProvisioner_Inline (256.50s)
--- PASS: TestPowershellProvisioner_Inline/testing_amazon-ebs_builder_against_powershell_provisioner (256.50s)
PASS
ok      github.com/hashicorp/packer/provisioner/powershell 256.525s
```
2020-04-06 16:52:05 -04:00
Sylvia Moss 665330de92
Write generic Builder-Provisioner acceptance test logic (#8963) 2020-04-03 18:17:09 +02:00
Megan Marsh 8ae6256c03 add test of NoEphemeral 2020-03-24 09:10:31 -07:00
Megan Marsh fc36a37db8 only set NoDevice if NoEphemeral is set; otherwise, legit block device mappings get destroyed 2020-03-24 08:51:32 -07:00
Adrien Delorme fab344a1fc Update ami_config.go
quote string  in err
2020-03-17 15:41:58 +01:00
Adrien Delorme 88297c796d Merge branch 'master' into hcl2_singular_blocks 2020-03-17 14:47:17 +01:00
Adrien Delorme 911dc5ad95 wip 2020-03-17 11:33:11 +01:00
Adrien Delorme b5e8750f5f Change key/value to name/value to remain consistent with Terraform 2020-03-17 11:23:11 +01:00
Adrien Delorme 3cae1a81ef up tests 2020-03-16 17:54:52 +01:00
Adrien Delorme d532bb376c wip 2020-03-16 17:47:44 +01:00
Adrien Delorme c845436e32 KeyValues.CopyOn: make sure a receiving nil map is set too 2020-03-16 15:46:08 +01:00
Adrien Delorme 87d6b2433f make generate 2020-03-16 15:21:29 +01:00
Adrien Delorme e1c84806cc rewrap 2020-03-16 14:55:03 +01:00