Difference between revisions of "Terraform resource: aws iam role"
Jump to navigation
Jump to search
Line 16: | Line 16: | ||
* <code>[[CreateRole]]</code> | * <code>[[CreateRole]]</code> | ||
* <code>[[sts:AssumeRole]]</code> | * <code>[[sts:AssumeRole]]</code> | ||
+ | * <code>[[aws_iam_instance_profile]]</code> | ||
== See also == | == See also == |
Revision as of 16:31, 29 May 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" } }
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
Related terms
See also
aws_iam_role: assume_role_policy, iam:CreateRole
- 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: