InstanceProfileProps

class aws_cdk.aws_iam.InstanceProfileProps(*, instance_profile_name=None, path=None, role=None)

Bases: object

Properties of an Instance Profile.

Parameters:
  • instance_profile_name (Optional[str]) – The name of the InstanceProfile to create. Default: - generated by CloudFormation

  • path (Optional[str]) – The path to the InstanceProfile. Default: /

  • role (Optional[IRole]) – An IAM role to associate with the instance profile that is used by EC2 instances. The role must be assumable by the service principal ec2.amazonaws.com: Default: - a role will be automatically created, it can be accessed via the role property

ExampleMetadata:

infused

Example:

role = iam.Role(self, "Role",
    assumed_by=iam.ServicePrincipal("ec2.amazonaws.com")
)

instance_profile = iam.InstanceProfile(self, "InstanceProfile",
    role=role,
    instance_profile_name="MyInstanceProfile",
    path="/sample/path/"
)

Attributes

instance_profile_name

The name of the InstanceProfile to create.

Default:
  • generated by CloudFormation

path

The path to the InstanceProfile.

Default:

/

role

An IAM role to associate with the instance profile that is used by EC2 instances.

The role must be assumable by the service principal ec2.amazonaws.com:

Default:
  • a role will be automatically created, it can be accessed via the role property

Example:

role = iam.Role(self, "MyRole",
    assumed_by=iam.ServicePrincipal("ec2.amazonaws.com")
)