Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated SNS Subscription handlers for resource migration. #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

.topicArn(attributes.get(Definitions.topicArn))
.endpoint(attributes.get(Definitions.endpoint))
.protocol(attributes.get(Definitions.protocol))
.filterPolicy(attributes.get(Definitions.filterPolicy) != null ? SnsSubscriptionUtils.convertToJson(attributes.get(Definitions.filterPolicy)) : null)
.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.

@@ -4,6 +4,7 @@
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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants