Set up and test a record visibility configuration
This topic shows how to add a record visibility configuration to an existing registry, test it with representative callers, and remove it. It also explains when a change takes effect, how to recover from a failed update, and how to read the configuration state.
Prerequisites
Before you set a record visibility configuration, check the permissions and setup in this section. agent-registry:PutRecordVisibilityConfiguration is a permission-only action with no API operation of its own. AWS Agent Registry checks it in addition to the CreateRegistry or UpdateRegistry action.
The following table lists the AWS Identity and Access Management (IAM) actions that each task requires.
| Task | Required actions | Notes |
|---|---|---|
|
Add, replace, or remove a configuration |
|
You need both actions whenever the request includes |
|
Create a registry with a configuration |
|
The service evaluates |
|
Read the current and pending configuration |
|
Only the registry owner’s account receives the configuration state. |
Without PutRecordVisibilityConfiguration, the request returns AccessDeniedException. For the other registry permissions, see IAM Permissions. You also need the following:
-
The owner account and a registry that accepts updates – Only the account that owns the registry can set, replace, or remove its configuration. An
UpdateRegistrycall from another account returnsAccessDeniedExceptionwith the messageCross-account access is not allowed for operation: UpdateRegistry. The registry must beREADY, orUPDATE_FAILEDwhen you retry a failed change. For that case, see Recover from a failed update. While a create or update is in progress, wait for it to finish. To create a registry, see Create a registry. -
IAM credentials for configuration management – Configuration management always uses IAM, even on a registry that uses JSON Web Token (JWT) authorization for discovery. For more information, see Authorization scope.
-
Declared metadata fields – You must declare each
customMetadata/<key>field that a configuration names in the registry’s default schema or in a record-type schema. If one request supplies both a schema and a configuration, the service validates the schema first. For more information, see Define a custom metadata schema. -
Approved, labeled records – A configuration evaluates the approved revision of each record. To create and approve records, see Create and manage records and Reviewing registry records.
-
Controls on the attributes that the configuration trusts – You need to restrict who can set principal tags, token claims, and record labels before a configuration relies on them. For more information, see Security considerations for record visibility configurations.
-
kms:Decryptfor IAM callers on a customer managed key – IAM discovery callers need the AWS Key Management Service (AWS KMS) permissionkms:Decrypton the key for Search and BatchGet. They can also need it for List when a record visibility configuration restricts what they can see. They might need it even when no records come back. For details, see KMS permissions used by each API operation. -
Key permissions for configuration management on a customer managed key – If a registry encrypted with a customer managed key has a custom metadata schema, the IAM principal that manages the configuration also needs the key permissions that
GetRegistryandUpdateRegistryneed to read that schema. For those permissions, see theGetRegistryandUpdateRegistryrows in KMS permissions used by each API operation.
Add or replace a configuration
A registry has one record visibility configuration document. To add a configuration or change it, you send the whole document, and it replaces any current configuration. The following example sets up department access, and the procedures after it apply the example to an existing registry.
On a registry encrypted with a customer managed key, ListDiscoverableRegistryRecords and the MCP list tool can require kms:Decrypt from an IAM caller when a record visibility configuration restricts which records that caller can see. Search and BatchGet already require it. List calls that succeeded before you add a configuration can then fail with an AWS KMS error. Before you add a configuration, allow kms:Decrypt on the key for every IAM principal that lists the registry’s records, in its identity policy and in the key policy. For details, see KMS permissions used by each API operation.
Example – Department access
In this example, each caller discovers only the records labeled with the caller’s department. The example uses the following setup:
-
A trusted caller attribute – Two IAM roles in the owner’s account,
FinanceReaderandLegalReader. An administrator sets adepartmentprincipal tag on each role,financeandlegal, and the roles can’t change their own tags. For more information, see Prevent callers from setting their own principal tags. Both roles can call the discovery operations. For the actions, see Registry data plane actions. -
One schema field – The registry’s default schema declares
departmentas a string, as in the following schema. For instructions, see Defining the schema.{"type": "object", "properties": {"department": {"type": "string"}}} -
One approved, labeled record – The registry has one approved record,
finance-mcp, labeleddepartment=finance. For instructions, see Create a registry record and Approve a record.
Save the following configuration document as configuration.json:
{ "version": "1", "statements": [ { "sid": "same-department", "effect": "Allow", "principal": { "iam:principalTag/department": {"Exists": true} }, "resource": { "customMetadata/department": { "StringEquals": {"ref": "iam:principalTag/department"} } } } ] }
The statement applies to callers that have a department principal tag. Each of those callers discovers the records whose department label equals the caller’s tag value. A record without a department label matches no caller. The following table shows the results that you expect when you test the configuration.
| Caller | Search and List | BatchGet of finance-mcp
|
|---|---|---|
|
|
|
The record |
|
|
No records |
|
|
A role with discovery permissions and no |
No records |
|
The configuration evaluates the registry owner’s own roles in the same way. An administrator role without a department tag discovers nothing from this registry.
Example – Department access on a JWT registry
On a registry that uses JWT authorization, the configuration tests a token claim instead of a principal tag. This variant assumes that your identity provider (IdP) issues a department claim that only IdP administrators can change. For authorizer setup, see Set up a JWT manually with your own identity provider.
{ "version": "1", "statements": [ { "sid": "same-department", "effect": "Allow", "principal": {"jwt:claim/department": {"Exists": true}}, "resource": { "customMetadata/department": {"StringEquals": {"ref": "jwt:claim/department"}} } } ] }
Test it with three users: one whose token carries the department claim finance, one with legal, and one with no department claim. The expected results match the preceding table. If the claim arrives as an array, a record matches when its label equals any element. For the claim values that the configuration accepts, see Supported caller values.
Console
The console sets a configuration on an existing registry. It can’t set a configuration when it creates a registry, so create the registry first and wait until its status is Ready. A new configuration starts with one Allow statement whose principal and resource are both "*".
To define or edit a record visibility configuration
-
Open the registry’s details page in the AWS Agent Registry console
. -
In the Record visibility configuration section, choose Define configuration. If the registry already has a configuration, choose Edit configuration.
-
To select the editing mode, choose Form or JSON. In JSON mode, you can turn on Show schema reference to see the document structure beside the editor.
-
Enter the configuration. For the example, in JSON mode, replace the editor’s whole contents with the contents of
configuration.json. -
Fix any validation errors.
-
Review any suggestions that the console lists. Suggestions don’t block Apply.
-
Choose Apply.
The Record visibility configuration section shows the configuration status. It’s Creating while a first configuration is applied, Updating while a replacement is applied, and Removing while a removal is applied. It’s Defined when the configuration is in force.
Edit configuration opens the current configuration. Apply sends the whole document as a put.
Apply sends a revision only when you edit an existing configuration:
-
Edit configuration – Apply also sends the revision that the editor loaded. If someone changed the configuration after you opened the editor, Apply fails instead of overwriting that change.
-
Define configuration – Apply sends no revision. It can replace a configuration that someone set after you opened the editor. To set a first configuration only if the registry still has none, use the CLI or an SDK with
"revision": "NO_CONFIG". For more information, see Avoid overwriting concurrent changes.
Define configuration or Edit configuration stays in the section, but it’s unavailable while a configuration change is pending or the registry is busy with another change. A change left pending by a failed update also counts. The button shows the reason. In an account that the registry is shared with, the button is unavailable and the section shows Record visibility configuration not available. To an owner whose registry has no configuration, the section shows No record visibility configuration found.
AWS CLI
The following rules apply to CreateRegistry and UpdateRegistry requests from the AWS CLI, an AWS SDK, or the API:
-
Whole-document replacement – A
putreplaces the entire configuration. There’s no partial edit. To change one statement, send the complete new document. -
Exactly one of
putordelete– AnUpdateRegistryrequest whoserecordVisibilityConfigurationhas both members, or neither, returnsValidationExceptionwith the messagerecordVisibilityConfiguration must contain exactly one of put or delete. -
Omit
recordVisibilityConfigurationto keep the configuration – AnUpdateRegistryrequest withoutrecordVisibilityConfigurationkeeps the current configuration. The exception is a retry after a failed update that left a pending configuration change. For more information, see Recover from a failed update. -
A
putneeds a document – Aputmust carry a present, nonempty document. To remove a configuration, senddelete. -
A JSON string, not an object –
CreateRegistrytakes the configuration inrecordVisibilityConfiguration, andUpdateRegistrytakes it inrecordVisibilityConfiguration.put.document. Both are strings that hold the JSON document. Pass your file’s text as that string, and let a tool such asjq --rawfileescape it rather than escaping it by hand. Whitespace counts toward the size limit in Record visibility configuration limits. -
Not
discoveryConfiguration– The registry’sdiscoveryConfigurationmember holds its authorizer settings, not the record visibility configuration. Set the record visibility configuration only throughrecordVisibilityConfiguration.
If the document itself fails validation, the request returns ValidationException with the problems that it found, and nothing changes. For the error format, see Validation errors and paths.
The commands in this topic use the shell variable REGISTRY_ARN for the registry’s Amazon Resource Name (ARN). Set it to your registry’s ARN. To add or replace the configuration, the following AWS CLI commands read configuration.json with jq --rawfile and wrap it in a put, so they send the file’s text without parsing or re-serializing it:
REGISTRY_ARN='arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>' aws agent-registry-control update-registry \ --registry-id "$REGISTRY_ARN" \ --record-visibility-configuration "$(jq -n --rawfile doc configuration.json '{put: {document: $doc}}')" \ --query '{status: status, pending: recordVisibilityConfigurationState.pending.change}' \ --region us-east-1
When the request changes the configuration, the output shows "status": "UPDATING" and "pending": "PUT". If the registry is READY and the document matches the configuration in force, no update runs, and the output shows "status": "READY" and "pending": null. For more information, see Requests that don’t run an update.
To make the replacement conditional on the configuration that you last read, add a revision. For more information, see Avoid overwriting concurrent changes.
As an alternative, you can set the configuration when you create a registry. Pass the file with --record-visibility-configuration, and declare the department field in the same request. Save the schema from the example as common.json. The following AWS CLI commands read common.json and configuration.json:
jq -n --rawfile common common.json '{defaultSchema: $common}' > schema-config.json aws agent-registry-control create-registry \ --name finance-tools \ --custom-metadata-schema-configuration file://schema-config.json \ --record-visibility-configuration file://configuration.json \ --region us-east-1
Registry creation is asynchronous. The configuration stays pending while the registry is CREATING, and it becomes the current configuration when the registry is READY. Before you check discovery results, wait as described in Test a configuration.
AWS SDK
The request rules in the preceding AWS CLI section also apply to the SDKs. The following Python code reads configuration.json as text, and then passes that text as document without parsing or re-serializing it:
import boto3 control = boto3.client('agent-registry-control', region_name='us-east-1') registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>' with open('configuration.json', encoding='utf-8') as f: document = f.read() response = control.update_registry( registryId=registry_arn, recordVisibilityConfiguration={'put': {'document': document}}, ) pending = response.get('recordVisibilityConfigurationState', {}).get('pending') print(response['status'], pending['change'] if pending else 'no pending change')
When the request changes the configuration, the script prints UPDATING PUT. If the registry is READY and the document matches the configuration in force, no update runs, and the script prints READY no pending change. To set the configuration when you create a registry instead, pass recordVisibilityConfiguration=document to create_registry, with the schema in customMetadataSchemaConfiguration.
Test a configuration
Validation checks a configuration’s syntax, field names, operators, schema declarations, and limits. It doesn’t check that tag names, claim names, or literal values exist, and nothing simulates which records a caller sees. To confirm visibility, test the configuration with real callers against known approved records. For more information about the checks, see Validation.
Before you test, wait for the configuration change to take effect. An accepted UpdateRegistry request doesn’t mean that the new configuration already applies. The following command waits until the registry is READY:
aws agent-registry-control wait registry-ready \ --registry-id "$REGISTRY_ARN" --region us-east-1
In the AWS SDK for Python (Boto3), use the registry_ready waiter:
import boto3 control = boto3.client('agent-registry-control', region_name='us-east-1') registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>' control.get_waiter('registry_ready').wait(registryId=registry_arn)
If the waiter fails, check the registry status. If it’s still CREATING or UPDATING, run the waiter again. If it’s UPDATE_FAILED or CREATE_FAILED, see Recover from a failed update.
After the registry is READY, wait 30 seconds before you check the results. For more information, see When the new configuration applies.
Start with the expected results of the department example. As each role, run Search, run List until the response has no nextToken, and run BatchGet on the known record ID. A List paged to the end and a BatchGet on a known record ID show whether the caller can discover a record. Search returns only the records that match its query, so use it to check that query. Use the CLI, an SDK, or an HTTP client. The console can’t run BatchGet on an arbitrary record ID, and its Record directory isn’t available for registries that use JWT authorization.
The following AWS CLI commands make the three calls as FinanceReader, through a named profile, finance-reader. They use the shell variable RECORD_ID for the ID of finance-mcp.
aws agent-registry search-discoverable-registry-records \ --registry-ids "$REGISTRY_ARN" --search-query "finance" \ --query 'registryRecords[].name' \ --profile finance-reader --region us-east-1 aws agent-registry list-discoverable-registry-records \ --registry-id "$REGISTRY_ARN" --max-results 50 \ --query '{names: registryRecords[].name, nextToken: nextToken}' \ --profile finance-reader --region us-east-1 aws agent-registry batch-get-discoverable-registry-record \ --entries "[{\"registryId\": \"$REGISTRY_ARN\", \"recordIds\": [\"$RECORD_ID\"]}]" \ --query '{records: registryRecords[].name, errors: errors[].errorCode}' \ --profile finance-reader --region us-east-1
As FinanceReader, each call returns finance-mcp. Run the commands again with a LegalReader profile. Search and List return no records, and BatchGet returns RESOURCE_NOT_FOUND for the record in errors. A List response can include a nextToken, even on a short or empty page. When it does, run the command again with --next-token. For more information, see Response ordering and pagination.
With the AWS SDK for Python (Boto3), make the same calls with a session for each role. In the following code, record_id holds the ID of finance-mcp, and the Search and List paginators follow nextToken through every page, including empty pages. Before you conclude that a caller can’t discover a record, check every page of List and the BatchGet result. A record missing from Search shows only that it isn’t among that query’s results.
import boto3 registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>' record_id = '<recordId>' discovery = boto3.Session(profile_name='finance-reader').client( 'agent-registry', region_name='us-east-1') searched = discovery.get_paginator('search_discoverable_registry_records').paginate( registryIds=[registry_arn], searchQuery='finance') listed = discovery.get_paginator('list_discoverable_registry_records').paginate( registryId=registry_arn) batch = discovery.batch_get_discoverable_registry_record( entries=[{'registryId': registry_arn, 'recordIds': [record_id]}]) print([r['name'] for page in searched for r in page['registryRecords']]) print([r['name'] for page in listed for r in page['registryRecords']]) print([r['name'] for r in batch['registryRecords']], [e['errorCode'] for e in batch['errors']])
BatchGet can return a newly approved record before Search and List do, while indexing catches up. If they don’t return a newly approved record, wait a few seconds and try again. For more information, see Eventual consistency in AWS Agent Registry search.
When the example works, test your own configuration in a non-production registry with the same authorization type, schema, and configuration.
To test your own configuration
-
For each caller and record, write down whether you expect the caller to discover the record.
-
Create and approve test records for each case that the configuration distinguishes, where your schema allows them. For example, create one record for each permitted label, one with another label, one with a label in a different case, and one with no label. If the configuration names a field that some record types don’t declare, add a record of such a type.
-
Get credentials or tokens for a caller of each audience, for callers that lack each tested attribute, and for the owner’s own roles.
-
As each caller, run Search and List through every page, and BatchGet on the known record IDs.
-
Compare the results with your expectations, allowing for indexing.
-
Resolve each mismatch before you apply the configuration to a production registry.
For help with unexpected results, see Record visibility configurations in the troubleshooting topic.
Remove a configuration
Removing a configuration restores discovery without a configuration. Every caller can then discover every approved record that its permissions allow, except quarantined records. Removal doesn’t hide records. To hide every record instead, keep a configuration that does so. For an example, see Hide every record on purpose.
To remove a configuration, send UpdateRegistry with recordVisibilityConfiguration.delete. When the update finishes, the registry has no configuration.
Removal runs a registry update, like any configuration change. For more information, see How a configuration change takes effect.
Console
To remove a record visibility configuration
-
Open the registry’s details page in the AWS Agent Registry console
. -
In the Record visibility configuration section, choose Edit configuration.
-
In the configuration editor, choose Clear configuration.
-
In the Clear record visibility configuration? dialog, choose Clear configuration.
The configuration status changes to Removing. When the registry is Ready, the registry has no configuration. The console sends the removal without a revision. To remove a configuration conditionally, use the CLI or an SDK.
AWS CLI
The following command removes the configuration without a precondition. To make the removal conditional, send '{"delete": {"revision": "<revision>"}}' with the current revision instead.
aws agent-registry-control update-registry \ --registry-id "$REGISTRY_ARN" \ --record-visibility-configuration '{"delete": {}}' \ --query '{status: status, pending: recordVisibilityConfigurationState.pending.change}' \ --region us-east-1
With a configuration in force, the output shows "status": "UPDATING" and "pending": "DELETE". When the update finishes, get-registry returns no recordVisibilityConfigurationState. If the registry is READY and has no configuration, no update runs, and the output shows "status": "READY" and "pending": null.
AWS SDK
The following code removes the configuration without a precondition. To make the removal conditional, pass {'delete': {'revision': revision}}.
import boto3 control = boto3.client('agent-registry-control', region_name='us-east-1') registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>' response = control.update_registry(registryId=registry_arn, recordVisibilityConfiguration={'delete': {}}) pending = response.get('recordVisibilityConfigurationState', {}).get('pending') print(response['status'], pending['change'] if pending else 'no pending change')
With a configuration in force, the code prints UPDATING DELETE. If the registry is READY and has no configuration, no update runs, and the code prints READY no pending change.
How a configuration change takes effect
An accepted configuration change runs a registry update. UpdateRegistry returns HTTP 202 and moves the registry to UPDATING. While the update runs, control-plane record operations, such as creating, approving, and getting records, return ConflictException.
The following table shows how the registry status affects a configuration change request.
| Registry status | Configuration change request |
|---|---|
|
|
Accepted |
|
|
|
|
|
Accepted as a retry. For more information, see Recover from a failed update. |
|
|
|
When the new configuration applies
A configuration change takes effect within 30 seconds after the registry returns to READY. Until then, discovery can still reflect the previous configuration. Adding, changing, or removing a record visibility configuration can also make a caller’s earlier List and Search tokens stop working. To start a list again, see Response ordering and pagination. To start a search again, see Page through search results.
Other changes reach discovery on their own schedules. The following table shows when discovery reflects each change.
| Change | When discovery reflects it |
|---|---|
|
A new approval, or new labels on a newly approved revision |
BatchGet can reflect it first. Search follows indexing, and so does List when a record visibility configuration restricts which records the caller can see. For more information, see Eventual consistency in AWS Agent Registry search. |
|
A rejection of the record’s approved revision while it’s the latest revision, or a deprecation of the record |
Within seconds |
|
AWS tags on a role, user, registry, or record |
Follows IAM timing. For more information, see Changes that I make are not always immediately visible in the IAM User Guide. |
|
A change to an AWS Resource Access Manager (AWS RAM) share |
Follows AWS RAM timing. For more information, see the AWS RAM User Guide. |
|
Session tags and JWT claims |
Fixed when the session or token is issued. The caller needs a new session or token to pick up a change. |
Requests that don’t run an update
In READY, an UpdateRegistry request that changes no setting returns status READY without running an update. A put of the configuration in force, or a delete without a revision when no configuration is in force, changes nothing.
In UPDATE_FAILED, an unchanged request reruns the update instead.
Relabeled records narrow visibility once indexed
Suppose that a newly approved revision changes a record’s labels, so that the configuration narrows who can discover the record. The narrowing applies once that revision is indexed. Until indexing catches up, Search can still return the previous approved revision to callers entitled to it, and so can List when a record visibility configuration restricts which records the caller can see.
AWS Agent Registry never returns the narrowed revision to a caller that the configuration excludes. BatchGet can reflect a newly approved revision before Search does.
For example, suppose that you approve a new revision of finance-mcp labeled department=legal. Until the new revision is indexed, Search can still return the earlier finance revision to FinanceReader. FinanceReader never receives the legal revision.
A change to the configuration document isn’t tied to indexing. To remove a record from every caller’s results quickly, change its status, as described in the following section.
Withdraw a record urgently
To withdraw a record from every caller, change its status with UpdateRegistryRecordStatus. The change reaches every discovery API within seconds. Choose the status as follows:
-
Reject the approved revision – If the record’s latest revision is the approved one, rejecting it withdraws that approval. You can approve the revision again later.
-
Deprecate the record – Deprecation removes the record from discovery, even when a newer revision is pending approval. Deprecation is final.
Rejecting a newer revision that is pending approval doesn’t withdraw an older approved revision. The older revision stays discoverable. In that case, deprecate the record. For more information, see Record lifecycle.
Use a Deny statement on recordId only when you need to hide a record from some audiences. A configuration change takes effect only after its registry update finishes. Record status changes need a READY registry, so you can’t change a record’s status while a configuration update runs.
Recover from a failed update
If a registry update fails, the registry status is UPDATE_FAILED. If the failed update changed the record visibility configuration, the previous configuration stays current and the change stays pending.
When a configuration change is pending, a retry must include recordVisibilityConfiguration.put or recordVisibilityConfiguration.delete. If GetRegistry returns no recordVisibilityConfigurationState.pending, nothing is pending, and you can retry the update without recordVisibilityConfiguration. When a configuration change is pending, the following retries apply:
| Retry | Result |
|---|---|
|
Send the pending change again: a |
Retries the update with that change. |
|
|
Replaces the pending change and retries the update. |
|
|
Discards the pending change and reruns the update. |
|
|
With a configuration in force, removes the configuration when the update succeeds. With no configuration in force, discards the pending change and reruns the update. |
|
Omit |
Returns |
In UPDATE_FAILED, a request that changes nothing still reruns the update. A failed creation, CREATE_FAILED, keeps its pending configuration until you delete the registry.
To retry a pending put from the AWS CLI, read the pending document and send it again.
PENDING=$(aws agent-registry-control get-registry --registry-id "$REGISTRY_ARN" \ --query recordVisibilityConfigurationState.pending.document --output text --region us-east-1) aws agent-registry-control update-registry --registry-id "$REGISTRY_ARN" \ --record-visibility-configuration "$(jq -n --arg doc "$PENDING" '{put: {document: $doc}}')" \ --query status --output text --region us-east-1
The second command prints UPDATING. If pending.change is DELETE, the first command prints None. In that case, send '{"delete": {}}' instead.
Avoid overwriting concurrent changes
To make sure that you replace or remove the configuration that you last read, send its revision as a precondition. If someone changed the configuration in the meantime, the request fails instead of overwriting their change. Revisions work as follows:
-
Each committed change, including a removal, gets a new revision. Treat a revision as an opaque value. For a conditional
putordelete, send backrecordVisibilityConfigurationState.current.revisionfromGetRegistryunchanged. -
A stale revision returns
ConflictException, even when the request would otherwise change nothing. -
putwith"revision": "NO_CONFIG"sets the configuration only if no configuration is in force. -
deletecan’t useNO_CONFIG. The request returnsValidationExceptionwith the messagerecordVisibilityConfiguration.delete.revision cannot be NO_CONFIG. -
A mismatch returns
ConflictException, for examplerecordVisibilityConfiguration.put.revision does not match the record visibility configuration in force. -
A request without a revision is unconditional. The registry status rules still apply.
The language version inside the document, "1", identifies the configuration language. It isn’t the revision. In the console, Apply sends the loaded revision only when you edit an existing configuration. Apply on a first configuration and Clear configuration send no revision.
AWS CLI
Read the current revision, and then send it with the replacement. If the registry has no configuration in force, the first command returns NO_CONFIG, so the put succeeds only while the registry still has none.
REVISION=$(aws agent-registry-control get-registry --registry-id "$REGISTRY_ARN" \ --query "recordVisibilityConfigurationState.current.revision || 'NO_CONFIG'" --output text --region us-east-1) aws agent-registry-control update-registry --registry-id "$REGISTRY_ARN" \ --record-visibility-configuration "$(jq -n --rawfile doc configuration.json --arg rev "$REVISION" \ '{put: {document: $doc, revision: $rev}}')" \ --query status --output text --region us-east-1
When the request changes the configuration, the second command prints UPDATING. If the registry is READY and the document matches the configuration in force, the second command prints READY. If it returns ConflictException, someone might have changed the configuration after you read it, or the registry might be busy with another change. Read the registry again, and check its status and the configuration’s revision. If the configuration changed, reconcile the other change with yours. Then retry with the current revision. For the messages that name a specific cause, see ConflictException when you set or remove a record visibility configuration.
AWS SDK
The following code reads the revision and sends it with the replacement configuration from configuration.json.
import boto3 control = boto3.client('agent-registry-control', region_name='us-east-1') registry_arn = 'arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>' with open('configuration.json', encoding='utf-8') as f: document = f.read() registry = control.get_registry(registryId=registry_arn) current = registry.get('recordVisibilityConfigurationState', {}).get('current') revision = current['revision'] if current else 'NO_CONFIG' try: control.update_registry(registryId=registry_arn, recordVisibilityConfiguration={ 'put': {'document': document, 'revision': revision}}) except control.exceptions.ConflictException as error: # A concurrent change, or a registry that is busy with another change print('UpdateRegistry returned ConflictException:', error)
If the request returns ConflictException, the code prints UpdateRegistry returned ConflictException: and the error. The configuration might have changed after you read it, or the registry might be busy. Read the registry again, and check its status and the configuration’s revision. If the configuration changed, reconcile the current document with your intended change, and then retry with the current revision. For the messages that name a specific cause, see ConflictException when you set or remove a record visibility configuration.
Check the configuration state
GetRegistry and UpdateRegistry return the configuration state in recordVisibilityConfigurationState. The following table describes its members.
| Member | Description |
|---|---|
|
|
The configuration in force, as a JSON string. Absent when the registry has no configuration. |
|
|
The revision of the configuration in force. |
|
|
|
|
|
The pending configuration, for a |
Only the registry owner’s account receives recordVisibilityConfigurationState. The member is absent when the registry has no current configuration and no pending change. ListRegistries never includes configuration state, and a caller in an account that the registry is shared with receives none.
When an update succeeds, the registry returns to READY, the pending configuration becomes current, and pending disappears. A successful removal leaves no current configuration.
The returned document can be formatted differently from the text that you sent, for example without whitespace. To compare a local file with the configuration in force, compare parsed JSON rather than text, for example with jq -S.