Resource: aws_iam_instance_profile

Provides an IAM instance profile.

Example Usage

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
}

Argument Reference

The following arguments are optional:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import Instance Profiles using the name. For example:

import {
  to = aws_iam_instance_profile.test_profile
  id = "app-instance-profile-1"
}

Using terraform import, import Instance Profiles using the name. For example:

% terraform import aws_iam_instance_profile.test_profile app-instance-profile-1