Skip to content

Commit

Permalink
fix(aws): ECS Service Tagging broken (backport #5954) (#5958)
Browse files Browse the repository at this point in the history
Co-authored-by: Haroon Said <[email protected]>
Co-authored-by: Haroon Said <[email protected]>
  • Loading branch information
3 people authored May 30, 2023
1 parent b291963 commit 39ff811
Showing 1 changed file with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,32 @@ public List<Tag> getResourceTags() {
}

private boolean isTaggingEnabled(AmazonECS ecs) {
Set<String> enabledSettings =
ecs
.listAccountSettings(new ListAccountSettingsRequest().withEffectiveSettings(true))
.getSettings()
.stream()
.filter(e -> Objects.equals("enabled", e.getValue()))
.map(Setting::getName)
.collect(Collectors.toSet());
boolean isServiceLongArnFormatEnabled = false;
boolean isTaskLongArnFormatEnabled = false;

String nextToken = null;
do {
ListAccountSettingsRequest request =
new ListAccountSettingsRequest().withEffectiveSettings(true).withNextToken(nextToken);

ListAccountSettingsResult response = ecs.listAccountSettings(request);

for (Setting setting : response.getSettings()) {
if (setting.getName().equals(SettingName.ServiceLongArnFormat.toString())
&& setting.getValue().equals("enabled")) {
isServiceLongArnFormatEnabled = true;
}

if (setting.getName().equals(SettingName.TaskLongArnFormat.toString())
&& setting.getValue().equals("enabled")) {
isTaskLongArnFormatEnabled = true;
}
}

nextToken = response.getNextToken();
} while (nextToken != null);

return enabledSettings.containsAll(
Set.of(
SettingName.ServiceLongArnFormat.toString(), SettingName.TaskLongArnFormat.toString()));
return isServiceLongArnFormatEnabled && isTaskLongArnFormatEnabled;
}

private String registerAutoScalingGroup(
Expand Down

0 comments on commit 39ff811

Please sign in to comment.