mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(acm): give resource-tag conditions the tags of the certificate a request names (#8737)
The generated request resources give ACM's certificate type the aws:ResourceTag/ key, but no service answered the acm namespace's stored tags, so a condition on a certificate's tags saw none. AcmService now answers it: storedTags reads the certificate stored under the key of the Region the ARN names, in the request's account, where the handlers read, in place, and matched on the whole ARN. Tag changes already store a new map under the service's lock; the tags field is now volatile.
This commit is contained in:
1 parent
c6faa73eb7
commit
2fdcbecdf0
6 files changed
+104
-12
No files matched your search
@@ -44,9 +44,9 @@ import java.util.Optional;
|
||||
* another account an association runs and the tags of a parameter, a document or an association; CloudFront, for the
|
||||
* key value store a name names and the tags of any resource it tags; ECS, for the revision a task definition
|
||||
* reference resolves to, its default cluster and the tags of a cluster, a task definition, a service, a capacity
|
||||
* provider, a task or a container instance); 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>
|
||||
* provider, a task or a container instance; ACM, for the tags of a certificate); 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
|
||||
|
||||
@@ -9,9 +9,11 @@ import io.floci.aws.core.common.Digests;
|
||||
import io.floci.aws.core.common.DomainNames;
|
||||
import io.floci.aws.core.common.Pem;
|
||||
import io.floci.aws.core.common.RegionResolver;
|
||||
import io.floci.aws.core.common.StoredResourceArns;
|
||||
import io.floci.aws.core.resource.ExplorerResource;
|
||||
import io.floci.aws.core.resource.ResourceProvider;
|
||||
import io.floci.aws.core.resource.SupportedResourceType;
|
||||
import io.floci.aws.core.storage.AccountAwareStorageBackend;
|
||||
import io.floci.aws.core.storage.StorageBackend;
|
||||
import io.floci.aws.core.storage.StorageFactory;
|
||||
import io.floci.aws.services.acm.model.Certificate;
|
||||
@@ -64,7 +66,7 @@ import java.util.stream.Collectors;
|
||||
* @see <a href="https://docs.aws.amazon.com/acm/latest/APIReference/Welcome.html">AWS ACM API Reference</a>
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class AcmService implements ResourceProvider {
|
||||
public class AcmService implements ResourceProvider, StoredResourceArns {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(AcmService.class);
|
||||
private static final int MAX_TAGS = 50;
|
||||
@@ -572,6 +574,40 @@ public class AcmService implements ResourceProvider {
|
||||
store.put(regionKey(region, cert.extractCertificateId()), cert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String namespace() {
|
||||
return "acm";
|
||||
}
|
||||
|
||||
/** A request names a certificate by its ARN, whose id ACM minted, so there is nothing to find by name. */
|
||||
@Override
|
||||
public Optional<String> find(String type, List<String> names, String region) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* The tags of the certificate whose ARN is {@code arn}, read in place under its key in the Region the ARN names,
|
||||
* in the request's account, where the handlers read: an ARN of another account names none. Tagging stores a new
|
||||
* map under the service's lock, so the read is of one whole set.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> storedTags(String arn) {
|
||||
if (!AwsArnUtils.isArnFor(arn, "acm")) {
|
||||
return Map.of();
|
||||
}
|
||||
AwsArnUtils.Arn parsed = AwsArnUtils.parse(arn);
|
||||
if (!parsed.accountId().equals(regionResolver.getAccountId())
|
||||
|| !parsed.resource().startsWith("certificate/")) {
|
||||
return Map.of();
|
||||
}
|
||||
Map<String, String> tags = AccountAwareStorageBackend.readInAccount(store, parsed.accountId(),
|
||||
regionKey(parsed.region(), Certificate.idFromArn(arn)))
|
||||
.filter(cert -> arn.equals(cert.getArn()))
|
||||
.map(Certificate::getTags)
|
||||
.orElse(Map.of());
|
||||
return new LinkedHashMap<>(tags);
|
||||
}
|
||||
|
||||
// ============ Account Configuration ============
|
||||
|
||||
public int getAccountDaysBeforeExpiry() {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Certificate {
|
||||
private KeyAlgorithm keyAlgorithm;
|
||||
private String signatureAlgorithm;
|
||||
private List<String> inUseBy;
|
||||
private Map<String, String> tags;
|
||||
private volatile Map<String, String> tags;
|
||||
private String certificateBody;
|
||||
private String privateKey;
|
||||
private String certificateChain;
|
||||
|
||||
Reference in new issue
Block a user