Skip to content

Commit

Permalink
#1877 tag by talk name
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Feb 27, 2024
1 parent 039841c commit 4ffe471
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/com/rultor/agents/aws/StartsInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public Iterable<Directive> process(final XML xml) throws IOException {
"SSH key is empty, it's a mistake"
);
}
final Instance instance = this.run();
final Instance instance = this.run(xml.xpath("/talk/@name").get(0));
Logger.info(
this, "EC2 instance %s on %s started in %s",
instance.getInstanceId(), instance.getPublicIpAddress(),
Expand All @@ -152,9 +152,10 @@ public Iterable<Directive> process(final XML xml) throws IOException {

/**
* Run a new instance.
* @param talk Name of the talk
* @return Instance ID
*/
private Instance run() {
private Instance run(final String talk) {
final RunInstancesRequest request = new RunInstancesRequest()
.withSecurityGroupIds(this.sgroup)
.withSubnetId(this.subnet)
Expand All @@ -174,7 +175,7 @@ private Instance run() {
this.api.aws().createTags(
new CreateTagsRequest()
.withResources(iid)
.withTags(new Tag().withKey("name").withValue("rultor"))
.withTags(new Tag().withKey("name").withValue(talk))
);
while (true) {
final DescribeInstanceStatusResult res = this.api.aws().describeInstanceStatus(
Expand Down

0 comments on commit 4ffe471

Please sign in to comment.