Difference between revisions of "Terraform resource: aws iam role"
Jump to navigation
Jump to search
Line 31: | Line 31: | ||
== See also == | == See also == | ||
* {{aws_iam_role_resource}} | * {{aws_iam_role_resource}} | ||
+ | * {{aws_iam_role}} | ||
* {{terraform aws iam resources}} | * {{terraform aws iam resources}} | ||
[[Category:Terraform]] | [[Category:Terraform]] | ||
[[Category:AWS]] | [[Category:AWS]] |
Revision as of 16:04, 10 October 2024
aws_iam_role
creates an IAM role (tf.io).
aws_iam_policy + aws_iam_role -> aws_iam_role_policy_attachment
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" } }
resource "aws_iam_role" "ecs_task_role" { name = "your-ecs-task-role" assume_role_policy = <<-EOF { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "ecs-tasks.amazonaws.com" }, "Action": [ "sts:AssumeRole" ] } ] } EOF }
Errors
Error: expected length of name prefix to be in the range
Error: reading inline policies for IAM role
Related terms
- IAM: AWS IAM role
aws_iam_role_policy_attachment
CreateRole
sts:AssumeRole
,sts:AssumeRoleWithWebIdentity
aws_iam_instance_profile
aws_iam_policy_attachment
Federated
See also
aws_iam_role: assume_role_policy, iam:CreateRole
- AWS IAM role, AWS service roles, AWS IAM Roles Anywhere: [
list-roles | get-role | create-role | put-role-policy | create-service-linked-role | attach-role-policy | update-role | add-role-to-instance-profile ], aws ec2 describe-iam-instance-profile-associations ]
, IAM roles for EC2 instances,AWSServiceRoleForAutoScaling
- Terraform IAM resources:
aws_iam_user, aws_iam_group, aws_iam_role, aws_iam_role_policy_attachment
,aws_iam_policy
,aws_iam_role_policy, aws_iam_user_policy, aws_iam_user_policy_attachment
,aws_iam_access_key, aws_iam_group_policy, aws_iam_group_policy_attachment, aws_iam_openid_connect_provider
Advertising: