Skip to content

Commit 3160fa3

Browse files
authored
Fix custom ec2 tags (#8)
1 parent c3234b4 commit 3160fa3

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

dist/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ActionConfig {
5252
this.ec2InstanceType = core.getInput("ec2_instance_type");
5353
this.ec2AmiId = core.getInput("ec2_ami_id");
5454
this.ec2InstanceIamRole = core.getInput("ec2_instance_iam_role");
55-
this.ec2InstanceTags = JSON.parse(core.getInput("ec2_instance_tags"));
55+
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
5656
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
5757
this.ec2SubnetId = core.getInput("ec2_subnet_id");
5858
this.ec2SecurityGroupId = core.getInput("ec2_security_group_id");
@@ -141,6 +141,11 @@ class Ec2Instance {
141141
});
142142
}
143143
getTags() {
144+
// Parse custom tags
145+
let customTags = [];
146+
if (this.config.ec2InstanceTags) {
147+
customTags = JSON.parse(this.config.ec2InstanceTags);
148+
}
144149
return [
145150
{
146151
Key: "Name",
@@ -161,13 +166,8 @@ class Ec2Instance {
161166
{
162167
Key: "github_repo",
163168
Value: this.config.githubRepo,
164-
}
165-
/*
166-
{
167-
Key: "expiration",
168-
Value: "some time goes here"
169-
},
170-
*/
169+
},
170+
...customTags
171171
];
172172
}
173173
getCrossAccountCredentials() {

src/config/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ActionConfig implements ConfigInterface {
7070
this.ec2InstanceType = core.getInput("ec2_instance_type");
7171
this.ec2AmiId = core.getInput("ec2_ami_id");
7272
this.ec2InstanceIamRole = core.getInput("ec2_instance_iam_role");
73-
this.ec2InstanceTags = JSON.parse(core.getInput("ec2_instance_tags"));
73+
this.ec2InstanceTags = core.getInput("ec2_instance_tags");
7474
this.ec2InstanceTtl = core.getInput("ec2_instance_ttl");
7575
this.ec2SubnetId = core.getInput("ec2_subnet_id");
7676
this.ec2SecurityGroupId = core.getInput("ec2_security_group_id");

src/ec2/ec2.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export class Ec2Instance {
5555
}
5656

5757
getTags() {
58+
// Parse custom tags
59+
let customTags = []
60+
if(this.config.ec2InstanceTags){
61+
customTags = JSON.parse(this.config.ec2InstanceTags);
62+
}
63+
5864
return [
5965
{
6066
Key: "Name",
@@ -75,13 +81,8 @@ export class Ec2Instance {
7581
{
7682
Key: "github_repo",
7783
Value: this.config.githubRepo,
78-
}
79-
/*
80-
{
81-
Key: "expiration",
82-
Value: "some time goes here"
83-
},
84-
*/
84+
},
85+
...customTags
8586
];
8687
}
8788

0 commit comments

Comments
 (0)