Difference between revisions of "Terraform resource: aws iam role"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 1: Line 1:
 
<code>[[aws_iam_role]]</code> creates an IAM role ([https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role tf.io]).
 
<code>[[aws_iam_role]]</code> creates an IAM role ([https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role tf.io]).
 +
 +
== Official example ==
 +
resource "aws_iam_role" "test_role" {
 +
  name = "test_role"
 +
 +
  # Terraform's "jsonencode" function converts a
 +
  # Terraform expression result to valid JSON syntax.
 +
  assume_role_policy = jsonencode({
 +
    Version = "2012-10-17"
 +
    Statement = [
 +
      {
 +
        Action = "sts:AssumeRole"
 +
        Effect = "Allow"
 +
        Sid    = ""
 +
        Principal = {
 +
          Service = "ec2.amazonaws.com"
 +
        }
 +
      },
 +
    ]
 +
  })
 +
 +
  [[tags]] = {
 +
    tag-key = "tag-value"
 +
  }
 +
}
  
 
== Errors ==
 
== Errors ==

Revision as of 04:43, 28 March 2023

aws_iam_role creates an IAM role (tf.io).

Official example

resource "aws_iam_role" "test_role" {
 name = "test_role"
 # Terraform's "jsonencode" function converts a
 # Terraform expression result to valid JSON syntax.
 assume_role_policy = jsonencode({
   Version = "2012-10-17"
   Statement = [
     {
       Action = "sts:AssumeRole"
       Effect = "Allow"
       Sid    = ""
       Principal = {
         Service = "ec2.amazonaws.com"
       }
     },
   ]
 })
 tags = {
   tag-key = "tag-value"
 }
}

Errors

Related terms

See also

Advertising: