Skip to content

Commit

Permalink
Fix custom ec2 tags (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdi-torabi authored Feb 1, 2024
1 parent c3234b4 commit 3160fa3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
16 changes: 8 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ActionConfig {
this.ec2InstanceType = core.getInput("ec2_instance_type");
this.ec2AmiId = core.getInput("ec2_ami_id");
this.ec2InstanceIamRole = core.getInput("ec2_instance_iam_role");
this.ec2InstanceTags = JSON.parse(core.getInput("ec2_instance_tags"));
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
this.ec2SubnetId = core.getInput("ec2_subnet_id");
this.ec2SecurityGroupId = core.getInput("ec2_security_group_id");
Expand Down Expand Up @@ -141,6 +141,11 @@ class Ec2Instance {
});
}
getTags() {
// Parse custom tags
let customTags = [];
if (this.config.ec2InstanceTags) {
customTags = JSON.parse(this.config.ec2InstanceTags);
}
return [
{
Key: "Name",
Expand All @@ -161,13 +166,8 @@ class Ec2Instance {
{
Key: "github_repo",
Value: this.config.githubRepo,
}
/*
{
Key: "expiration",
Value: "some time goes here"
},
*/
},
...customTags
];
}
getCrossAccountCredentials() {
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ActionConfig implements ConfigInterface {
this.ec2InstanceType = core.getInput("ec2_instance_type");
this.ec2AmiId = core.getInput("ec2_ami_id");
this.ec2InstanceIamRole = core.getInput("ec2_instance_iam_role");
this.ec2InstanceTags = JSON.parse(core.getInput("ec2_instance_tags"));
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
this.ec2SubnetId = core.getInput("ec2_subnet_id");
this.ec2SecurityGroupId = core.getInput("ec2_security_group_id");
Expand Down
15 changes: 8 additions & 7 deletions src/ec2/ec2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export class Ec2Instance {
}

getTags() {
// Parse custom tags
let customTags = []
if(this.config.ec2InstanceTags){
customTags = JSON.parse(this.config.ec2InstanceTags);
}

return [
{
Key: "Name",
Expand All @@ -75,13 +81,8 @@ export class Ec2Instance {
{
Key: "github_repo",
Value: this.config.githubRepo,
}
/*
{
Key: "expiration",
Value: "some time goes here"
},
*/
},
...customTags
];
}

Expand Down

0 comments on commit 3160fa3

Please sign in to comment.