Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoscaling): bring your own IAM role #1727

Merged
merged 2 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ export interface AutoScalingGroupProps extends CommonAutoScalingGroupProps {
* AMI to launch
*/
machineImage: ec2.IMachineImageSource;

/**
* An IAM role to associate with the instance profile assigned to this Auto Scaling Group.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention that the role must be assumable by { Service: ec2.amazonaws.com }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Added

* @default A role will automatically be created, it can be accessed via the `role` property
*/
role?: iam.IRole;
}

/**
Expand Down Expand Up @@ -187,7 +193,7 @@ export class AutoScalingGroup extends cdk.Construct implements IAutoScalingGroup
/**
* The IAM role assumed by instances of this fleet.
*/
public readonly role: iam.Role;
public readonly role: iam.IRole;

/**
* Name of the AutoScalingGroup
Expand Down Expand Up @@ -217,7 +223,7 @@ export class AutoScalingGroup extends cdk.Construct implements IAutoScalingGroup
this.securityGroups.push(this.securityGroup);
this.apply(new cdk.Tag(NAME_TAG, this.node.path));

this.role = new iam.Role(this, 'InstanceRole', {
this.role = props.role || new iam.Role(this, 'InstanceRole', {
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com')
});

Expand Down
Loading