Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Conversation

ziarrdan
Copy link

Modified

  • aws-sns-subscription/src/main/*: Updated CRUDL handlers for migration,
  • aws-sns-subscription/src/test/*: Updated unit tests.

Issue #, if available:
CFN-47468

Description of changes:
Updated SNS Subscription handlers for resource migration.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

**Modified**
- aws-sns-subscription/src/main/*: Updated CRUDL handlers for migration,
- aws-sns-subscription/src/test/*: Updated unit tests.
request.getClientRequestToken()));

return proxy.initiate("AWS-SNS-Subscription::Create", proxyClient, resourceModel, callbackContext)
.translateToServiceRequest(Translator::translateToCreateRequest)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.handleError((awsRequest, exception, client, model, context) -> handleError(awsRequest, exception, client, model, context))
.done((getSubscriptionsRequest, getSubscriptionsResponse, client, resourceModel1, context) ->
ProgressEvent.<ResourceModel, CallbackContext>builder()
.resourceModels(Translator.translateFromListRequest(getSubscriptionsResponse))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List handler should only return the primaryIds I see topicArn & protocol properties in your translateFromListRequest model

.redrivePolicy(attributes.get(Definitions.redrivePolicy) != null ? SnsSubscriptionUtils.convertToJson(attributes.get(Definitions.redrivePolicy)) : null)
.deliveryPolicy(attributes.get(Definitions.deliveryPolicy) != null ? SnsSubscriptionUtils.convertToJson(attributes.get(Definitions.deliveryPolicy)) : null)
.rawMessageDelivery(rawMessageDelivery)
.rawMessageDelivery(attributes.get(Definitions.rawMessageDelivery) != null ? Boolean.valueOf(attributes.get(Definitions.rawMessageDelivery)) : null)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this always be null if it isn't entered? could it be empty? asking if it would be better to do a NotNullOrEmpty() check instead of only checking for null

if (!StringUtils.equals(
prevRegion == null ? currentRequestRegion : prevRegion,
curRegion == null ? currentRequestRegion : curRegion)) {
throw new CfnNotUpdatableException(ResourceModel.TYPE_NAME, currentModel.getRegion());
Copy link

@ceskander-aws ceskander-aws Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import software.amazon.cloudformation.LambdaWrapper;
import software.amazon.awssdk.regions.Region;


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.translateToServiceRequest((resouceModel) -> Translator.translateToUpdateRequest(subscriptionAttribute, resouceModel, previousRawMessageDelivery, desiredRawMessageDelivery))
.makeServiceCall(this::updateSubscription)
.stabilize(this::stabilizeSnsSubscription)
return proxy.initiate("AWS-SNS-Subscription::Update-"+subscriptionAttribute.name(), proxyClient, model, progress.getCallbackContext())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request.getClientRequestToken()));

return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext)
.then(progress -> checkSubscriptionExistsAndSetSubscriptionArn(proxy, proxyClient, request, progress, callbackContext, true, logger))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since as you said we are asking to use read permissions for the delete handler will this need a soft failure?

.then(progress -> proxy.initiate("AWS-SNS-Subscription::Delete", proxyClient, resourceModel, callbackContext)
.translateToServiceRequest(Translator::translateToDeleteRequest)
.makeServiceCall((unsubscribeRequest, client) -> client.injectCredentialsAndInvokeV2(unsubscribeRequest, proxyClient.client()::unsubscribe))
.handleError((awsRequest, exception, client, model, context) -> handleError(awsRequest, exception, client, model, context))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.handleError((awsRequest, exception, client, model, context) -> handleError(awsRequest, exception, client, model, context))
.progress())
.then(progress -> {
if (progress.getCallbackContext().isPropagationDelay()) {
Copy link

@ceskander-aws ceskander-aws Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you point out in the native code where a propagation delay occurs for a delete?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants