Skip to content

Commit

Permalink
Add documentation for enabling instance metadata v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nywilken committed Nov 3, 2023
1 parent 51c989d commit 6de572b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 20 deletions.
43 changes: 33 additions & 10 deletions .web-docs/components/builder/ebs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ references for [AMI](#ami-configuration),
configuration references, which are
necessary for this build to succeed and can be found further down the page.

### Optional:
**Optional:**

<!-- Code generated from the comments of the Config struct in builder/ebs/builder.go; DO NOT EDIT MANUALLY -->

Expand Down Expand Up @@ -93,7 +93,7 @@ necessary for this build to succeed and can be found further down the page.

### AMI Configuration

#### Required:
**Required:**

<!-- Code generated from the comments of the AMIConfig struct in builder/common/ami_config.go; DO NOT EDIT MANUALLY -->

Expand All @@ -105,7 +105,7 @@ necessary for this build to succeed and can be found further down the page.
<!-- End of code generated from the comments of the AMIConfig struct in builder/common/ami_config.go; -->


#### Optional:
**Optional:**

<!-- Code generated from the comments of the AMIConfig struct in builder/common/ami_config.go; DO NOT EDIT MANUALLY -->

Expand Down Expand Up @@ -272,7 +272,7 @@ necessary for this build to succeed and can be found further down the page.

### Access Configuration

#### Required:
**Required:**

<!-- Code generated from the comments of the AccessConfig struct in builder/common/access_config.go; DO NOT EDIT MANUALLY -->

Expand All @@ -291,7 +291,7 @@ necessary for this build to succeed and can be found further down the page.
<!-- End of code generated from the comments of the AccessConfig struct in builder/common/access_config.go; -->


#### Optional:
**Optional:**

<!-- Code generated from the comments of the AccessConfig struct in builder/common/access_config.go; DO NOT EDIT MANUALLY -->

Expand Down Expand Up @@ -501,7 +501,7 @@ JSON example:

### Run Configuration

#### Required:
**Required:**

<!-- Code generated from the comments of the RunConfig struct in builder/common/run_config.go; DO NOT EDIT MANUALLY -->

Expand All @@ -515,7 +515,7 @@ JSON example:
<!-- End of code generated from the comments of the RunConfig struct in builder/common/run_config.go; -->


#### Optional:
**Optional:**

<!-- Code generated from the comments of the RunConfig struct in builder/common/run_config.go; DO NOT EDIT MANUALLY -->

Expand Down Expand Up @@ -1143,6 +1143,29 @@ source "amazon-ebs" "basic-example" {
}
```

##### Enable Instance Metadata Service v2

The Amazon builder has support for enabling metadata service v2 (imdsv2) on a running instance and on the resulting AMI generated from a Packer build.
To enable support for both there are two key attributes that must be defined.

**HCL2**

```hcl
source "amazon-ebs" "basic-example" {
region = "us-east-1"
source_ami = "ami-fce3c696"
instance_type = "t2.micro"
ssh_username = "ubuntu"
ami_name = "packer_AWS_example_{{timestamp}}"
# enables imdsv2 support on the running instance being provisioned by Packer
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = 1
}
imds_support = "v2.0" # enables imdsv2 support on the resulting AMI
}
```

### Session Manager Connections

Expand Down Expand Up @@ -1307,7 +1330,7 @@ https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concept
<!-- End of code generated from the comments of the BlockDevice struct in builder/common/block_device.go; -->


#### Optional:
**Optional:**

<!-- Code generated from the comments of the BlockDevice struct in builder/common/block_device.go; DO NOT EDIT MANUALLY -->

Expand Down Expand Up @@ -1364,7 +1387,7 @@ https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concept

### Communicator Configuration

#### Optional:
**Optional:**

<!-- Code generated from the comments of the Config struct in communicator/config.go; DO NOT EDIT MANUALLY -->

Expand Down Expand Up @@ -1642,7 +1665,7 @@ https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/win-ami-config-fast-launc
<!-- End of code generated from the comments of the FastLaunchConfig struct in builder/ebs/fast_launch_setup.go; -->


#### Optional
**Optional:**

<!-- Code generated from the comments of the FastLaunchConfig struct in builder/ebs/fast_launch_setup.go; DO NOT EDIT MANUALLY -->

Expand Down
43 changes: 33 additions & 10 deletions docs/builders/ebs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,29 @@ references for [AMI](#ami-configuration),
configuration references, which are
necessary for this build to succeed and can be found further down the page.

### Optional:
**Optional:**

@include 'builder/ebs/Config-not-required.mdx'

### AMI Configuration

#### Required:
**Required:**

@include 'builder/common/AMIConfig-required.mdx'

#### Optional:
**Optional:**

@include 'builder/common/AMIConfig-not-required.mdx'

@include 'builder/common/SnapshotConfig-not-required.mdx'

### Access Configuration

#### Required:
**Required:**

@include 'builder/common/AccessConfig-required.mdx'

#### Optional:
**Optional:**

@include 'builder/common/AccessConfig-not-required.mdx'

Expand All @@ -85,11 +85,11 @@ necessary for this build to succeed and can be found further down the page.

### Run Configuration

#### Required:
**Required:**

@include 'builder/common/RunConfig-required.mdx'

#### Optional:
**Optional:**

@include 'builder/common/RunConfig-not-required.mdx'

Expand Down Expand Up @@ -146,6 +146,29 @@ source "amazon-ebs" "basic-example" {
}
```

##### Enable Instance Metadata Service v2

The Amazon builder has support for enabling metadata service v2 (imdsv2) on a running instance and on the resulting AMI generated from a Packer build.
To enable support for both there are two key attributes that must be defined.

**HCL2**

```hcl
source "amazon-ebs" "basic-example" {
region = "us-east-1"
source_ami = "ami-fce3c696"
instance_type = "t2.micro"
ssh_username = "ubuntu"
ami_name = "packer_AWS_example_{{timestamp}}"
# enables imdsv2 support on the running instance being provisioned by Packer
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = 1
}
imds_support = "v2.0" # enables imdsv2 support on the resulting AMI
}
```

@include 'builders/aws-session-manager.mdx'

Expand All @@ -157,13 +180,13 @@ Block devices can be nested in the

@include 'builder/common/BlockDevice.mdx'

#### Optional:
**Optional:**

@include 'builder/common/BlockDevice-not-required.mdx'

### Communicator Configuration

#### Optional:
**Optional:**

@include 'packer-plugin-sdk/communicator/Config-not-required.mdx'

Expand Down Expand Up @@ -261,7 +284,7 @@ Windows](http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/finding-an-ami.ht

@include 'builder/ebs/FastLaunchConfig.mdx'

#### Optional
**Optional:**

@include 'builder/ebs/FastLaunchConfig-not-required.mdx'

Expand Down

0 comments on commit 6de572b

Please sign in to comment.