private void associateKmsKey()

in aws-logs-loggroup/src/main/java/software/amazon/logs/loggroup/UpdateHandler.java [138:166]


    private void associateKmsKey(final AmazonWebServicesClientProxy proxy,
                                 final ResourceHandlerRequest<ResourceModel> request,
                                 final Logger logger) {
        final ResourceModel model = request.getDesiredResourceState();
        final AssociateKmsKeyRequest associateKmsKeyRequest =
                Translator.translateToAssociateKmsKeyRequest(model);
        try {
            proxy.injectCredentialsAndInvokeV2(associateKmsKeyRequest,
                    ClientBuilder.getClient()::associateKmsKey);
        } catch (final ResourceNotFoundException e) {
            // The specified resource does not exist.
            throwNotFoundException(model);
        } catch (final InvalidParameterException e) {
            // A parameter is specified incorrectly. We should be passing valid parameters.
            throw new CfnInternalFailureException(e);
        } catch (final OperationAbortedException e){
            // Multiple requests to update the same resource were in conflict.
            throw new CfnResourceConflictException(ResourceModel.TYPE_NAME,
                Objects.toString(model.getPrimaryIdentifier()), "OperationAborted", e);
        } catch (final ServiceUnavailableException e) {
            // The service cannot complete the request.
            throw new CfnServiceInternalErrorException(e);
        }

        final String kmsKeyMessage =
                String.format("%s [%s] successfully associated kms key: [%s].",
                        ResourceModel.TYPE_NAME, model.getLogGroupName(), model.getKmsKeyId());
        logger.log(kmsKeyMessage);
    }