fix(timestream-influxdb): give resource-tag conditions the tags of the resource a request names (#8803)

The generated request resources give Timestream for InfluxDB's
db-instance, db-cluster, db-parameter-group and db-backup types the
aws:ResourceTag/ key, but no service answered the timestream-influxdb
namespace's stored tags, so a condition on such a resource's tags saw
none. TimestreamInfluxDbService now answers it: storedTags reads the
resource the ARN's type and id name, under the Region the ARN names, in
the request's account, where the handlers read, in place, and matched
on the whole ARN. Tag calls already run one at a time and give the
resource a new map; the tags fields are now volatile.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-17 22:19:08 -04:00
1 parent f06695cf08
commit 77565a9c60
9 files changed
+134 -15

No files matched your search

@@ -47,9 +47,10 @@ import java.util.Optional;
* provider, a task or a container instance; ACM, for the tags of a certificate; Firehose, for the tags of a delivery
* stream; Cognito, for the tags of a user pool or an identity pool; OpenSearch, for the tags of a domain; Signer, for
* the tags of a signing profile; Access Analyzer, for the tags of an analyzer; Managed Service for Apache Flink, for
* the tags of an application; S3 Vectors, for the tags of a vector bucket or an index); looked up lazily by
* {@code ResourceArnBuilder} and {@code IamConditionContextResolver} through {@code Instance<StoredResourceArns>} for
* the namespace a request or an ARN is of, so IAM never depends on that service directly.</p>
* the tags of an application; S3 Vectors, for the tags of a vector bucket or an index; Timestream for InfluxDB, for the
* tags of a DB instance, a DB cluster, a parameter group or a backup); looked up lazily by {@code ResourceArnBuilder}
* and {@code IamConditionContextResolver} through {@code Instance<StoredResourceArns>} for the namespace a request or
* an ARN is of, so IAM never depends on that service directly.</p>
*
* <p>Each answer is a lookup of what the service holds, asked for by an entry of the generated table ({@code find},
* {@code through}, a default, {@code forwarded}, a type's {@code resourceTagKeys}): never a fact about what an operation acts on, which the table alone
@@ -10,6 +10,7 @@ import io.floci.aws.core.common.PaginatedResult;
import io.floci.aws.core.common.Pagination;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.common.Resettable;
import io.floci.aws.core.common.StoredResourceArns;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.secretsmanager.SecretsManagerService;
@@ -50,7 +51,7 @@ import static io.floci.aws.services.timestreaminfluxdb.TimestreamInfluxDbValidat
import static io.floci.aws.services.timestreaminfluxdb.TimestreamInfluxDbValidation.validation;
@ApplicationScoped
public class TimestreamInfluxDbService implements Resettable {
public class TimestreamInfluxDbService implements Resettable, StoredResourceArns {
static final String ENGINE_V2 = "INFLUXDB_V2";
static final String ENGINE_V3_CORE = "INFLUXDB_V3_CORE";
@@ -785,6 +786,44 @@ public class TimestreamInfluxDbService implements Resettable {
saveTags(arn, tags);
}
@Override
public String namespace() {
return "timestream-influxdb";
}
/** A request names a resource by the id Timestream for InfluxDB minted, which its ARN ends in: nothing to find. */
@Override
public Optional<String> find(String type, List<String> names, String region) {
return Optional.empty();
}
/**
* The tags of the DB instance, DB cluster, parameter group or backup whose ARN is {@code arn}, in the request's
* account, where the handlers read: an ARN of another account names none. Read in place under the Region the ARN
* names and the resource's id, a resource stored before storage was account-aware included, and matched on the
* whole ARN. Tag calls run one at a time and give the resource a new map, so the read is of one whole set.
*/
@Override
public Map<String, String> storedTags(String arn) {
Matcher matcher = arn == null ? null : TimestreamInfluxDbValidation.ARN.matcher(arn);
if (matcher == null || !matcher.matches() || !matcher.group(2).equals(regionResolver.getAccountId())) {
return Map.of();
}
String account = matcher.group(2);
String storageKey = key(matcher.group(1), matcher.group(4));
Optional<Map<String, String>> tags = switch (matcher.group(3)) {
case "db-instance" -> AccountAwareStorageBackend.readInAccount(instances, account, storageKey)
.filter(instance -> arn.equals(instance.getArn())).map(DbInstance::getTags);
case "db-cluster" -> AccountAwareStorageBackend.readInAccount(clusters, account, storageKey)
.filter(cluster -> arn.equals(cluster.getArn())).map(DbCluster::getTags);
case "db-parameter-group" -> AccountAwareStorageBackend.readInAccount(parameterGroups, account, storageKey)
.filter(group -> arn.equals(group.getArn())).map(DbParameterGroup::getTags);
default -> AccountAwareStorageBackend.readInAccount(backups, account, storageKey)
.filter(backup -> arn.equals(backup.getArn())).map(DbBackup::getTags);
};
return new LinkedHashMap<>(tags.orElse(Map.of()));
}
/**
* Starts the InfluxDB containers of resources persisted by a previous run. Their volumes still
* hold the data and CLI configuration, so the image skips its setup mode and needs no credentials.
@@ -38,7 +38,7 @@ public class DbBackup {
private String influxAuthParametersSecretArn;
private JsonNode maintenanceSchedule;
private JsonNode dbBackupConfigurations;
private Map<String, String> tags = new LinkedHashMap<>();
private volatile Map<String, String> tags = new LinkedHashMap<>();
private String accountId;
private String region;
private boolean dataCaptured;
@@ -36,7 +36,7 @@ public class DbCluster {
private JsonNode dbBackupConfigurations;
private String kmsKeyId;
private Instant createdAt;
private Map<String, String> tags = new LinkedHashMap<>();
private volatile Map<String, String> tags = new LinkedHashMap<>();
private String accountId;
private String region;
private String containerId;
@@ -38,7 +38,7 @@ public class DbInstance {
private String kmsKeyId;
private String engineType;
private Instant createdAt;
private Map<String, String> tags = new LinkedHashMap<>();
private volatile Map<String, String> tags = new LinkedHashMap<>();
private String accountId;
private String region;
private String containerId;
@@ -16,7 +16,7 @@ public class DbParameterGroup {
private JsonNode parameters;
private String engineType;
private Instant createdAt;
private Map<String, String> tags = new LinkedHashMap<>();
private volatile Map<String, String> tags = new LinkedHashMap<>();
public DbParameterGroup() {
}