# InstanceProfileAttributes

Attributes of an Instance Profile.

Used as argument in: [InstanceProfile.fromInstanceProfileAttributes](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.InstanceProfile.html#frominstanceprofileattributes)

- Source: [`aws-iam/lib/instance-profile.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-iam/lib/instance-profile.ts#L71)
- Type last changed: v2.88.0 · 20 Jul 2023

## Example

TypeScript:

```ts
const role = new iam.Role(this, 'Role', {
  assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
});

const instanceProfile = iam.InstanceProfile.fromInstanceProfileAttributes(this, 'ImportedInstanceProfile', {
  instanceProfileArn: 'arn:aws:iam::account-id:instance-profile/MyInstanceProfile',
  role,
});
```

Python:

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

instance_profile = iam.InstanceProfile.from_instance_profile_attributes(self, "ImportedInstanceProfile",
    instance_profile_arn="arn:aws:iam::account-id:instance-profile/MyInstanceProfile",
    role=role
)
```

Java:

```java
Role role = Role.Builder.create(this, "Role")
        .assumedBy(new ServicePrincipal("ec2.amazonaws.com"))
        .build();

IInstanceProfile instanceProfile = InstanceProfile.fromInstanceProfileAttributes(this, "ImportedInstanceProfile", InstanceProfileAttributes.builder()
        .instanceProfileArn("arn:aws:iam::account-id:instance-profile/MyInstanceProfile")
        .role(role)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var role = new Role(this, "Role", new RoleProps {
    AssumedBy = new ServicePrincipal("ec2.amazonaws.com")
});

var instanceProfile = InstanceProfile.FromInstanceProfileAttributes(this, "ImportedInstanceProfile", new InstanceProfileAttributes {
    InstanceProfileArn = "arn:aws:iam::account-id:instance-profile/MyInstanceProfile",
    Role = role
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
role := iam.NewRole(this, jsii.String("Role"), &RoleProps{
	AssumedBy: iam.NewServicePrincipal(jsii.String("ec2.amazonaws.com")),
})

instanceProfile := iam.InstanceProfile_FromInstanceProfileAttributes(this, jsii.String("ImportedInstanceProfile"), &InstanceProfileAttributes{
	InstanceProfileArn: jsii.String("arn:aws:iam::account-id:instance-profile/MyInstanceProfile"),
	Role: Role,
})
```

## Properties

- `instanceProfileArn`: string (required) — The ARN of the InstanceProfile.

  Format: arn:<partition>:iam::<account-id>:instance-profile/<instance-profile-name-with-path>

- `role`: [IRole](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The role associated with the InstanceProfile.

  **Default:** no role
