Skip to content
v2.278.0

InstanceProfileAttributes Struct ​

Attributes of an Instance Profile.

Example ​

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
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
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());
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
});
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 ​

instanceProfileArnstringinstance_profile_arnstrinstanceProfileArnStringInstanceProfileArnstringInstanceProfileArn*string required #
The ARN of the InstanceProfile.

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

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole #
The role associated with the InstanceProfile.

Default: no role