mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 15:49:33 -05:00
fix(cloudformation): list a service-managed stack set's targets and tags in DescribeStackSet (#7242)
AWS returns a stack set's tags and the recorded root and OU deployment targets of a service-managed stack set. Read the same saved targets that ListStackSetAutoDeploymentTargets reports. Replace the tag map on UpdateStackSet instead of clearing and refilling a map that a concurrent DescribeStackSet may be reading. Copy the request's tags so the published map is independent of later request changes. Cover both response members, an update interleaved with tag iteration, and request-map isolation with regression tests. Use the shared account-scoped InMemoryStorageFactory for the added regression tests instead of a private factory copy.
This commit is contained in:
1 parent
5bcb83b932
commit
918ce95b53
5 files changed
+136
-3
No files matched your search
+21
@@ -920,6 +920,15 @@ public class CloudFormationQueryHandler {
|
||||
.end("ManagedExecution");
|
||||
appendCapabilities(xml, ss.getCapabilities());
|
||||
appendParameters(xml, ss.getParameters());
|
||||
appendStackSetTags(xml, ss.getTags());
|
||||
if ("SERVICE_MANAGED".equals(ss.getPermissionModel())) {
|
||||
List<String> targets = stackSetService.organizationalUnitIds(ss.getStackSetName());
|
||||
if (!targets.isEmpty()) {
|
||||
xml.start("OrganizationalUnitIds");
|
||||
targets.forEach(target -> xml.elem("member", target));
|
||||
xml.end("OrganizationalUnitIds");
|
||||
}
|
||||
}
|
||||
xml.end("StackSet").end("DescribeStackSetResult")
|
||||
.raw(AwsQueryResponse.responseMetadata())
|
||||
.end("DescribeStackSetResponse");
|
||||
@@ -1168,6 +1177,18 @@ public class CloudFormationQueryHandler {
|
||||
xml.end("Parameters");
|
||||
}
|
||||
|
||||
private void appendStackSetTags(XmlBuilder xml, Map<String, String> tags) {
|
||||
if (tags == null || tags.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
xml.start("Tags");
|
||||
tags.forEach((key, value) -> xml.start("member")
|
||||
.elem("Key", key)
|
||||
.elem("Value", value)
|
||||
.end("member"));
|
||||
xml.end("Tags");
|
||||
}
|
||||
|
||||
private Response xmlError(String code, String message, int status) {
|
||||
String xml = new XmlBuilder()
|
||||
.start("ErrorResponse", CF_NS)
|
||||
|
||||
+12
-2
@@ -228,8 +228,7 @@ public class StackSetService implements PassedRoleLookup {
|
||||
ss.getCapabilities().addAll(capabilities);
|
||||
}
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
ss.getTags().clear();
|
||||
ss.getTags().putAll(tags);
|
||||
ss.setTags(new LinkedHashMap<>(tags));
|
||||
}
|
||||
if (description != null) {
|
||||
ss.setDescription(description);
|
||||
@@ -379,6 +378,17 @@ public class StackSetService implements PassedRoleLookup {
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* The organization root and OU ids a service-managed stack set targets, as DescribeStackSet's
|
||||
* {@code OrganizationalUnitIds} lists them: every target {@code CreateStackInstances} named that still
|
||||
* has a Region.
|
||||
*/
|
||||
public List<String> organizationalUnitIds(String name) {
|
||||
return listStackSetAutoDeploymentTargets(name).stream()
|
||||
.map(StackSetAutoDeploymentTarget::getOrganizationalUnitId)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<StackInstance> listStackInstances(String name, String accountFilter, String regionFilter) {
|
||||
getStackSetOrThrow(name);
|
||||
String prefix = name + ":";
|
||||
|
||||
Reference in new issue
Block a user