When running my TF script to create an AWS App Runner service I'm getting this error:
InvalidRequestException: Error in assuming instance role arn:aws:iam::000000000000:role/MyAppRunnerServiceRole
I created the role policy trust using AppRunnerECRAccessRole
as reference, which is auto-generated by the console, but using either that or my own below I'm getting the same issue.
Here's my TF code:
### IAM ###
resource "aws_iam_role" "app_runner" {
name = "MyAppRunnerServiceRole"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "build.apprunner.amazonaws.com"
}
},
]
})
}
resource "aws_iam_role_policy_attachment" "app_runner" {
role = aws_iam_role.app_runner.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSAppRunnerServicePolicyForECRAccess"
}
### App Runner ###
resource "aws_apprunner_service" "main" {
service_name = "sandbox-service"
source_configuration {
image_repository {
image_configuration {
port = "5000"
}
image_identifier = "${aws_ecr_repository.main.repository_url}:latest"
image_repository_type = "ECR"
}
}
instance_configuration {
instance_role_arn = aws_iam_role.app_runner.arn
}
}
This is the AppRunnerECRAccessRole
which is auto-generated by the Console when creating a new App Runner service. I would assume this same configuration would work, but it isn't.