Skip to content

Commit

Permalink
allow specifying keypairs
Browse files Browse the repository at this point in the history
  • Loading branch information
ludamad committed Apr 15, 2024
1 parent 058abf0 commit 4976f14
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ inputs:
ec2_subnet_id:
description: 'Subnet id'
required: true
ec2_key_name:
description: 'EC2 keypair name'
required: true
ec2_spot_instance_strategy:
description: >
Spot instance scheduling modes:
None -> (default) no spot instances, use on-demand
SpotOnly -> Strictly spot instances only
BestEffort -> Use spot instances whenever they are cheaper than on-demand
MaxPerformance -> Use the largest spot instance in same class for <= the on-demand price
MaxPerformance -> Use the largest spot instance in same class for <= the on-demand price
required: false
default: "none"
Expand Down
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ActionConfig {
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
this.ec2SubnetId = core.getInput("ec2_subnet_id");
this.ec2KeyName = core.getInput("ec2_key_name");
this.ec2SecurityGroupId = core.getInput("ec2_security_group_id");
this.ec2SpotInstanceStrategy = core
.getInput("ec2_spot_instance_strategy")
Expand Down Expand Up @@ -343,6 +344,7 @@ class Ec2Instance {
MinCount: 1,
SecurityGroupIds: [this.config.ec2SecurityGroupId],
SubnetId: this.config.ec2SubnetId,
KeyName: this.config.ec2KeyName,
Placement: {
AvailabilityZone: yield this.getSubnetAz(),
},
Expand Down
3 changes: 3 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface ConfigInterface {
ec2InstanceTtl: string;
ec2SecurityGroupId: string;
ec2SubnetId: string;
ec2KeyName: string;
ec2SpotInstanceStrategy: string;
}

Expand All @@ -50,6 +51,7 @@ export class ActionConfig implements ConfigInterface {
ec2InstanceTtl: string;
ec2SecurityGroupId: string;
ec2SubnetId: string;
ec2KeyName: string;
ec2SpotInstanceStrategy: string;

constructor() {
Expand Down Expand Up @@ -79,6 +81,7 @@ export class ActionConfig implements ConfigInterface {
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
this.ec2SubnetId = core.getInput("ec2_subnet_id");
this.ec2KeyName = core.getInput("ec2_key_name");
this.ec2SecurityGroupId = core.getInput("ec2_security_group_id");
this.ec2SpotInstanceStrategy = core
.getInput("ec2_spot_instance_strategy")
Expand Down
1 change: 1 addition & 0 deletions src/ec2/ec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export class Ec2Instance {
MinCount: 1,
SecurityGroupIds: [this.config.ec2SecurityGroupId],
SubnetId: this.config.ec2SubnetId,
KeyName: this.config.ec2KeyName,
Placement: {
AvailabilityZone: await this.getSubnetAz(),
},
Expand Down

0 comments on commit 4976f14

Please sign in to comment.