diff --git a/.changelog/40210.txt b/.changelog/40210.txt new file mode 100644 index 00000000000..069f9cf6b96 --- /dev/null +++ b/.changelog/40210.txt @@ -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 +``` diff --git a/internal/service/ec2/ec2_ami.go b/internal/service/ec2/ec2_ami.go index 6a3f5c569ad..196745cc7f8 100644 --- a/internal/service/ec2/ec2_ami.go +++ b/internal/service/ec2/ec2_ami.go @@ -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, @@ -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 { @@ -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 diff --git a/internal/service/ec2/ec2_ami_copy.go b/internal/service/ec2/ec2_ami_copy.go index 9dc9148fd69..7b1feeb6763 100644 --- a/internal/service/ec2/ec2_ami_copy.go +++ b/internal/service/ec2/ec2_ami_copy.go @@ -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, diff --git a/internal/service/ec2/ec2_ami_data_source.go b/internal/service/ec2/ec2_ami_data_source.go index 1146e5c7d7a..0cb4f1d67e3 100644 --- a/internal/service/ec2/ec2_ami_data_source.go +++ b/internal/service/ec2/ec2_ami_data_source.go @@ -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, @@ -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 diff --git a/internal/service/ec2/ec2_ami_from_instance.go b/internal/service/ec2/ec2_ami_from_instance.go index be928cdaf77..edf52514730 100644 --- a/internal/service/ec2/ec2_ami_from_instance.go +++ b/internal/service/ec2/ec2_ami_from_instance.go @@ -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, diff --git a/website/docs/d/ami.html.markdown b/website/docs/d/ami.html.markdown index 3128965f0f5..b8f14698cba 100644 --- a/website/docs/d/ami.html.markdown +++ b/website/docs/d/ami.html.markdown @@ -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. diff --git a/website/docs/r/ami.html.markdown b/website/docs/r/ami.html.markdown index c7451e50a94..569206f4300 100644 --- a/website/docs/r/ami.html.markdown +++ b/website/docs/r/ami.html.markdown @@ -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: