Skip to content

bug: terraform fail after creating EC2 of burstable instance type (regression with DescribeInstanceCreditSpecifications API) #13488

@sro-nfq

Description

@sro-nfq

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When provisioning an EC2 with a burstable instance type, such as t4g.* or t2.*, terraform will show forever Still creating...[elapsed time..] and then will throw the error:
Error: reading EC2 Instance (i-d35a0a4dd2ba8aa01) credit specification: operation error EC2: DescribeInstanceCreditSpecifications, https response error StatusCode: 0.

To be clear, the EC2 IS created in localstack. But it seems like terraform is trying to call the API for DescribeInstanceCreditSpecifications, and this is blocking terraform, and make it fail ultimately.

The issue is not present in localstack v4.10.0. The bug appeared starting v4.11.0, so it is present in the latest version (v4.11.1).

Expected Behavior

  • The AWS API DescribeInstanceCreditSpecifications is marked as supported by in the docs of localstack (community image).
  • Deploying burstable instance worked smoothly in the past (with localstack =< v4.10.0)

Thus, I assume this API is supposed to work and that there's a regression bug introduced in v4.11.0.

How are you starting LocalStack?

Custom (please describe below)

Steps To Reproduce

Minimal terraform code to provision EC2 instances

# x86_64
data "aws_ssm_parameter" "amazon_linux_2023_x86_64" {
  name = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64"
}

# arm64
data "aws_ssm_parameter" "amazon_linux_2023_arm64" {
  name = "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64"
}

resource "aws_instance" "example_arm64" {
  ami = data.aws_ssm_parameter.amazon_linux_2023_arm64.value # for g(raviton) instances

  # Burstable instance types don't work:
  instance_type = "t4g.small" # arm64

  # Non-burstable instances types do work:
  # instance_type = "m6g.medium" # arm64
}

resource "aws_instance" "example_x86" {
  ami = data.aws_ssm_parameter.amazon_linux_2023_x86_64.value # for x86-based (non graviton) instances

  # Burstable instance types don't work:
  instance_type = "t2.micro" # x86

  # Non-burstable instances types do work:
  # instance_type = "m5.large"   # x86

 # Note that adding this does not work as a workaround. Still failing.
  credit_specification {
    cpu_credits = "standard" # or "unlimited". This does not prevent the call to the faulty API.
  }

}

Output

Run localstack with image localstack/localstack:4.11.0 or localstack/localstack:4.11.1 and terraform apply. Deploying a burstable instance will fail with this output:

aws_instance.example_arm64: Creating...
aws_instance.example_arm64: Still creating... [00m10s elapsed]
aws_instance.example_arm64: Still creating... [00m20s elapsed]
aws_instance.example_arm64: Still creating... [00m30s elapsed]
aws_instance.example_arm64: Still creating... [00m40s elapsed]
aws_instance.example_arm64: Still creating... [00m50s elapsed]
aws_instance.example_arm64: Still creating... [01m00s elapsed]

[interrupt with ^C, as it will never succeed]

Error: reading EC2 Instance (i-34360f1691a758414) credit specification: operation error EC2: DescribeInstanceCreditSpecifications, https response error StatusCode: 0, RequestID: , canceled, context canceled

The EC2 is created and running in localstack, but terraform will be stuck and fail.

Anything else?

I saw in the diff between v4.10.0 and v4.11.0 that the file localstack-core/localstack/aws/api/ec2/__init__.py has been modified. Including parts related to DescribeInstanceCreditSpecifications. But I couldn't find a PR or commit specific to this API in the changelog.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions