mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(oam): give resource-tag conditions the tags of the sink or link a request names (#8710)
The generated request resources give OAM's sink and link types the aws:ResourceTag/ key, but OamService answered no tags, so a condition on a sink's or a link's tags saw none. OamService.storedTags now reads the sink or link stored under the ARN in the account it names, in place, matched on the whole ARN they are kept by. Tagging and untagging now take the service's lock, so two tag calls on one resource keep each other's tags, and the tag fields are volatile; setTags already puts a new map in place of the held one.
This commit is contained in:
1 parent
e0ef191767
commit
7199c8580e
6 files changed
+69
-13
No files matched your search
@@ -25,9 +25,9 @@ import java.util.Optional;
|
||||
* the key an alias names; EMR, for the clusters of its instance groups and a tag call's resource and the tags of a
|
||||
* cluster; IAM Identity Center, for the accounts its permission sets are provisioned to and the tags of an instance,
|
||||
* a permission set, an application or a trusted token issuer; Resource Explorer, for its default view; OAM and RAM,
|
||||
* for the sinks, invitations and shares of other accounts they act on; Secrets Manager, for the secret a name or an
|
||||
* ARN names, random suffix included, and its tags; EventBridge Scheduler, for its default schedule group and its
|
||||
* groups' tags;
|
||||
* for the sinks, invitations and shares of other accounts they act on, and OAM for the tags of a sink or a link;
|
||||
* Secrets Manager, for the secret a name or an ARN names, random suffix included, and its tags; EventBridge
|
||||
* Scheduler, for its default schedule group and its groups' tags;
|
||||
* CloudFormation, for the stack or the stack set a name names, whose id it minted, and the tags of a stack, a stack set
|
||||
* or a change set; S3 Tables, for the table a request names by its table bucket, namespace and name, and the tags of a
|
||||
* table bucket or a table; Lambda, for the layer version a layer version ARN selects, the image of a MicroVM and the
|
||||
|
||||
@@ -186,7 +186,7 @@ public class OamService implements StoredResourceArns {
|
||||
|
||||
public Map<String, String> tags(String arn) { return new LinkedHashMap<>(resourceTags(arn)); }
|
||||
|
||||
public void tag(String arn, Map<String, String> tags) {
|
||||
public synchronized void tag(String arn, Map<String, String> tags) {
|
||||
validateTags(tags);
|
||||
Map<String, String> merged = new LinkedHashMap<>(resourceTags(arn));
|
||||
merged.putAll(tags == null ? Map.of() : tags);
|
||||
@@ -194,7 +194,7 @@ public class OamService implements StoredResourceArns {
|
||||
saveTags(arn, merged);
|
||||
}
|
||||
|
||||
public void untag(String arn, List<String> tagKeys) {
|
||||
public synchronized void untag(String arn, List<String> tagKeys) {
|
||||
if (tagKeys == null) throw missing("TagKeys");
|
||||
Map<String, String> updated = new LinkedHashMap<>(resourceTags(arn));
|
||||
tagKeys.forEach(updated::remove);
|
||||
@@ -235,6 +235,31 @@ public class OamService implements StoredResourceArns {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* The tags held on the sink or link stored under {@code arn}, in the account it names, read in place; both are kept
|
||||
* by their whole ARN, so the ARN is matched whole. Empty for an ARN naming neither.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> storedTags(String arn) {
|
||||
String account = arnAccount(arn);
|
||||
if (account == null || account.isEmpty() || !AwsArnUtils.isArnFor(arn, "oam")) {
|
||||
return Map.of();
|
||||
}
|
||||
Optional<Map<String, String>> tags = Optional.empty();
|
||||
if (arn.contains(":sink/")) {
|
||||
tags = AccountAwareStorageBackend.readInAccount(sinks, account, arn).map(OamSink::getTags);
|
||||
} else if (arn.contains(":link/")) {
|
||||
tags = AccountAwareStorageBackend.readInAccount(links, account, arn).map(OamLink::getTags);
|
||||
}
|
||||
Map<String, String> held = new LinkedHashMap<>();
|
||||
tags.ifPresent(stored -> stored.forEach((key, value) -> {
|
||||
if (key != null && value != null) {
|
||||
held.put(key, value);
|
||||
}
|
||||
}));
|
||||
return held;
|
||||
}
|
||||
|
||||
/** A sink another account owns, which {@code CreateLink} finds in that account and links the caller's to. */
|
||||
@Override
|
||||
public boolean reachedInItsAccount(String arn, String accountId) {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class OamLink {
|
||||
private String sourceAccountId;
|
||||
private List<String> resourceTypes = List.of();
|
||||
private Map<String, Object> linkConfiguration = new LinkedHashMap<>();
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
private volatile Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
public OamLink() {}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class OamSink {
|
||||
private String region;
|
||||
private String ownerAccountId;
|
||||
private String policy;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
private volatile Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
public OamSink() {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user