Getting incompatible mismatches at plan time

I am using Terraform to provision servers at AWS - but sometimes the configs are not compatible.

Say for example I choose t4g.nano|Family: t4g|2vCPU|0.5 GiB Memory for Chicago local region, which will throw an error since the minimum config required for Chicago is t3.medium|Family: t3|2vCPU|4 GiB Memory

(I am not 100% sure of above statement, I’m just using this as an example)

After providing all the inputs, how can I get the actual reason for the error at plan time ?

Like in this case :

t4g.nano is not available for Chicago region, minimum Family required is t3.medium

Won’t the AWS provider plugin return this ?

The provider doesn’t know about all the business rules in AWS so it cannot alert you of that.

That’s why you only get this error during the apply when Terraform actually calls the AWS API to do the changes. During the plan phase it’s just retrieving current state and figuring out necessary changes, but no modify/write API calls.

1 Like

Hi @anjanesh,

If there is some way to query the AWS API to ask what is available then that API could potentially be exposed by the AWS providers as a data source, and then you could use a precondition on the resource that’s using the instance type to return an early error based on the data source result.

I’m not sure if there is such as API and associated data source today, though. Even if there is it’s worth keeping in mind that the availability of particular instance types in particular AZs can vary dynamically based on demand in that AZ, so in rare cases the given instance type might be available during planning but then become unavailable before apply. In your case though it sounds like a new instance type that hasn’t been rolled out in some regions yet, which I assume isn’t something that varies quickly enough to change between plan and apply.

1 Like