🤖🤖🤖 New Actions: aws_agentregistry_submit_registry_record_for_approval and aws_agentregistry_update_registry_record_status - #49931
Open
pablo19sc wants to merge 10 commits into
Conversation
Add the aws_agentregistry_registry_record resource supporting all four record types (MCP, AGENT, SKILL, CUSTOM) with typed descriptors, URL source synchronization with IAM and OAuth credential providers, tags, resource identity, and two-part (registry_id,record_id) import. UpdateRegistryRecord wraps mutable fields in Updated* optional-value types; updates send a full-desired-state patch so removed descriptor fields are unset. trigger_synchronization is intentionally not exposed as it is a non-convergent action flag.
The UpdateRegistryRecord API takes RecordVersion as a plain string with no Updated* wrapper, so there is no way to clear a version once set. Removing the argument leaves the previous value in place and produces a persistent difference.
Look up a registry record by registry ID and record ID, reusing the resource's descriptor models and finder. Also exposes the read-only status, status_reason, registry_arn, created_at and updated_at fields that the resource does not manage.
Comparing the whole descriptors object fails because unset descriptor types are null lists in resource state but empty lists in the data source. Compare the custom.data leaf and the list size instead, matching the registry data source test approach.
The test-naming and tflint jobs failed in their setup steps with apt-get 'Hash Sum mismatch' errors fetching the Chrome apt index on the runner image, before running any checks. No code changes are needed.
Records are created in DRAFT and are not discoverable until approved. Neither the record resource nor a registry's auto-approval rules submit a record; this action does, and is intended to run on the record's after_create and after_update lifecycle events since any content update returns the record to DRAFT. The action reads the record first: DRAFT is submitted, PENDING_APPROVAL and APPROVED are no-ops (the API rejects resubmission of an APPROVED record), REJECTED and DEPRECATED return descriptive errors with the recovery path, and CREATING/UPDATING are waited on before proceeding.
Curator-side companion to the submit action: approve or reject a PENDING_APPROVAL record, or deprecate a record. The status argument is restricted to APPROVED, REJECTED and DEPRECATED, matching the targets the API accepts. When the record already has the requested status the action returns without calling the API, since repeating a status update overwrites the existing status reason.
Contributor
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
No. Both actions call existing Agent Registry APIs (
SubmitRegistryRecordForApproval,UpdateRegistryRecordStatus) with the caller's credentials and add no new permissions. They preserve the service's publisher/curator separation: submission and approval remain distinct operations that users can bind to different provider identities.Description
Agent Registry records are created in
DRAFTand are not discoverable until approved. Nothing in the provider can move a record out ofDRAFTtoday, so every record created withaws_agentregistry_registry_record(#49918) is invisible to consumers. This also affects registries configured withauto_approval_rules = ["APPROVE_ALL"]: verified against the API, auto-approval does not bypass submission, it only changes where submission lands.This PR includes two Terraform Actions covering the record approval lifecycle.
aws_agentregistry_submit_registry_record_for_approval(publisher side) moves aDRAFTrecord into the approval workflow. Designed to run on the record'safter_createandafter_updateevents, since any content update returns a record toDRAFTand it must be resubmitted.aws_agentregistry_update_registry_record_status(curator side) approves or rejects aPENDING_APPROVALrecord, or deprecates a record.statusis restricted toAPPROVED,REJECTED,DEPRECATED, the only targets the API accepts.With an auto-approval registry, records become discoverable on every apply with one
action_triggerand no manual steps. With manual approval, the publisher's apply leaves the recordPENDING_APPROVALand a curator (typically a separate configuration and IAM principal) invokes the status action withterraform apply -invoke=.... Both actions require Terraform 1.14 or later, consistent with the provider's existing actions.Why two actions in one PR
The contribution guide asks for one resource per PR, and I want to be explicit about why this PR deliberately contains two actions.
They are two halves of a single state machine, and neither is complete or fully reviewable alone:
APPROVEDandREJECTEDare only reachable fromPENDING_APPROVAL, which only submission produces. Its acceptance tests chain both actions on one trigger; a standalone PR would have no way to test approve/reject.REJECTEDrecords is only meaningful once rejection exists. Reviewing its recovery-path messaging in isolation means reviewing behavior nothing can yet trigger.The shared code is one small helper (
waitRegistryRecordSettled, ~25 lines). The two actions are otherwise independent files, so the diff still reads one action at a time, and the commits are split one per action for that reason.Why actions rather than a resource or a
statusargumentConsidered and rejected, in case reviewers wonder:
statusargument on the record resource would fight the governance workflow. If a curator rejects a record out-of-band, the next plan showsREJECTED → APPROVEDas drift and the apply fails, because that transition is invalid. It would also merge publisher and curator permissions into one principal.*_approvalresource has no remote object to import, read, or delete, and has the same drift problem after every record update. Terraform would try to re-approve records a human had rejected.Implementation notes
Behavior below was verified against the live API before implementation; the notes record what the tests rely on.
DRAFTsubmits.PENDING_APPROVALandAPPROVEDare no-ops, which matters because the API is asymmetric here: resubmitting aPENDING_APPROVALrecord succeeds, resubmitting anAPPROVEDrecord fails with aValidationException.REJECTEDandDEPRECATEDreturn errors describing the recovery path (update content to return toDRAFT; deprecation is terminal).CREATING/UPDATINGare waited on, which is the normal case when triggered fromafter_update.status_reason, erasing the original curator's rationale.timeoutonly bounds the pre-action settle wait (default 600s).callersymbol, which is only available in HCP Terraform Stacks on Terraform 1.16+. Noted in the docs.DEPRECATEDis documented with a warning as irreversible: no further submission, approval, or content update is possible, only deletion.AI Usage
This PR was developed with AI assistance. The AI ran the exploratory API tests that established the record status transition matrix, generated both action implementations, their acceptance tests, and documentation following the provider's existing action patterns (
aws_ec2_stop_instance,aws_codebuild_start_build), and ran unit tests,make gen,make quick-fix, andmake swissshepherd. I reviewed the code and the design, and ran all acceptance tests against a real AWS account. I take full responsibility for the change.Relations
Relates #48694
Depends on #49918
Depends on #49922
References
Output from Acceptance Testing
Terraform v1.14.6.