From a1651977b35e034e981cdfc17d5cefed90f71b50 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 17 Jul 2020 15:10:55 -0700 Subject: [PATCH 1/9] add tabs to generated docs from access_config and run_config structs --- builder/amazon/common/access_config.go | 16 +++ builder/amazon/common/run_config.go | 136 ++++++++++++++++-- .../common/AccessConfig-not-required.mdx | 19 ++- .../amazon/common/RunConfig-not-required.mdx | 136 ++++++++++++++++-- 4 files changed, 276 insertions(+), 31 deletions(-) diff --git a/builder/amazon/common/access_config.go b/builder/amazon/common/access_config.go index d8e5cbc4f..d85911c2b 100644 --- a/builder/amazon/common/access_config.go +++ b/builder/amazon/common/access_config.go @@ -116,6 +116,9 @@ type AccessConfig struct { // credential types) and GetFederationToken (for federation\_token // credential types) for more details. // + // + // + // // ```json // { // "vault_aws_engine": { @@ -124,7 +127,20 @@ type AccessConfig struct { // "ttl": "3600s" // } // } + // + // + // + // + // ```hcl + // vault_aws_engine { + // name = "myrole" + // role_arn = "myarn" + // ttl = "3600s" + // } // ``` + // + // + // VaultAWSEngine VaultAWSEngineOptions `mapstructure:"vault_aws_engine" required:"false"` getEC2Connection func() ec2iface.EC2API diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index b242f5380..82fe519be 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -96,12 +96,27 @@ type RunConfig struct { // `true`, will cause a timeout. // Example of a valid shutdown command: // + // + // + // // ```json - // { + // "provisioners: [{ // "type": "windows-shell", // "inline": ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] + // }] + // ``` + // + // + // + // + // ```hcl + // provisioner "windows-shell"{ + // inline = ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] // } // ``` + // + // + // DisableStopInstance bool `mapstructure:"disable_stop_instance" required:"false"` // Mark instance as [EBS // Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). @@ -164,6 +179,9 @@ type RunConfig struct { InstanceType string `mapstructure:"instance_type" required:"true"` // Filters used to populate the `security_group_ids` field. Example: // + // + // + // // ```json // { // "security_group_filter": { @@ -174,6 +192,20 @@ type RunConfig struct { // } // ``` // + // + // + // + // ```hcl + // security_group_filter { + // filters = { + // "tag:Class": "packer" + // } + // } + // ``` + // + // + // + // // This selects the SG's with tag `Class` with the value `packer`. // // - `filters` (map of strings) - filters used to select a @@ -211,19 +243,45 @@ type RunConfig struct { // Filters used to populate the `source_ami` // field. Example: // - // ```json + // + // + // + // ```json + // "builders" [ // { + // "type": "amazon-ebs", // "source_ami_filter": { - // "filters": { - // "virtualization-type": "hvm", - // "name": "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*", - // "root-device-type": "ebs" - // }, - // "owners": ["099720109477"], - // "most_recent": true + // "filters": { + // "virtualization-type": "hvm", + // "name": "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*", + // "root-device-type": "ebs" + // }, + // "owners": ["099720109477"], + // "most_recent": true // } // } - // ``` + // ] + // ``` + // + // + // + // + // ```hcl + // source "amazon-ebs" "basic-example" { + // source_ami_filter { + // filters = { + // virtualization-type = "hvm" + // name = "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*" + // root-device-type = "ebs" + // } + // owners = ["099720109477"] + // most_recent = true + // } + // } + // ``` + // + // + // // // This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. NOTE: // This will fail unless *exactly* one AMI is returned. In the above example, @@ -293,8 +351,13 @@ type RunConfig struct { // Filters used to populate the `subnet_id` field. // Example: // - // ```json + // + // + // + // ```json + // "builders" [ // { + // "type": "amazon-ebs", // "subnet_filter": { // "filters": { // "tag:Class": "build" @@ -303,7 +366,26 @@ type RunConfig struct { // "random": false // } // } - // ``` + // ] + // ``` + // + // + // + // + // ```hcl + // source "amazon-ebs" "basic-example" { + // subnet_filter { + // filters = { + // "tag:Class": "build" + // } + // most_free = true + // random = false + // } + // } + // ``` + // + // + // // // This selects the Subnet with tag `Class` with the value `build`, which has // the most free IP addresses. NOTE: This will fail unless *exactly* one @@ -350,10 +432,31 @@ type RunConfig struct { // Filters used to populate the `vpc_id` field. // Example: // + // + // + // // ```json - // { - // "vpc_filter": { - // "filters": { + // "builders" [ + // { + // "type": "amazon-ebs", + // "vpc_filter": { + // "filters": { + // "tag:Class": "build", + // "isDefault": "false", + // "cidr": "/24" + // } + // } + // } + // ] + // ``` + // + // + // + // + // ```hcl + // source "amazon-ebs" "basic-example" { + // vpc_filter { + // filters = { // "tag:Class": "build", // "isDefault": "false", // "cidr": "/24" @@ -362,6 +465,9 @@ type RunConfig struct { // } // ``` // + // + // + // // This selects the VPC with tag `Class` with the value `build`, which is not // the default VPC, and have a IPv4 CIDR block of `/24`. NOTE: This will fail // unless *exactly* one VPC is returned. diff --git a/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx b/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx index 715c71c22..fb04fe023 100644 --- a/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx +++ b/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx @@ -59,7 +59,10 @@ the DurationSeconds parameter for AssumeRole (for assumed\_role credential types) and GetFederationToken (for federation\_token credential types) for more details. - + + + + ```json { "vault_aws_engine": { @@ -69,3 +72,17 @@ } } ``` + + + + + ```hcl + vault_aws_engine { + name = "myrole" + role_arn = "myarn" + ttl = "3600s" + } + ``` + + + diff --git a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx index a454eded7..46ce71d43 100644 --- a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx +++ b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx @@ -26,12 +26,27 @@ `true`, will cause a timeout. Example of a valid shutdown command: + + + ```json - { + "provisioners: [{ "type": "windows-shell", "inline": ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] + }] + ``` + + + + + ```hcl + provisioner "windows-shell"{ + inline = ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] } ``` + + + - `ebs_optimized` (bool) - Mark instance as [EBS Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). @@ -90,6 +105,9 @@ - `security_group_filter` (SecurityGroupFilterOptions) - Filters used to populate the `security_group_ids` field. Example: + + + ```json { "security_group_filter": { @@ -100,6 +118,20 @@ } ``` + + + + ```hcl + security_group_filter { + filters = { + "tag:Class": "packer" + } + } + ``` + + + + This selects the SG's with tag `Class` with the value `packer`. - `filters` (map of strings) - filters used to select a @@ -132,19 +164,45 @@ - `source_ami_filter` (AmiFilterOptions) - Filters used to populate the `source_ami` field. Example: - ```json + + + + ```json + "builders" [ { + "type": "amazon-ebs", "source_ami_filter": { - "filters": { - "virtualization-type": "hvm", - "name": "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*", - "root-device-type": "ebs" - }, - "owners": ["099720109477"], - "most_recent": true + "filters": { + "virtualization-type": "hvm", + "name": "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*", + "root-device-type": "ebs" + }, + "owners": ["099720109477"], + "most_recent": true } } - ``` + ] + ``` + + + + + ```hcl + source "amazon-ebs" "basic-example" { + source_ami_filter { + filters = { + virtualization-type = "hvm" + name = "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*" + root-device-type = "ebs" + } + owners = ["099720109477"] + most_recent = true + } + } + ``` + + + This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. NOTE: This will fail unless *exactly* one AMI is returned. In the above example, @@ -208,8 +266,13 @@ - `subnet_filter` (SubnetFilterOptions) - Filters used to populate the `subnet_id` field. Example: - ```json + + + + ```json + "builders" [ { + "type": "amazon-ebs", "subnet_filter": { "filters": { "tag:Class": "build" @@ -218,7 +281,26 @@ "random": false } } - ``` + ] + ``` + + + + + ```hcl + source "amazon-ebs" "basic-example" { + subnet_filter { + filters = { + "tag:Class": "build" + } + most_free = true + random = false + } + } + ``` + + + This selects the Subnet with tag `Class` with the value `build`, which has the most free IP addresses. NOTE: This will fail unless *exactly* one @@ -265,10 +347,31 @@ - `vpc_filter` (VpcFilterOptions) - Filters used to populate the `vpc_id` field. Example: + + + ```json - { - "vpc_filter": { - "filters": { + "builders" [ + { + "type": "amazon-ebs", + "vpc_filter": { + "filters": { + "tag:Class": "build", + "isDefault": "false", + "cidr": "/24" + } + } + } + ] + ``` + + + + + ```hcl + source "amazon-ebs" "basic-example" { + vpc_filter { + filters = { "tag:Class": "build", "isDefault": "false", "cidr": "/24" @@ -277,6 +380,9 @@ } ``` + + + This selects the VPC with tag `Class` with the value `build`, which is not the default VPC, and have a IPv4 CIDR block of `/24`. NOTE: This will fail unless *exactly* one VPC is returned. From f245ff4e3406f1070ec87e5c6f9354fd08415675 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 17 Jul 2020 15:28:33 -0700 Subject: [PATCH 2/9] add hcl example for session manager --- .../partials/builders/aws-session-manager.mdx | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/website/pages/partials/builders/aws-session-manager.mdx b/website/pages/partials/builders/aws-session-manager.mdx index df2123937..14bf72219 100644 --- a/website/pages/partials/builders/aws-session-manager.mdx +++ b/website/pages/partials/builders/aws-session-manager.mdx @@ -15,6 +15,9 @@ To use the session manager as the connection interface for the SSH communicator - `session_manager_port`: A local port on the host machine that should be used as the local end of the session tunnel to the remote host. If not specified Packer will find an available port to use. - `temporary_iam_instance_profile_policy_document`: Creates a temporary instance profile policy document to grant Systems Manager permissions to the Ec2 instance. This is an alternative to using an existing `iam_instance_profile`. + + + ```json { "builders": [ @@ -48,6 +51,52 @@ To use the session manager as the connection interface for the SSH communicator } ``` + + + +```hcl +// In order to get these variables to read from the environment, +// set the environment variables to have the same name as the declared +// variables, with the prefix PKR_VAR_. + +// You could also hardcode them into the file, but we recommend that. + + +source "amazon-ebs" "ssm-example" { + ami_name = "packer_AWS {{timestamp}}" + instance_type = "t2.micro" + region = "us-east-1" + source_ami_filter { + filters = { + virtualization-type = "hvm" + name = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*" + root-device-type = "ebs" + } + owners = ["099720109477"] + most_recent = true + } + ssh_username = "ubuntu" + ssh_interface = "session_manager" + communicator = "ssh" + iam_instance_profile = "myinstanceprofile" +} + +build { + sources = [ + "source.amazon-ebs.ssm-example" + ] + + provisioner "shell" { + inline = [ + "echo Connected via SSM at '${build.User}@${build.Host}:${build.Port}'" + ] + } +} +``` + + + + #### Session Manager Plugin Connectivity via the session manager requires the use of a session-manger-plugin, which needs to be installed alongside Packer, and an instance AMI that is capable of running the AWS ssm-agent - see [About SSM Agent](https://docs.aws.amazon.com/systems-manager/latest/userguide/prereqs-ssm-agent.html) for details on supported AMIs. From 530f5e3f63e8c80def897a07b9fb5cf9f687b20b Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 17 Jul 2020 15:52:11 -0700 Subject: [PATCH 3/9] more additions to partials --- builder/amazon/common/block_device.go | 30 +++++++++++++++---- helper/communicator/config.go | 20 ++++++++++++- .../common/AccessConfig-not-required.mdx | 11 ++++--- .../builder/amazon/common/BlockDevice.mdx | 30 +++++++++++++++---- .../communicator/Config-not-required.mdx | 20 ++++++++++++- 5 files changed, 93 insertions(+), 18 deletions(-) diff --git a/builder/amazon/common/block_device.go b/builder/amazon/common/block_device.go index b641849c4..4e1046823 100644 --- a/builder/amazon/common/block_device.go +++ b/builder/amazon/common/block_device.go @@ -21,12 +21,32 @@ import ( // The following mapping will tell Packer to encrypt the root volume of the // build instance at launch using a specific non-default kms key: // +// +// +// // ```json -// [{ -// "device_name": "/dev/sda1", -// "encrypted": true, -// "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" -// }] +// ami_block_device_mappings: [ +// { +// "device_name": "/dev/sda1", +// "encrypted": true, +// "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" +// } +// ] +// ``` +// +// +// +// +// ```hcl +// ami_block_device_mappings { +// device_name = "/dev/sda1" +// encrypted = true +// kms_key_id = "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" +// } +// ``` +// +// +// // ``` // // Documentation for Block Devices Mappings can be found here: diff --git a/helper/communicator/config.go b/helper/communicator/config.go index 874fe254e..cd9160377 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -49,14 +49,32 @@ type Config struct { // If you end up in this situation, you can use the template option // `pause_before_connecting`. By default, there is no pause. For example: // + // + // + // // ```json - // { + // "builders" [{ + // ... // "communicator": "ssh", // "ssh_username": "myuser", // "pause_before_connecting": "10m" + // }] + // ``` + // + // + // + // + // ```hcl + // source "amazon-ebs" "example" { + // communicator = "ssh" + // ssh_username = "myuser" + // pause_before_connecting = "10m" // } // ``` // + // + // + // // In this example, Packer will check whether it can connect, as normal. But once // a connection attempt is successful, it will disconnect and then wait 10 minutes // before connecting to the guest and beginning provisioning. diff --git a/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx b/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx index fb04fe023..93ea549f1 100644 --- a/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx +++ b/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx @@ -59,10 +59,10 @@ the DurationSeconds parameter for AssumeRole (for assumed\_role credential types) and GetFederationToken (for federation\_token credential types) for more details. - + - + ```json { "vault_aws_engine": { @@ -71,11 +71,10 @@ "ttl": "3600s" } } - ``` - + - + ```hcl vault_aws_engine { name = "myrole" @@ -83,6 +82,6 @@ ttl = "3600s" } ``` - + diff --git a/website/pages/partials/builder/amazon/common/BlockDevice.mdx b/website/pages/partials/builder/amazon/common/BlockDevice.mdx index 89536e6c3..9d70f64c6 100644 --- a/website/pages/partials/builder/amazon/common/BlockDevice.mdx +++ b/website/pages/partials/builder/amazon/common/BlockDevice.mdx @@ -8,12 +8,32 @@ Example use case: The following mapping will tell Packer to encrypt the root volume of the build instance at launch using a specific non-default kms key: + + + ```json -[{ - "device_name": "/dev/sda1", - "encrypted": true, - "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" -}] +ami_block_device_mappings: [ + { + "device_name": "/dev/sda1", + "encrypted": true, + "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" + } +] +``` + + + + +```hcl +ami_block_device_mappings { + device_name = "/dev/sda1" + encrypted = true + kms_key_id = "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d" +} +``` + + + ``` Documentation for Block Devices Mappings can be found here: diff --git a/website/pages/partials/helper/communicator/Config-not-required.mdx b/website/pages/partials/helper/communicator/Config-not-required.mdx index 5ad952f90..075f85672 100644 --- a/website/pages/partials/helper/communicator/Config-not-required.mdx +++ b/website/pages/partials/helper/communicator/Config-not-required.mdx @@ -22,14 +22,32 @@ If you end up in this situation, you can use the template option `pause_before_connecting`. By default, there is no pause. For example: + + + ```json - { + "builders" [{ + ... "communicator": "ssh", "ssh_username": "myuser", "pause_before_connecting": "10m" + }] + ``` + + + + + ```hcl + source "amazon-ebs" "example" { + communicator = "ssh" + ssh_username = "myuser" + pause_before_connecting = "10m" } ``` + + + In this example, Packer will check whether it can connect, as normal. But once a connection attempt is successful, it will disconnect and then wait 10 minutes before connecting to the guest and beginning provisioning. From fd6be7f279dc60190dd758ba44cd5bd1fdbc470d Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 20 Jul 2020 16:02:49 +0200 Subject: [PATCH 4/9] better/simpler `pause_before_connecting` example --- helper/communicator/config.go | 41 ++++--------------- .../communicator/Config-not-required.mdx | 41 ++++--------------- 2 files changed, 16 insertions(+), 66 deletions(-) diff --git a/helper/communicator/config.go b/helper/communicator/config.go index cd9160377..88c194660 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -43,41 +43,16 @@ type Config struct { Type string `mapstructure:"communicator"` // We recommend that you enable SSH or WinRM as the very last step in your - // guest's bootstrap script, but sometimes you may have a race condition where - // you need Packer to wait before attempting to connect to your guest. + // guest's bootstrap script, but sometimes you may have a race condition + // where you need Packer to wait before attempting to connect to your + // guest. // // If you end up in this situation, you can use the template option - // `pause_before_connecting`. By default, there is no pause. For example: - // - // - // - // - // ```json - // "builders" [{ - // ... - // "communicator": "ssh", - // "ssh_username": "myuser", - // "pause_before_connecting": "10m" - // }] - // ``` - // - // - // - // - // ```hcl - // source "amazon-ebs" "example" { - // communicator = "ssh" - // ssh_username = "myuser" - // pause_before_connecting = "10m" - // } - // ``` - // - // - // - // - // In this example, Packer will check whether it can connect, as normal. But once - // a connection attempt is successful, it will disconnect and then wait 10 minutes - // before connecting to the guest and beginning provisioning. + // `pause_before_connecting`. By default, there is no pause. For example if + // you set `pause_before_connecting` to `10m` Packer will check whether it + // can connect, as normal. But once a connection attempt is successful, it + // will disconnect and then wait 10 minutes before connecting to the guest + // and beginning provisioning. PauseBeforeConnect time.Duration `mapstructure:"pause_before_connecting"` SSH `mapstructure:",squash"` diff --git a/website/pages/partials/helper/communicator/Config-not-required.mdx b/website/pages/partials/helper/communicator/Config-not-required.mdx index 075f85672..a0ffb17d3 100644 --- a/website/pages/partials/helper/communicator/Config-not-required.mdx +++ b/website/pages/partials/helper/communicator/Config-not-required.mdx @@ -16,38 +16,13 @@ files. - `pause_before_connecting` (duration string | ex: "1h5m2s") - We recommend that you enable SSH or WinRM as the very last step in your - guest's bootstrap script, but sometimes you may have a race condition where - you need Packer to wait before attempting to connect to your guest. + guest's bootstrap script, but sometimes you may have a race condition + where you need Packer to wait before attempting to connect to your + guest. If you end up in this situation, you can use the template option - `pause_before_connecting`. By default, there is no pause. For example: - - - - - ```json - "builders" [{ - ... - "communicator": "ssh", - "ssh_username": "myuser", - "pause_before_connecting": "10m" - }] - ``` - - - - - ```hcl - source "amazon-ebs" "example" { - communicator = "ssh" - ssh_username = "myuser" - pause_before_connecting = "10m" - } - ``` - - - - - In this example, Packer will check whether it can connect, as normal. But once - a connection attempt is successful, it will disconnect and then wait 10 minutes - before connecting to the guest and beginning provisioning. + `pause_before_connecting`. By default, there is no pause. For example if + you set `pause_before_connecting` to `10m` Packer will check whether it + can connect, as normal. But once a connection attempt is successful, it + will disconnect and then wait 10 minutes before connecting to the guest + and beginning provisioning. From 191094edccd5a100080c8ede82abf84fc7e3f521 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 20 Jul 2020 16:20:47 +0200 Subject: [PATCH 5/9] better `disable_stop_instance` docs --- builder/amazon/common/run_config.go | 41 +++++++------------ .../amazon/common/RunConfig-not-required.mdx | 41 +++++++------------ 2 files changed, 30 insertions(+), 52 deletions(-) diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index 82fe519be..9f5479f6e 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -89,34 +89,23 @@ type RunConfig struct { // which will stop the instance for you. If this is set to `true`, Packer // *will not* stop the instance but will assume that you will send the stop // signal yourself through your final provisioner. You can do this with a - // [windows-shell - // provisioner](/docs/provisioners/windows-shell). - // Note that Packer will still wait for the instance to be stopped, and - // failing to send the stop signal yourself, when you have set this flag to - // `true`, will cause a timeout. - // Example of a valid shutdown command: - // - // - // - // - // ```json - // "provisioners: [{ - // "type": "windows-shell", - // "inline": ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] - // }] + // [windows-shell provisioner](/docs/provisioners/windows-shell). Note that + // Packer will still wait for the instance to be stopped, and failing to + // send the stop signal yourself, when you have set this flag to `true`, + // will cause a timeout. + // + // An example of a valid windows shutdown command in a `windows-shell` + // provisioner is : + // ```shell-session + // ec2config.exe -sysprep // ``` - // - // - // - // - // ```hcl - // provisioner "windows-shell"{ - // inline = ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] - // } + // or + // ```sell-session + // "%programfiles%\amazon\ec2configservice\"ec2config.exe -sysprep"" // ``` - // - // - // + // -> Note: The double quotation marks in the command are not required if + // your CMD shell is already in the + // `C:\Program Files\Amazon\EC2ConfigService\` directory. DisableStopInstance bool `mapstructure:"disable_stop_instance" required:"false"` // Mark instance as [EBS // Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). diff --git a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx index 46ce71d43..5072ccc00 100644 --- a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx +++ b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx @@ -19,34 +19,23 @@ which will stop the instance for you. If this is set to `true`, Packer *will not* stop the instance but will assume that you will send the stop signal yourself through your final provisioner. You can do this with a - [windows-shell - provisioner](/docs/provisioners/windows-shell). - Note that Packer will still wait for the instance to be stopped, and - failing to send the stop signal yourself, when you have set this flag to - `true`, will cause a timeout. - Example of a valid shutdown command: - - - - - ```json - "provisioners: [{ - "type": "windows-shell", - "inline": ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] - }] + [windows-shell provisioner](/docs/provisioners/windows-shell). Note that + Packer will still wait for the instance to be stopped, and failing to + send the stop signal yourself, when you have set this flag to `true`, + will cause a timeout. + + An example of a valid windows shutdown command in a `windows-shell` + provisioner is : + ```shell-session + ec2config.exe -sysprep ``` - - - - - ```hcl - provisioner "windows-shell"{ - inline = ["\"c:\\Program Files\\Amazon\\Ec2ConfigService\\ec2config.exe\" -sysprep"] - } + or + ```sell-session + "%programfiles%\amazon\ec2configservice\"ec2config.exe -sysprep"" ``` - - - + -> Note: The double quotation marks in the command are not required if + your CMD shell is already in the + `C:\Program Files\Amazon\EC2ConfigService\` directory. - `ebs_optimized` (bool) - Mark instance as [EBS Optimized](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html). From 1455a29f2b39de7a82b6c818bf8a6e0f3eeeada4 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 20 Jul 2020 16:24:47 +0200 Subject: [PATCH 6/9] remove tabs for security_group_filter too --- builder/amazon/common/run_config.go | 11 ++--------- .../builder/amazon/common/RunConfig-not-required.mdx | 11 ++--------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index 9f5479f6e..a7bdb4451 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -166,10 +166,7 @@ type RunConfig struct { // The EC2 instance type to use while building the // AMI, such as t2.small. InstanceType string `mapstructure:"instance_type" required:"true"` - // Filters used to populate the `security_group_ids` field. Example: - // - // - // + // Filters used to populate the `security_group_ids` field. JSON Example: // // ```json // { @@ -181,8 +178,7 @@ type RunConfig struct { // } // ``` // - // - // + // HCL2 Example: // // ```hcl // security_group_filter { @@ -192,9 +188,6 @@ type RunConfig struct { // } // ``` // - // - // - // // This selects the SG's with tag `Class` with the value `packer`. // // - `filters` (map of strings) - filters used to select a diff --git a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx index 5072ccc00..8dcec731f 100644 --- a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx +++ b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx @@ -92,10 +92,7 @@ shutdown in case Packer exits ungracefully. Possible values are stop and terminate. Defaults to stop. -- `security_group_filter` (SecurityGroupFilterOptions) - Filters used to populate the `security_group_ids` field. Example: - - - +- `security_group_filter` (SecurityGroupFilterOptions) - Filters used to populate the `security_group_ids` field. JSON Example: ```json { @@ -107,8 +104,7 @@ } ``` - - + HCL2 Example: ```hcl security_group_filter { @@ -118,9 +114,6 @@ } ``` - - - This selects the SG's with tag `Class` with the value `packer`. - `filters` (map of strings) - filters used to select a From 5c4901c2c26341855e7166d621b4992e3be90e01 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 20 Jul 2020 16:26:45 +0200 Subject: [PATCH 7/9] builder/amazon/common/run_config.go: replace tabs with words --- builder/amazon/common/run_config.go | 36 ++++--------------- .../amazon/common/RunConfig-not-required.mdx | 36 ++++--------------- 2 files changed, 12 insertions(+), 60 deletions(-) diff --git a/builder/amazon/common/run_config.go b/builder/amazon/common/run_config.go index a7bdb4451..c9a8b8c6e 100644 --- a/builder/amazon/common/run_config.go +++ b/builder/amazon/common/run_config.go @@ -223,10 +223,7 @@ type RunConfig struct { // used when from_scratch is set to true. SourceAmi string `mapstructure:"source_ami" required:"true"` // Filters used to populate the `source_ami` - // field. Example: - // - // - // + // field. JSON Example: // // ```json // "builders" [ @@ -244,9 +241,7 @@ type RunConfig struct { // } // ] // ``` - // - // - // + // HCL2 example: // // ```hcl // source "amazon-ebs" "basic-example" { @@ -262,9 +257,6 @@ type RunConfig struct { // } // ``` // - // - // - // // This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. NOTE: // This will fail unless *exactly* one AMI is returned. In the above example, // `most_recent` will cause this to succeed by selecting the newest image. @@ -331,10 +323,7 @@ type RunConfig struct { // will allow you to create those programatically. SpotTag hcl2template.KeyValues `mapstructure:"spot_tag" required:"false"` // Filters used to populate the `subnet_id` field. - // Example: - // - // - // + // JSON Example: // // ```json // "builders" [ @@ -350,9 +339,7 @@ type RunConfig struct { // } // ] // ``` - // - // - // + // HCL2 example: // // ```hcl // source "amazon-ebs" "basic-example" { @@ -366,9 +353,6 @@ type RunConfig struct { // } // ``` // - // - // - // // This selects the Subnet with tag `Class` with the value `build`, which has // the most free IP addresses. NOTE: This will fail unless *exactly* one // Subnet is returned. By using `most_free` or `random` one will be selected @@ -412,10 +396,7 @@ type RunConfig struct { // data when launching the instance. UserDataFile string `mapstructure:"user_data_file" required:"false"` // Filters used to populate the `vpc_id` field. - // Example: - // - // - // + // JSON Example: // // ```json // "builders" [ @@ -431,9 +412,7 @@ type RunConfig struct { // } // ] // ``` - // - // - // + // HCL2 example: // // ```hcl // source "amazon-ebs" "basic-example" { @@ -447,9 +426,6 @@ type RunConfig struct { // } // ``` // - // - // - // // This selects the VPC with tag `Class` with the value `build`, which is not // the default VPC, and have a IPv4 CIDR block of `/24`. NOTE: This will fail // unless *exactly* one VPC is returned. diff --git a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx index 8dcec731f..6c3a3afd6 100644 --- a/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx +++ b/website/pages/partials/builder/amazon/common/RunConfig-not-required.mdx @@ -144,10 +144,7 @@ security_group_id. - `source_ami_filter` (AmiFilterOptions) - Filters used to populate the `source_ami` - field. Example: - - - + field. JSON Example: ```json "builders" [ @@ -165,9 +162,7 @@ } ] ``` - - - + HCL2 example: ```hcl source "amazon-ebs" "basic-example" { @@ -183,9 +178,6 @@ } ``` - - - This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. NOTE: This will fail unless *exactly* one AMI is returned. In the above example, `most_recent` will cause this to succeed by selecting the newest image. @@ -246,10 +238,7 @@ will allow you to create those programatically. - `subnet_filter` (SubnetFilterOptions) - Filters used to populate the `subnet_id` field. - Example: - - - + JSON Example: ```json "builders" [ @@ -265,9 +254,7 @@ } ] ``` - - - + HCL2 example: ```hcl source "amazon-ebs" "basic-example" { @@ -281,9 +268,6 @@ } ``` - - - This selects the Subnet with tag `Class` with the value `build`, which has the most free IP addresses. NOTE: This will fail unless *exactly* one Subnet is returned. By using `most_free` or `random` one will be selected @@ -327,10 +311,7 @@ data when launching the instance. - `vpc_filter` (VpcFilterOptions) - Filters used to populate the `vpc_id` field. - Example: - - - + JSON Example: ```json "builders" [ @@ -346,9 +327,7 @@ } ] ``` - - - + HCL2 example: ```hcl source "amazon-ebs" "basic-example" { @@ -362,9 +341,6 @@ } ``` - - - This selects the VPC with tag `Class` with the value `build`, which is not the default VPC, and have a IPv4 CIDR block of `/24`. NOTE: This will fail unless *exactly* one VPC is returned. From 966b17d2b54fd6eb69719bd560e3044df541f1ad Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 20 Jul 2020 16:31:23 +0200 Subject: [PATCH 8/9] builder/amazon/common/access_config.go: replace tabs with words --- builder/amazon/common/access_config.go | 10 +++------- .../amazon/common/AccessConfig-not-required.mdx | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/builder/amazon/common/access_config.go b/builder/amazon/common/access_config.go index d85911c2b..2be4cf3ef 100644 --- a/builder/amazon/common/access_config.go +++ b/builder/amazon/common/access_config.go @@ -116,8 +116,7 @@ type AccessConfig struct { // credential types) and GetFederationToken (for federation\_token // credential types) for more details. // - // - // + // JSON example: // // ```json // { @@ -127,9 +126,9 @@ type AccessConfig struct { // "ttl": "3600s" // } // } + // ``` // - // - // + // HCL2 example: // // ```hcl // vault_aws_engine { @@ -138,9 +137,6 @@ type AccessConfig struct { // ttl = "3600s" // } // ``` - // - // - // VaultAWSEngine VaultAWSEngineOptions `mapstructure:"vault_aws_engine" required:"false"` getEC2Connection func() ec2iface.EC2API diff --git a/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx b/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx index 93ea549f1..3c0faabe7 100644 --- a/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx +++ b/website/pages/partials/builder/amazon/common/AccessConfig-not-required.mdx @@ -60,8 +60,7 @@ credential types) and GetFederationToken (for federation\_token credential types) for more details. - - + JSON example: ```json { @@ -71,9 +70,9 @@ "ttl": "3600s" } } + ``` - - + HCL2 example: ```hcl vault_aws_engine { @@ -82,6 +81,3 @@ ttl = "3600s" } ``` - - - From 810f161d22e81d7409d0a7c82543e19b07fca2d9 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 20 Jul 2020 16:34:13 +0200 Subject: [PATCH 9/9] builder/amazon/common/block_device.go: replace tabs with words --- builder/amazon/common/block_device.go | 10 ++-------- .../partials/builder/amazon/common/BlockDevice.mdx | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/builder/amazon/common/block_device.go b/builder/amazon/common/block_device.go index 4e1046823..cca863f24 100644 --- a/builder/amazon/common/block_device.go +++ b/builder/amazon/common/block_device.go @@ -21,8 +21,7 @@ import ( // The following mapping will tell Packer to encrypt the root volume of the // build instance at launch using a specific non-default kms key: // -// -// +// JSON example: // // ```json // ami_block_device_mappings: [ @@ -34,8 +33,7 @@ import ( // ] // ``` // -// -// +// HCL2 example: // // ```hcl // ami_block_device_mappings { @@ -45,10 +43,6 @@ import ( // } // ``` // -// -// -// ``` -// // Documentation for Block Devices Mappings can be found here: // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html // diff --git a/website/pages/partials/builder/amazon/common/BlockDevice.mdx b/website/pages/partials/builder/amazon/common/BlockDevice.mdx index 9d70f64c6..2d379812c 100644 --- a/website/pages/partials/builder/amazon/common/BlockDevice.mdx +++ b/website/pages/partials/builder/amazon/common/BlockDevice.mdx @@ -8,8 +8,7 @@ Example use case: The following mapping will tell Packer to encrypt the root volume of the build instance at launch using a specific non-default kms key: - - +JSON example: ```json ami_block_device_mappings: [ @@ -21,8 +20,7 @@ ami_block_device_mappings: [ ] ``` - - +HCL2 example: ```hcl ami_block_device_mappings { @@ -32,9 +30,5 @@ ami_block_device_mappings { } ``` - - -``` - Documentation for Block Devices Mappings can be found here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html