Is it possible to use T2 Unlimited instances in Elastic Beanstalk?
I found a solution. Posting it here in case others run into the same issue:
- Create an IAM policy that allows the ec2 instances in your elastic beanstalk environment to modify instance credit specification and attach it to your elastic beanstalk ec2 role.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "InstanceCreditPolicy",
"Effect": "Allow",
"Action": [
"ec2:ModifyInstanceCreditSpecification",
"ec2:DescribeInstanceCreditSpecifications"
],
"Resource": "*"
}
]
}
- Create an eb extension (
.ebextensions/01-set-instance-credit-unlimited.config
)
commands:
set-instance-credit-unlimited:
command: |
aws ec2 modify-instance-credit-specification --region <your_region> --instance-credit-specification '[{"InstanceId": "'"$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id)"'","CpuCredits": "unlimited"}]'