Skip to content

Commit

Permalink
Merge pull request #40210 from b1-systems/prs/add-support-for-uefiData
Browse files Browse the repository at this point in the history
Add support for UEFI data
  • Loading branch information
ewbankkit authored Jan 15, 2025
2 parents 94283e5 + 8de1b48 commit 97c4c3e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changelog/40210.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
data-source/aws_ami: Add support for UEFI data
```

```release-note:enhancement
resource/aws_ami: Add support for UEFI data
```
16 changes: 16 additions & 0 deletions internal/service/ec2/ec2_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ func resourceAMI() *schema.Resource {
ForceNew: true,
ValidateDiagFunc: enum.Validate[awstypes.TpmSupportValues](),
},
"uefi_data": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"usage_operation": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -362,6 +367,10 @@ func resourceAMICreate(ctx context.Context, d *schema.ResourceData, meta interfa
input.BlockDeviceMappings = append(input.BlockDeviceMappings, expandBlockDeviceMappingsForAMIEphemeralBlockDevice(v.(*schema.Set).List())...)
}

if uefiData := d.Get("uefi_data").(string); uefiData != "" {
input.UefiData = aws.String(uefiData)
}

output, err := conn.RegisterImage(ctx, input)

if err != nil {
Expand Down Expand Up @@ -459,6 +468,13 @@ func resourceAMIRead(ctx context.Context, d *schema.ResourceData, meta interface
return sdkdiag.AppendErrorf(diags, "setting ephemeral_block_device: %s", err)
}

instanceData, err := conn.GetInstanceUefiData(ctx, &ec2.GetInstanceUefiDataInput{
InstanceId: aws.String(d.Id()),
})
if err == nil {
d.Set("uefi_data", instanceData.UefiData)
}

setTagsOut(ctx, image.Tags)

return diags
Expand Down
4 changes: 4 additions & 0 deletions internal/service/ec2/ec2_ami_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ func resourceAMICopy() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"uefi_data": {
Type: schema.TypeString,
Computed: true,
},
"usage_operation": {
Type: schema.TypeString,
Computed: true,
Expand Down
11 changes: 11 additions & 0 deletions internal/service/ec2/ec2_ami_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ func dataSourceAMI() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"uefi_data": {
Type: schema.TypeString,
Optional: true,
},
"usage_operation": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -338,6 +342,13 @@ func dataSourceAMIRead(ctx context.Context, d *schema.ResourceData, meta interfa
d.Set("usage_operation", image.UsageOperation)
d.Set("virtualization_type", image.VirtualizationType)

instanceData, err := conn.GetInstanceUefiData(ctx, &ec2.GetInstanceUefiDataInput{
InstanceId: aws.String(d.Id()),
})
if err == nil {
d.Set("uefi_data", instanceData.UefiData)
}

setTagsOut(ctx, image.Tags)

return diags
Expand Down
4 changes: 4 additions & 0 deletions internal/service/ec2/ec2_ami_from_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ func resourceAMIFromInstance() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"uefi_data": {
Type: schema.TypeString,
Computed: true,
},
"usage_operation": {
Type: schema.TypeString,
Computed: true,
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/ami.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ interpolation.
* `tpm_support` - If the image is configured for NitroTPM support, the value is `v2.0`.
* `virtualization_type` - Type of virtualization of the AMI (ie: `hvm` or
`paravirtual`).
* `uefi_data` - (Optional) Base64 representation of the non-volatile UEFI variable store.
* `usage_operation` - Operation of the Amazon EC2 instance and the billing code that is associated with the AMI.
* `platform_details` - Platform details associated with the billing code of the AMI.
* `ena_support` - Whether enhanced networking with ENA is enabled.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/ami.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ This resource supports the following arguments:
* `tags` - (Optional) Map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `tpm_support` - (Optional) If the image is configured for NitroTPM support, the value is `v2.0`. For more information, see [NitroTPM](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nitrotpm.html) in the Amazon Elastic Compute Cloud User Guide.
* `imds_support` - (Optional) If EC2 instances started from this image should require the use of the Instance Metadata Service V2 (IMDSv2), set this argument to `v2.0`. For more information, see [Configure instance metadata options for new instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-IMDS-new-instances.html#configure-IMDS-new-instances-ami-configuration).
* `uefi_data` - (Optional) Base64 representation of the non-volatile UEFI variable store.

When `virtualization_type` is "paravirtual" the following additional arguments apply:

Expand Down

0 comments on commit 97c4c3e

Please sign in to comment.