-
Notifications
You must be signed in to change notification settings - Fork 14
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
base: master
Are you sure you want to change the base?
Conversation
**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) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the same as throwing a Terminal Exception?
You can check by attempting it in native then attempt in Uluru and see how you should handle the error
@@ -4,6 +4,7 @@ | |||
import software.amazon.cloudformation.LambdaWrapper; | |||
import software.amazon.awssdk.regions.Region; | |||
|
|||
|
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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?
Modified
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.