mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ram): give resource-tag conditions the tags of the resource share a request names (#8713)
The generated request resources give RAM's resource-share type the aws:ResourceTag/ and ram:ResourceTag/ keys, but RamService answered no tags, so a condition on a share's tags saw none. RamService.storedTags now reads the share stored under the ARN in the owning account the ARN names, in place, matched on the whole ARN shares are kept by, when the caller may see it as GetResourceShares shows it: one it owns or one made visible to it, so a decision never turns on a share RAM hides from the caller. A share is immutable and tagging stores a new one under the service's lock, so the lookup always reads one whole set of tags.
This commit is contained in:
1 parent
751c97dde6
commit
da39feee4e
5 files changed
+76
-3
No files matched your search
@@ -25,7 +25,8 @@ 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, and OAM for the tags of a sink or a link;
|
||||
* for the sinks, invitations and shares of other accounts they act on, OAM for the tags of a sink or a link, and
|
||||
* RAM for the tags of a resource share;
|
||||
* 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
|
||||
|
||||
@@ -375,6 +375,30 @@ public class RamService implements StoredResourceArns {
|
||||
return share.filter(shared -> !"DELETED".equals(shared.getStatus())).isPresent();
|
||||
}
|
||||
|
||||
/**
|
||||
* The tags held on the resource share stored under {@code arn}, in the account that owns it, which the ARN names,
|
||||
* read in place, when the caller may see that share as GetResourceShares shows it: one it owns, or one another
|
||||
* account made visible to it. Shares are kept by their whole ARN, so the ARN is matched whole. Empty for an ARN
|
||||
* naming no share or one the caller cannot see, so a decision never turns on a share RAM hides from it.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> storedTags(String arn) {
|
||||
if (!isResourceShareArn(arn) || !(shares instanceof AccountAwareStorageBackend<ResourceShare> aware)) {
|
||||
return Map.of();
|
||||
}
|
||||
String caller = aware.accountId();
|
||||
Map<String, String> held = new LinkedHashMap<>();
|
||||
AccountAwareStorageBackend.readInAccount(shares, AwsArnUtils.parse(arn).accountId(), arn)
|
||||
.filter(share -> isVisible(share, caller, "SELF") || isVisible(share, caller, "OTHER-ACCOUNTS"))
|
||||
.map(ResourceShare::getTags)
|
||||
.ifPresent(tags -> tags.forEach((key, value) -> {
|
||||
if (key != null && value != null) {
|
||||
held.put(key, value);
|
||||
}
|
||||
}));
|
||||
return held;
|
||||
}
|
||||
|
||||
private List<ResourceShareInvitation> allInvitations() {
|
||||
if (invitations instanceof AccountAwareStorageBackend<ResourceShareInvitation> accountAware) {
|
||||
return accountAware.scanAllAccounts();
|
||||
|
||||
Reference in new issue
Block a user