Error when creating AWS Budget Actions to automatically stop EC2 and RDS

3.6k views Asked by At

I use one EC2 instance and one RDS to run my Backend for my website. Now I saw that you can create an AWS Budget Action to automatically stop your EC2 or RDS instance. That wasn't possible before and I definitly wanna use it to be 100% sure not to get a fat bill from AWS. I already set up a billing alert, but I want the EC2 and RDS to also be automatically shut down, just to be really safe.

So when creating a new budget in AWS Budgets you can add a "Budget action", which requires you to attach an IAM role to AWS Budgets. I tried that with an existing EC2Role of mine, which has "AmazonEC2FullAccess" Policy attached to it. But this doesn't seem to be the right policy: error message in AWS Budgets

3

There are 3 answers

1
Boommeister On BEST ANSWER

Ok I just figured it out after posting the question, the Role also needed a Trust relationship to AWS Budgets, which had to be attached to the Role in IAM:

Added trust relationship in IAM

0
Sumit Badsara On

While creating the role, the first step is to select the trusted entity, where you need to select Budgets

enter image description here

And then select specific permissions related to EC2/RDS and create the role.

NOTE: you will have to create a new role to add this privilege for IAM in the budget.

0
pedro_bb7 On

Just to clarify, after clicking Edit trust relationship, insert this policy:

enter image description here

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "ec2.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    },
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "budgets.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}