Difference between revisions of "Terraform resource: aws iam instance profile"

From wikieduonline
Jump to navigation Jump to search
Line 10: Line 10:
 
   statement {
 
   statement {
 
     effect = "Allow"
 
     effect = "Allow"
 
+
 
     principals {
 
     principals {
 
       type        = "Service"
 
       type        = "Service"

Revision as of 12:58, 2 April 2023

Official example

resource "aws_iam_instance_profile" "test_profile" {
 name = "test_profile"
 role = aws_iam_role.role.name
}

data "aws_iam_policy_document" "assume_role" {
 statement {
   effect = "Allow"

   principals {
     type        = "Service"
     identifiers = ["ec2.amazonaws.com"]
   }

   actions = ["sts:AssumeRole"]
 }
}

resource "aws_iam_role" "role" {
 name               = "test_role"
 path               = "/"
 assume_role_policy = data.aws_iam_policy_document.assume_role.json
}

Related

See also

Advertising: