Missing required field Principal

0

Bellow is what I have to to create an IAM role using terraform. Whenever I init it says that I am missing a field principal? Where/What am I missing?

resource "aws_iam_role" "role_identifier" { name = var.role_name assume_role_policy = jsonencode({ Version = "2012-10-17", #policy language version Statement = [ { Action = "sts:AssumeRole", #Allows role to be assumed Effect = "Allow" Sid = "" Principal = { Service = "ec2.amazonaws.com" } }, { Action = "AssumeRole", Effect = "Allow" } ] }) }

DMaras
preguntada hace 7 meses717 visualizaciones
2 Respuestas
3
Respuesta aceptada

This should do it

resource "aws_iam_role" "role_identifier" {
  name = var.role_name

  assume_role_policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Action = "sts:AssumeRole"
        Effect = "Allow"
        Sid    = ""
        Principal = {
          Service = "ec2.amazonaws.com"
        }
      },
    ]
  })
}
profile picture
EXPERTO
respondido hace 7 meses
0

Hi,

Your policy contains two statements. The first part has Principal but the second part only has the following:

{ Action = "AssumeRole", Effect = "Allow" }

This second part needs to be cleaned up as it looks like it is not required.

profile pictureAWS
Feng_C
respondido hace 7 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas