Repository navigation
Feature/appsync events cfn - #8912
MasterOfMastersDestoyerOfWorlds wants to merge 2 commits into
Conversation
Add the AppSync Events API resource (CreateApi, GetApi, UpdateApi, DeleteApi, ListApis) on /v2/apis. API Gateway v2 serves the same paths, so a pre-matching AppSyncEventsRouteFilter moves appsync-signed requests onto an internal prefix served by AppSyncApiController. CreateApi and UpdateApi validate the event config: at least one auth provider, provider-specific required config, and every connection, publish and subscribe mode must name a configured provider. dns.HTTP and dns.REALTIME carry the partition-aware AWS hosts. DeleteApi cascades to channel namespaces, API keys and domain associations. Channel namespaces, API keys and tags now resolve either an Events API or a GraphQL API. Channel namespaces store and validate publish and subscribe auth modes, handlerConfigs and tags, enforce the model's name pattern, use the channelNamespace/ ARN segment from the AWS Service Authorization Reference, and report created and lastModified in epoch seconds instead of epoch milliseconds.
…hannelNamespace Serve the two AppSync Events resource types from AppSyncCfnProvisioner instead of stubbing them. Api: Ref is the ApiArn, the registry schema's primary identifier, and Fn::GetAtt serves ApiId, ApiArn, Dns.Http and Dns.Realtime. Every change is an in-place UpdateApi addressed by the recorded ApiId. UpdateApi takes no tags, so the template's tags are set through an internal replaceApiTags call. ChannelNamespace: Ref and ChannelNamespaceArn are the namespace ARN. ApiId and Name are create-only; other changes update in place, and a dropped mode list, CodeHandlers or HandlerConfigs is cleared. CodeS3Location is refused with ValidationError. Both types snapshot before an in-place update and replay it on rollback, and their deletes tolerate only NotFoundException. Register the types in the resource inventory, regenerate create-only-properties.json and schema-surface.tsv from the registry schemas, record drop policies and the nested Dns attribute gap, and regenerate the CloudFormation docs table.
PR Summary by QodoAdd AppSync Events API management and CloudFormation resources
AI Description
Merge Risk
|
Code Review by Qodo
1. Events API config checks are untested for most providers
|
| private void requireConfigMember(AuthenticationType type, String configName, Map<String, Object> config, | ||
| String member) { | ||
| String value = config == null ? null : coerceString(config.get(member)); | ||
| if (value == null || value.isBlank()) { |
There was a problem hiding this comment.
1. Events api config checks are untested for most providers 📘 Rule violation ≡ Correctness
requireConfigMember rejects a missing userPoolId or awsRegion on a Cognito provider and a missing issuer on an OIDC provider, and parseEventConfig rejects a bad logConfig.logLevel or a missing cloudWatchLogsRoleArn. The new AppSyncServiceTest cases only exercise the AWS_LAMBDA authorizerUri refusal, so a regression in any of these boundary checks would pass the suite unnoticed.
Agent Prompt
## Issue description
The Events API validation in `AppSyncService` has no regression tests for the Cognito (`userPoolId`, `awsRegion`), OIDC (`issuer`) and `logConfig` (`logLevel`, `cloudWatchLogsRoleArn`) rejection paths. Compliance rule 3865583 requires a test per new validation path that asserts a 400 and no stored state change.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/appsync/AppSyncService.java[418-425]
- src/test/java/io/floci/aws/services/appsync/AppSyncServiceTest.java[860-870]
## Recommended Fix
In `AppSyncServiceTest`, add parameterized tests that call `createApi` with a COGNITO_USER_POOLS provider missing `userPoolId` or `awsRegion`, an OPENID_CONNECT provider missing `issuer`, an invalid `logConfig.logLevel`, and a missing `cloudWatchLogsRoleArn`. Each test should assert `BadRequestException` and that `listApis` is unchanged, following the pattern of `createApiRefusesALambdaProviderWithoutAnAuthorizerUri`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| ns = appSyncService.createChannelNamespace(apiId, req); | ||
| } | ||
|
|
||
| r.setPhysicalId(ns.getChannelNamespaceArn()); |
There was a problem hiding this comment.
2. Renamed namespaces remain after updates 🐞 Bug ≡ Correctness
provisionChannelNamespace creates a namespace when ApiId or Name changes, then overwrites the resource identifiers without recording the displaced namespace for cleanup. After a successful stack update, the old namespace remains in AppSync and can conflict with a later attempt to reuse its name.
Agent Prompt
## Issue description
A successful namespace replacement leaves its previous namespace behind.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/cloudformation/provisioners/AppSyncCfnProvisioner.java[556-579]
- src/main/java/io/floci/aws/services/cloudformation/provisioners/AppSyncCfnProvisioner.java[610-617]
## Recommended Fix
Record the displaced namespace's API ID and name when creating its replacement, implement replacement detection and post-commit cleanup, and retain the tracking state until cleanup succeeds.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| } else { | ||
| if (!tags.isEmpty()) { | ||
| req.put("tags", tags); | ||
| } | ||
| ns = appSyncService.createChannelNamespace(apiId, req); |
There was a problem hiding this comment.
3. Namespace replacement blocks rollback 🐞 Bug ☼ Reliability
provisionChannelNamespace takes the creation branch for a replacement but records no snapshot or other state that rollbackUpdate can use to undo it. If a later resource fails during the stack update, the rollback walker treats this as an update to an existing resource, cannot remove the newly created namespace, and marks rollback failed.
Agent Prompt
## Issue description
A failed stack update cannot roll back a namespace replacement.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/cloudformation/provisioners/AppSyncCfnProvisioner.java[556-579]
- src/main/java/io/floci/aws/services/cloudformation/provisioners/AppSyncCfnProvisioner.java[584-594]
## Recommended Fix
Persist the previous and replacement identities on the attempted resource. Teach rollback to delete the replacement and restore the prior resource identity, while keeping successful-update cleanup separate.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| public Api getApi(String apiId) { | ||
| return eventApiStore.get(apiId) | ||
| .orElseThrow(() -> new AwsException("NotFoundException", "API not found: " + apiId, 404)); | ||
| } | ||
|
|
||
| public Page<Api> listApis(Integer maxResults, String nextToken) { | ||
| return paginate(eventApiStore.scan(k -> true), nextToken, maxResults); | ||
| } |
There was a problem hiding this comment.
4. Other regions can delete events apis 🐞 Bug ≡ Correctness
getApi, listApis, updateApi, and deleteApi use an account-scoped store without comparing the request region to the API ARN's region. A request from the same account signed for a different served region can list, read, modify, or delete the API, including its children on deletion.
Agent Prompt
## Issue description
Events API lookups ignore the region of the incoming request.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/appsync/AppSyncService.java[286-317]
- src/main/java/io/floci/aws/services/appsync/AppSyncService.java[473-501]
## Recommended Fix
Filter listings and reject API and child-resource lookups whose stored ARN region differs from the effective request region. Preserve explicit stack-region context for CloudFormation worker calls.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| public Response createApi(@Context HttpHeaders headers, String body) throws IOException { | ||
| Api api = service.createApi(readRequest(body), regionResolver.resolveRegion(headers)); | ||
| return Response.ok(wrap(api)).build(); |
There was a problem hiding this comment.
5. Query-signed apis get the wrong region 🐞 Bug ≡ Correctness
createApi passes RegionResolver.resolveRegion(headers) to the service, but that method does not read the credential in a query-signed request. When such a request has no Authorization header and signs for a region other than the configured default, the created API receives the default region in its ARN and DNS names.
Agent Prompt
## Issue description
Query-signed creates use the deployment default instead of the credential's region.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/appsync/AppSyncApiController.java[49-52]
## Recommended Fix
Use the region already established in request context for API creation, including query-signed requests, rather than resolving it solely from headers.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| `EventConfig` is replaced as a whole. A template without `EventConfig` fails the resource, since | ||
| `CreateApi` requires one. |
There was a problem hiding this comment.
7. Docs promise a failure that updates never raise 🐞 Bug ⚙ Maintainability
The new docs say a template without EventConfig fails the resource, but the provisioner lists EventConfig as kept-on-drop for AWS::AppSync::Api, so clearDropped leaves it out of the UpdateApi request. Only a create fails. An UpdateStack that drops EventConfig succeeds and keeps the old config, so a reader who trusts the docs gets the wrong result.
Agent Prompt
## Issue description
The docs say a template without `EventConfig` fails the resource. That only happens on create. On update, a dropped `EventConfig` is kept.
## Fix Focus Areas
- docs/services/appsync.md[655-657]
## Recommended Fix
Rewrite the sentence: "A create without `EventConfig` fails the resource, since `CreateApi` requires one; an update that drops it keeps the API's current event config."
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| private Double created; | ||
| private HandlerConfigs handlerConfigs; | ||
| private Long lastModified; | ||
| private Double lastModified; |
There was a problem hiding this comment.
6. Saved namespaces show far-future dates 🐞 Bug ≡ Correctness
ChannelNamespace.created and lastModified are now read and emitted as epoch seconds, but previously persisted millisecond values are not converted when the store loads. After an upgrade using persistent storage, SDK clients receive creation dates far in the future, and updating a namespace does not correct its original created value.
Agent Prompt
## Issue description
Previously saved channel namespace timestamps retain millisecond values under the new seconds-based model, so records loaded after an upgrade expose dates far in the future.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/appsync/model/ChannelNamespace.java[19-21]
- src/main/java/io/floci/aws/services/appsync/model/ChannelNamespace.java[41-48]
- src/main/java/io/floci/aws/services/appsync/AppSyncService.java[1214-1216]
## Recommended Fix
Normalize legacy `created` and `lastModified` values when loading persisted namespaces, before exposing or updating them. In the timestamp setters or Jackson setters used on load, divide values greater than about 1e11 by 1000 to convert legacy milliseconds to seconds. Test loading and updating a namespace saved in the previous storage format, including that its creation date remains correct.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
@MasterOfMastersDestoyerOfWorlds welcome, and thanks for your first PR! This one carries #8911's first commit underneath the CloudFormation work, so it can't be reviewed on its own yet. Could you rebase it onto A couple of small things for then: both commits need signing, which |
|
@MasterOfMastersDestoyerOfWorlds I'm closing this one too, since it is built on #8911, which I closed, and it has been quiet for a few days. The CloudFormation work is welcome once the Events API management is in: a fresh PR on top of |
Summary
Depends on Pull Request #8911
Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
Checklist
./mvnw testpasses locally