How can I use T2 Unlimited instances with AWS Elastic Beanstalk in my Windows environment?

AWS doesn't currently support the use of T2 Unlimited instances with Elastic Beanstalk in a Windows environment without the use of surplus credits. To use T2 instances in your Windows environment, you must modify your .ebextensions configuration file in Elastic Beanstalk.

Note: Modifying your configuration file works only for T2 instances, which launch as standard by default. By modifying the configuration file, you enable unlimited T2 instances at launch. T3 instances launch as unlimited by default. For more information, see Unlimited Mode for Burstable Performance Instances.

Update the inline policy for the instance profile of your Elastic Beanstalk environment

1.     Open the AWS Identity and Access Management (IAM) console.

2.     Choose Roles.

3.     In the search box, enter aws-elasticbeanstalk-ec2-role to find the default instance profile of your Elastic Beanstalk environment.

4.     Choose aws-elasticbeanstalk-ec2-role, and then choose Add inline policy.

5.     Choose the JSON view, and then enter the following code in the code editor:

  "Version": "2012-10-17",
  "Statement": [
      "Sid": "T2UnlimitedPermissions",
      "Effect": "Allow",
      "Action": [
      "Resource": "*"

6.     Choose Review policy.

7.     For Name, enter a name for the new policy that you created.

8.     Choose Create policy.

Update your Elastic Beanstalk configuration file

1.     In the root of your application source bundle, create a directory named .ebextensions.

2.     In the .ebextensions directory, create a new file named changetot2unlimited.config, and then include the following:

     content : |
      powershell -command "Start-Sleep -s 60"
      $instance = (Invoke-WebRequest -UseBasicParsing).Content
      if(echo "$instance" | Select-String 't2.*'){ exit 0}

     content: |
       $instanceId = (New-Object System.Net.WebClient).DownloadString("")
       #Set Default Region
       Set-DefaultAWSRegion -Region `{"Ref":"AWS::Region"}`

       #Check current credit model
       Get-EC2CreditSpecification -InstanceId $instanceId

       #Change to unlimited
       $unlimitedCredit = New-Object -TypeName Amazon.EC2.Model.InstanceCreditSpecificationRequest
       $unlimitedCredit.InstanceId = $instanceId
       $unlimitedCredit.CpuCredits = "unlimited"
       Edit-EC2InstanceCreditSpecification -InstanceCreditSpecification $unlimitedCredit

    command: powershell.exe -ExecutionPolicy Bypass -File C:\windows\temp\changecredit.ps1
    test: powershell.exe c:\windows\temp\t2-test.ps1
    ignoreErrors: true
    command: cd c:\Windows\Temp\ && del /f *.bak

3.     To create an application source bundle with the updated configuration file, run the following zip command:

zip ../ -r * .[^.]*

Validate your configuration settings before deploying your application

1.     Open the Elastic Beanstalk console, and then select your application.

2.     In the navigation panel, choose Configuration.

3.     In Instance type section, for Instance type, choose t2.micro, if it's not already selected by default.

Important: This solution applies only to IIS-based Elastic Beanstalk environments with T2 instance type.

4.     In the Root volume (boot device) section, for Size, enter 30 or higher.

Important: Your root volume size must be 30 GB or higher for Windows instances.

5.     Choose Apply.

Deploy your updated application

In the Elastic Beanstalk console, Elastic Beanstalk Command Line Interface, or AWS Command Line Interface, deploy your application to your Elastic Beanstalk environment.

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2019-02-27

Updated: 2019-03-06