The Amazon EC2 g-family latest generation policy flags older g-family GPU instances, such as g2, and recommends g3, g4dn, or g6. A g3.8xlarge costs about 12% less per month than a g2.8xlarge in US East (N. Virginia), with the same 32 vCPUs and four times the memory. Apply this policy to any aws_instance or aws_launch_template whose instance_type uses a previous-generation g-family type.
Attribute | Detail |
|---|---|
Cloud Provider | Amazon Web Services (AWS) |
Resource Type | Amazon EC2 GPU instances, g-family (accelerated computing) |
Terraform Attribute |
|
Non-compliant Values | Previous g-family generations, for example |
Compliant Value |
|
Cost Impact | About 12% lower on-demand cost moving g2.8xlarge to g3.8xlarge, with 244 GiB instead of 60 GiB of memory |
Why This Policy Matters
How It Helps Reduce Cloud Costs
Amazon EC2 g-family instances are GPU instances built for graphics workloads, video encoding, remote workstations, and machine learning inference.
GPU instances are some of the most expensive line items in an AWS account. A single g2.8xlarge costs close to $1,900 per month on demand, so a small per-hour gap adds up fast.
A g2.8xlarge runs four NVIDIA GRID K520 GPUs with 60 GiB of host memory. A g3.8xlarge runs two NVIDIA Tesla M60 GPUs with 244 GiB of host memory, an Intel Xeon E5-2686 v4 (Broadwell) processor, and enhanced networking.
Both sizes have 32 vCPUs and 16 GiB of total GPU memory. The g3.8xlarge still costs less per hour.
Staying on g2 means paying more per hour for older GPUs and a quarter of the host memory. This is a common source of wasted spend in GPU fleets that were sized years ago and never revisited.
AWS now also lists G3 as a previous-generation family. For new GPU workloads, g4dn and g6 are the better default, and g3 is mainly a minimal-change step away from g2.
Potential Savings
The Amazon EC2 g-family generation upgrade saves money because each newer generation costs less per hour for the same vCPU count.
Instance type | vCPUs | Memory | GPUs | Approx. monthly on-demand cost (US East, Linux) |
|---|---|---|---|---|
| 32 | 60 GiB | 4 x NVIDIA GRID K520 | $1,898 |
| 32 | 244 GiB | 2 x NVIDIA Tesla M60 | $1,664 |
| 32 | 128 GiB | 1 x NVIDIA T4 | $1,588 |
| 32 | 128 GiB | 1 x NVIDIA L4 | $1,471 |
Monthly figures assume 730 hours at US East (N. Virginia) on-demand Linux rates. Prices vary by region, operating system, and purchase option.
Moving one g2.8xlarge to g3.8xlarge saves about $234 per month, or roughly $2,800 per year. Moving to g4dn.8xlarge saves about 16%, and g6.8xlarge about 22%.
The g4dn and g6 options change the GPU count and host memory, so they need a workload check that the g3 move does not.
Implementation Guide
Infrastructure-as-Code Example (Terraform)
The following examples show an Amazon EC2 GPU instance on g2, and the corrected configuration on g3.
Non-compliant configuration: EC2 GPU instance on g2
This configuration pays about 12% more every hour for older GPUs and a quarter of the host memory available on a g3.8xlarge.
Compliant configuration: EC2 GPU instance on g3
The only change is the instance_type value. The resource address stays the same, so Terraform updates the existing instance in place instead of creating a new one.
The same fix applies to launch templates used by Auto Scaling groups:
Step-by-Step Fix Instructions
Search Terraform code for
instance_typevalues that start withg2.inaws_instanceandaws_launch_templateresources.Check shared modules,
.tfvarsfiles, and variable defaults. GPU instance types often sit in avariable "instance_type"default rather than in the resource block.Confirm the AMI includes an NVIDIA driver that supports the target GPU. A driver built for the GRID K520 may not support the Tesla M60, T4, or L4.
Confirm the AMI has Elastic Network Adapter (ENA) support enabled. g4dn and g6 run on the AWS Nitro System, which also requires NVMe drivers.
Check GPU count assumptions. A g2.8xlarge exposes four GPUs and a g3.8xlarge exposes two, so jobs pinned to specific device IDs need updating.
Change the
instance_typevalue and runterraform plan. Confirm the plan shows an in-place update toinstance_type, not a resource replacement.Apply during a maintenance window. Changing the instance type on an
aws_instancestops and starts the instance.Validate the workload, then add Infracost to CI/CD so new previous-generation g-family types are flagged in pull requests before they merge.
Best Practices
Pin approved GPU instance types in shared Terraform modules with a
validationblock, so previous-generation g-family types fail atterraform plan.Migrate a single GPU node first. Driver mismatches on old AMIs usually surface on the first boot.
Review Reserved Instances and Savings Plans before migrating. A standard Reserved Instance for g2 does not cover g3 or g4dn usage. Compute Savings Plans apply across instance families.
Default new GPU workloads to g4dn or g6 rather than g3. AWS classifies G3 as previous generation.
Benchmark before choosing between g4dn and g6. Graphics, encoding, and inference workloads respond differently to the T4 and L4 GPUs.
This policy targets generation upgrades within the g-family. Moving GPU work to p-family or Inferentia instances is a separate sizing decision.
Tools and Scripts
How does Infracost detect previous-generation Amazon EC2 g-family instances automatically?
The Amazon EC2 g-family latest generation policy is available in Infracost, including in the free trial. When Infracost runs in CI/CD, it checks EC2 resources in each pull request. It flags previous-generation g-family instance types in the PR comment, with the file and line to change.
The same Infracost pull request comment shows the estimated monthly cost of the change. Reviewers see what a g2.8xlarge costs before it merges, not on next month's AWS bill.
Infracost also scans connected repositories for previous-generation g-family types already in code. FinOps and platform teams can burn down that backlog over time, tracking issues prevented in pull requests separately from existing issues fixed.
Teams can set the policy to warn engineers or block pull requests. Teams can also limit it to new resources only, so an unrelated PR does not force a GPU instance change that needs downtime.
To find previous-generation g-family types in a Terraform codebase:
To list running EC2 instances on g2 with the AWS CLI:
If an instance is managed by Terraform, change instance_type in code rather than in the console. Otherwise the next terraform apply sets the old type again.
Examples of Impact
Savings from the Amazon EC2 g-family generation upgrade scale with fleet size, because the code change per resource is one attribute.
Illustrative example: a rendering farm. A media team runs ten g2.8xlarge instances for batch rendering. Moving to g3.8xlarge cuts on-demand compute cost by about 12%, roughly $2,340 per month, and quadruples host memory per node after a driver update.
Illustrative example: an inference pool. A platform team runs GPU inference from a launch template set to g2.8xlarge. After benchmarking, the team moves to g4dn.8xlarge and rolls the Auto Scaling group through an instance refresh, saving about 16% per hour.
(These are illustrative scenarios, not specific customer accounts.)
Considerations and Caveats
The Amazon EC2 g-family upgrade is low risk on cost, but GPU drivers and device counts are where migrations go wrong.
GPU driver support. Each g-family generation uses a different NVIDIA GPU. An AMI with drivers for the GRID K520 may need a driver update for the Tesla M60, T4, or L4.
Fewer, larger GPUs. A g3.8xlarge has two GPUs instead of four, and g4dn.8xlarge or g6.8xlarge have one. Multi-GPU job configurations need review.
G3 is not the end state. AWS lists G3 as previous generation. The g2 to g3 move saves money today, but plan a later move to g4dn or g6.
Restart required. Changing
instance_typestops and starts the instance. Without an Elastic IP, the public IPv4 address changes.Provider-specific. This policy targets Amazon EC2 through the
awsTerraform provider. Azure and Google Cloud have their own GPU VM generations with different names.
Related Policies and Concepts
Amazon EC2 - consider using latest generation instances for c family instances: the same generation upgrade for compute-optimized EC2 instances.
Amazon EC2 - consider using latest generation instances for r family instances: the memory-optimized equivalent of this g-family policy.
Amazon EC2 - Consider using a preferred instance type: a related Compute-group policy that restricts EC2 instance types to an approved list, which can exclude g2 by default.
Azure Virtual Machines - consider upgrading ND series machines to NCas T4 v3 or NDamsr A100 v4: the Azure version of a GPU generation upgrade, including a move to the same NVIDIA T4 GPU used by g4dn.
AWS EC2 - consider using Graviton instances: a planned Compute-group policy covering a separate EC2 cost lever, moving x86 workloads to Arm-based instances.
Frequently Asked Questions (FAQs)
Is this policy supported in Infracost?
Yes. The Amazon EC2 g-family latest generation policy is supported in Infracost and available in the free trial. Infracost flags previous-generation g-family instance types in Terraform pull requests, so the team can change the instance type before merge.
Can this policy be customized?
Yes. Teams can configure how Infracost enforces the Amazon EC2 g-family latest generation policy. A finding can warn engineers or block the pull request, and the policy can apply to new resources only.
Does Infracost automatically fix violations?
No. Infracost reports each previous-generation Amazon EC2 g-family instance type in the pull request with the file and line to change. Choosing between g3, g4dn, or g6 depends on GPU drivers and GPU count, so the team makes that decision.
Is this policy cloud-agnostic?
No. The Amazon EC2 g-family latest generation policy targets Amazon EC2 through the aws Terraform provider. Azure and Google Cloud have their own GPU VM generations, with different resource and attribute names.
Which Amazon EC2 g-family generation should replace g2?
For the smallest change, g3 keeps the same vCPU count and GPU memory at a lower hourly rate. For new or long-lived Amazon EC2 GPU workloads, g4dn or g6 cost less again, because AWS now lists G3 as previous generation.
Does upgrading an Amazon EC2 g-family instance cause downtime?
Yes, briefly. Changing the instance type on an Amazon EC2 g-family instance requires a stop and start. Plan the change in a maintenance window, or roll it through an Auto Scaling group with an instance refresh.
How often should I review Amazon EC2 g-family instance generations?
Teams running Infracost in CI/CD get an Amazon EC2 g-family check on every pull request that touches an EC2 resource. For existing GPU instances, a quarterly review of instance generations is a reasonable cadence for most teams.
Create Free Account
This policy is supported in Infracost and available in the free trial. Sign up today and scan your code using our entire library of FinOps policies.